From b1743df9f2b4ad7617eb0148bd9ed37b408a44cb Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 24 Apr 2023 20:11:11 +0200 Subject: [PATCH 1/7] fix: remove sentry config --- config/config.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index de956d3f..8e660a1e 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -8,10 +8,6 @@ hosting_config: ssl: true use_default_org: false default_org: learnhouse - sentry_config: - dsn: "https://1a6aa22656224851af492aae5d4155a1@o4505007882436608.ingest.sentry.io/4505007884599296" - environment: dev - release: "0.1.0" allowed_origins: - http://localhost:3000 - http://localhost:3001 From 74ccbc573897a4beef9ab4e1e47921f3d49f5c72 Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 24 Apr 2023 20:42:06 +0200 Subject: [PATCH 2/7] fix: verify sentry config before starting --- config/config.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/config/config.py b/config/config.py index 36021252..a5d215c2 100644 --- a/config/config.py +++ b/config/config.py @@ -103,6 +103,9 @@ def get_learnhouse_config() -> LearnHouseConfig: 'database_config', {}).get('mongodb_connection_string') # Sentry config + # check if the sentry config is provided in the YAML file + sentry_config_verif = yaml_config.get('hosting_config', {}).get('sentry_config') or env_sentry_dsn or env_sentry_environment or env_sentry_release or None + sentry_dsn = env_sentry_dsn or yaml_config.get( 'hosting_config', {}).get('sentry_config', {}).get('dsn') sentry_environment = env_sentry_environment or yaml_config.get( @@ -110,11 +113,16 @@ def get_learnhouse_config() -> LearnHouseConfig: sentry_release = env_sentry_release or yaml_config.get( 'hosting_config', {}).get('sentry_config', {}).get('release') - sentry_config = SentryConfig( - dsn=sentry_dsn, - environment=sentry_environment, - release=sentry_release - ) + if sentry_config_verif: + sentry_config = SentryConfig( + dsn=sentry_dsn, + environment=sentry_environment, + release=sentry_release + ) + else: + sentry_config = None + + # Create HostingConfig and DatabaseConfig objects hosting_config = HostingConfig( From 3f2d9d2b9f61176f7783fc9a149bbc9c043a3e6a Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 24 Apr 2023 20:42:25 +0200 Subject: [PATCH 3/7] feat: deny anonymous user from getting orgs --- src/services/orgs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/services/orgs.py b/src/services/orgs.py index a0de2f47..7934ff86 100644 --- a/src/services/orgs.py +++ b/src/services/orgs.py @@ -149,6 +149,12 @@ async def get_orgs_by_user(request: Request, user_id: str, page: int = 1, limit: orgs = request.app.db["organizations"] user = request.app.db["users"] + if user_id is "anonymous": + + # raise error + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, detail="User not logged in") + # get user orgs user_orgs = await user.find_one({"user_id": user_id}) From 394f4e0b5a079cf6d622bd30e6d72d9a87bbfe11 Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 24 Apr 2023 20:46:01 +0200 Subject: [PATCH 4/7] fix: collection creation bug --- front/app/_orgs/[orgslug]/(withmenu)/collections/new/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/app/_orgs/[orgslug]/(withmenu)/collections/new/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/collections/new/page.tsx index 5a190dec..84421186 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/collections/new/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/collections/new/page.tsx @@ -4,7 +4,7 @@ import React from "react"; import { Title } from "@components/UI/Elements/Styles/Title"; import { createCollection } from "@services/courses/collections"; import useSWR from "swr"; -import { getAPIUrl } from "@services/config/config"; +import { getAPIUrl, getUriWithOrg } from "@services/config/config"; import { swrFetcher } from "@services/utils/ts/requests"; import { getOrganizationContextInfo } from "@services/organizations/orgs"; @@ -44,7 +44,7 @@ function NewCollection(params : any) { org_id: org.org_id, }; await createCollection(collection); - router.push("/org/" + orgslug + "/collections"); + router.push(getUriWithOrg(orgslug, "/collections")); }; From 1a173964fe421932057473c98758e289727f3c90 Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 24 Apr 2023 20:47:19 +0200 Subject: [PATCH 5/7] fix: org deletion bug --- src/services/courses/collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/courses/collections.py b/src/services/courses/collections.py index 387d910d..817f5e54 100644 --- a/src/services/courses/collections.py +++ b/src/services/courses/collections.py @@ -156,7 +156,7 @@ async def verify_collection_rights(request: Request,collection_id: str, current raise HTTPException( status_code=status.HTTP_409_CONFLICT, detail="Collection does not exist") - hasRoleRights = await verify_user_rights_with_roles(request, action, current_user.user_id, collection_id) + hasRoleRights = await verify_user_rights_with_roles(request, action, current_user.user_id, collection_id, collection["org_id"]) if not hasRoleRights: raise HTTPException( From 76324bc257c10a2dd5d0203b73792f34aa13c219 Mon Sep 17 00:00:00 2001 From: swve Date: Mon, 24 Apr 2023 22:51:33 +0200 Subject: [PATCH 6/7] feat: improve chapters and courses indicators --- .../[courseid]/activity/[activityid]/page.tsx | 32 ++++++++------- .../(withmenu)/course/[courseid]/page.tsx | 40 ++++++++++++------- front/components/Editor/Editor.tsx | 1 - .../Editor/Toolbar/ToolbarButtons.tsx | 2 +- front/components/UI/Tooltip/Tooltip.tsx | 22 +++++++--- 5 files changed, 60 insertions(+), 37 deletions(-) diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx index 98df7ec9..92591a79 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx @@ -5,13 +5,14 @@ import React, { useMemo } from "react"; import { getActivity } from "@services/courses/activities"; import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config/config"; import Canva from "@components/Pages/Activities/DynamicCanva/DynamicCanva"; -import styled from "styled-components"; +import styled from "styled-components"; import { getCourse } from "@services/courses/courses"; import VideoActivity from "@components/Pages/Activities/Video/Video"; import useSWR, { mutate } from "swr"; import { Check } from "lucide-react"; import { swrFetcher } from "@services/utils/ts/requests"; import { markActivityAsComplete } from "@services/courses/activity"; +import ToolTip from "@components/UI/Tooltip/Tooltip"; function ActivityPage(params: any) { const activityid = params.params.activityid; @@ -37,7 +38,7 @@ function ActivityPage(params: any) { - + @@ -53,11 +54,14 @@ function ActivityPage(params: any) {
{chapter.activities.map((activity: any) => { return ( - <> - - - {" "} - + + + + + ); })}
@@ -74,10 +78,10 @@ function ActivityPage(params: any) { {activity.type == "video" && } - + {course.trail.activities_marked_complete && - course.trail.activities_marked_complete.includes("activity_" + activityid) && - course.trail.status == "ongoing" ? ( + course.trail.activities_marked_complete.includes("activity_" + activityid) && + course.trail.status == "ongoing" ? (