From 5ee6cc2596f9ab50ffdd192c4e63529e98d51214 Mon Sep 17 00:00:00 2001 From: Reto Aebersold Date: Mon, 18 Dec 2023 12:25:59 +0100 Subject: [PATCH] feat: store assigment user --- client/src/router/guards.ts | 13 +++++++++++++ client/src/router/index.ts | 6 ++++++ client/src/stores/dashboard.ts | 2 +- server/vbv_lernwelt/assignment/services.py | 1 + .../vbv_lernwelt/assignment/tests/test_services.py | 4 +++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/client/src/router/guards.ts b/client/src/router/guards.ts index 117372cb..4899cf7b 100644 --- a/client/src/router/guards.ts +++ b/client/src/router/guards.ts @@ -123,3 +123,16 @@ export async function handleCockpit(to: RouteLocationNormalized) { return "/"; } } + +export async function handleAcceptLearningMentorInvitation( + to: RouteLocationNormalized +) { + const user = useUserStore(); + if (user.loggedIn) { + return; + } + + return `/onboarding/vv-${user.language}/account/create?next=${encodeURIComponent( + to.fullPath + )}`; +} diff --git a/client/src/router/index.ts b/client/src/router/index.ts index c98e6462..c54a3044 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -1,6 +1,7 @@ import DashboardPage from "@/pages/dashboard/DashboardPage.vue"; import LoginPage from "@/pages/LoginPage.vue"; import { + handleAcceptLearningMentorInvitation, handleCockpit, handleCourseSessionAsQueryParam, handleCurrentCourseSession, @@ -132,6 +133,11 @@ const router = createRouter({ path: "/lernbegleitung/:courseId/invitation/:invitationId", component: () => import("@/pages/learningMentor/InvitationAcceptPage.vue"), props: true, + beforeEnter: handleAcceptLearningMentorInvitation, + meta: { + // The login redirect is handled in the beforeEnter guard + public: true, + }, }, { path: "/course/:courseSlug/cockpit", diff --git a/client/src/stores/dashboard.ts b/client/src/stores/dashboard.ts index 7286eec6..1b011169 100644 --- a/client/src/stores/dashboard.ts +++ b/client/src/stores/dashboard.ts @@ -48,7 +48,7 @@ export const useDashboardStore = defineStore("dashboard", () => { const loadDashboardConfig = async () => { if (dashboardConfigs.value.length > 0) return; const configData = await fetchDashboardConfig(); - if (configData) { + if (configData && configData.length > 0) { dashboardConfigs.value = configData; await switchAndLoadDashboardConfig(configData[0]); } diff --git a/server/vbv_lernwelt/assignment/services.py b/server/vbv_lernwelt/assignment/services.py index 548cec11..2e2b2ae1 100644 --- a/server/vbv_lernwelt/assignment/services.py +++ b/server/vbv_lernwelt/assignment/services.py @@ -154,6 +154,7 @@ def update_assignment_completion( if completion_status == AssignmentCompletionStatus.SUBMITTED: ac.submitted_at = timezone.now() if evaluation_user: + ac.evaluation_user = evaluation_user NotificationService.send_assignment_submitted_notification( recipient=evaluation_user, sender=ac.assignment_user, diff --git a/server/vbv_lernwelt/assignment/tests/test_services.py b/server/vbv_lernwelt/assignment/tests/test_services.py index 3708a8d0..988ee439 100644 --- a/server/vbv_lernwelt/assignment/tests/test_services.py +++ b/server/vbv_lernwelt/assignment/tests/test_services.py @@ -144,7 +144,7 @@ class UpdateAssignmentCompletionTestCase(TestCase): user_text_input0 = subtasks[0] user_text_input1 = subtasks[1] - ac = AssignmentCompletion.objects.create( + AssignmentCompletion.objects.create( assignment_user=self.user, assignment=self.assignment, course_session=self.course_session, @@ -163,6 +163,7 @@ class UpdateAssignmentCompletionTestCase(TestCase): assignment=self.assignment, course_session=self.course_session, completion_status=AssignmentCompletionStatus.SUBMITTED, + evaluation_user=self.trainer, ) ac = AssignmentCompletion.objects.get( @@ -173,6 +174,7 @@ class UpdateAssignmentCompletionTestCase(TestCase): self.assertEqual(ac.completion_status, "SUBMITTED") self.assertEqual(ac.submitted_at.date(), date.today()) + self.assertEqual(ac.evaluation_user, self.trainer) # will create AssignmentCompletionAuditLog entry acl = AssignmentCompletionAuditLog.objects.get(