chore: cockpit for mentor
This commit is contained in:
parent
14e8d5da49
commit
e61dce95f6
|
|
@ -70,12 +70,31 @@ onMounted(() => {
|
||||||
log.debug("MainNavigationBar mounted");
|
log.debug("MainNavigationBar mounted");
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasMediaLibrary = computed(() => {
|
const hasMediaLibraryMenu = computed(() => {
|
||||||
if (useCockpitStore().hasMentorCockpitType) {
|
if (useCockpitStore().hasMentorCockpitType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return inCourse() && Boolean(courseSessionsStore.currentCourseSession);
|
return inCourse() && Boolean(courseSessionsStore.currentCourseSession);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hasCockpitMenu = computed(() => {
|
||||||
|
return courseSessionsStore.currentCourseSessionHasCockpit;
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasPreviewMenu = computed(() => {
|
||||||
|
return useCockpitStore().hasExpertCockpitType;
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasAppointmentsMenu = computed(() => {
|
||||||
|
if (useCockpitStore().hasMentorCockpitType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return userStore.loggedIn;
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasNotificationsMenu = computed(() => {
|
||||||
|
return userStore.loggedIn;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -86,7 +105,7 @@ const hasMediaLibrary = computed(() => {
|
||||||
v-if="userStore.loggedIn"
|
v-if="userStore.loggedIn"
|
||||||
:show="state.showMobileNavigationMenu"
|
:show="state.showMobileNavigationMenu"
|
||||||
:course-session="courseSessionsStore.currentCourseSession"
|
:course-session="courseSessionsStore.currentCourseSession"
|
||||||
:has-media-library="hasMediaLibrary"
|
:has-media-library="hasMediaLibraryMenu"
|
||||||
:media-url="
|
:media-url="
|
||||||
getMediaCenterUrl(courseSessionsStore.currentCourseSession?.course?.slug)
|
getMediaCenterUrl(courseSessionsStore.currentCourseSession?.course?.slug)
|
||||||
"
|
"
|
||||||
|
|
@ -146,6 +165,7 @@ const hasMediaLibrary = computed(() => {
|
||||||
<div class="hidden space-x-8 lg:flex">
|
<div class="hidden space-x-8 lg:flex">
|
||||||
<template v-if="courseSessionsStore.currentCourseSessionHasCockpit">
|
<template v-if="courseSessionsStore.currentCourseSessionHasCockpit">
|
||||||
<router-link
|
<router-link
|
||||||
|
v-if="hasCockpitMenu"
|
||||||
data-cy="navigation-cockpit-link"
|
data-cy="navigation-cockpit-link"
|
||||||
:to="
|
:to="
|
||||||
getCockpitUrl(
|
getCockpitUrl(
|
||||||
|
|
@ -159,6 +179,7 @@ const hasMediaLibrary = computed(() => {
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
|
v-if="hasPreviewMenu"
|
||||||
data-cy="navigation-preview-link"
|
data-cy="navigation-preview-link"
|
||||||
:to="
|
:to="
|
||||||
getLearningPathUrl(
|
getLearningPathUrl(
|
||||||
|
|
@ -220,7 +241,7 @@ const hasMediaLibrary = computed(() => {
|
||||||
|
|
||||||
<div class="flex items-stretch justify-start space-x-8">
|
<div class="flex items-stretch justify-start space-x-8">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="hasMediaLibrary"
|
v-if="hasMediaLibraryMenu"
|
||||||
:to="
|
:to="
|
||||||
getMediaCenterUrl(
|
getMediaCenterUrl(
|
||||||
courseSessionsStore.currentCourseSession?.course.slug
|
courseSessionsStore.currentCourseSession?.course.slug
|
||||||
|
|
@ -234,7 +255,7 @@ const hasMediaLibrary = computed(() => {
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-if="userStore.loggedIn"
|
v-if="hasAppointmentsMenu"
|
||||||
:to="appointmentsUrl"
|
:to="appointmentsUrl"
|
||||||
data-cy="all-duedates-link"
|
data-cy="all-duedates-link"
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
|
|
@ -244,7 +265,7 @@ const hasMediaLibrary = computed(() => {
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<!-- Notification Bell & Menu -->
|
<!-- Notification Bell & Menu -->
|
||||||
<div v-if="userStore.loggedIn" class="nav-item leading-none">
|
<div v-if="hasNotificationsMenu" class="nav-item leading-none">
|
||||||
<NotificationPopover>
|
<NotificationPopover>
|
||||||
<template #toggleButtonContent>
|
<template #toggleButtonContent>
|
||||||
<div class="relative h-8 w-8">
|
<div class="relative h-8 w-8">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { itGetCached } from "@/fetchHelpers";
|
import { itGetCached } from "@/fetchHelpers";
|
||||||
|
import { useCockpitStore } from "@/stores/cockpit";
|
||||||
import type { CourseSession, DueDate } from "@/types";
|
import type { CourseSession, DueDate } from "@/types";
|
||||||
import eventBus from "@/utils/eventBus";
|
import eventBus from "@/utils/eventBus";
|
||||||
import { useRouteLookups } from "@/utils/route";
|
import { useRouteLookups } from "@/utils/route";
|
||||||
|
|
@ -149,6 +150,9 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
function hasCockpit(courseSession: CourseSession) {
|
function hasCockpit(courseSession: CourseSession) {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
return (
|
return (
|
||||||
|
useCockpitStore().hasMentorCockpitType ||
|
||||||
|
useCockpitStore().hasExpertCockpitType ||
|
||||||
|
// for legacy reasons: don't forget course session supervisors!
|
||||||
userStore.course_session_experts.includes(courseSession.id) ||
|
userStore.course_session_experts.includes(courseSession.id) ||
|
||||||
userStore.is_superuser
|
userStore.is_superuser
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from vbv_lernwelt.iam.permissions import (
|
||||||
is_circle_expert,
|
is_circle_expert,
|
||||||
is_course_session_expert,
|
is_course_session_expert,
|
||||||
)
|
)
|
||||||
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
|
|
||||||
logger = structlog.get_logger(__name__)
|
logger = structlog.get_logger(__name__)
|
||||||
|
|
||||||
|
|
@ -142,8 +143,17 @@ def get_course_sessions(request):
|
||||||
).values_list("course_session", flat=True)
|
).values_list("course_session", flat=True)
|
||||||
).prefetch_related("course")
|
).prefetch_related("course")
|
||||||
|
|
||||||
|
# enrich with mentor course sessions
|
||||||
|
mentor_course_sessions = CourseSession.objects.filter(
|
||||||
|
course__in=LearningMentor.objects.filter(mentor=request.user).values_list(
|
||||||
|
"course", flat=True
|
||||||
|
)
|
||||||
|
).prefetch_related("course")
|
||||||
|
|
||||||
all_to_serialize = (
|
all_to_serialize = (
|
||||||
regular_course_sessions | supervisor_course_sessions
|
regular_course_sessions
|
||||||
|
| supervisor_course_sessions
|
||||||
|
| mentor_course_sessions
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue