fix: cockpit type for supervisor
This commit is contained in:
parent
368ef7d16e
commit
49f2c68889
|
|
@ -8,6 +8,7 @@ from vbv_lernwelt.course.creators.test_utils import (
|
||||||
create_user,
|
create_user,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.course.models import CourseSessionUser
|
from vbv_lernwelt.course.models import CourseSessionUser
|
||||||
|
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
|
||||||
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -57,3 +58,23 @@ class MeUserViewTest(APITestCase):
|
||||||
# THEN
|
# THEN
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEquals(response.data["type"], "expert")
|
self.assertEquals(response.data["type"], "expert")
|
||||||
|
|
||||||
|
def test_supervisor_cockpit(self):
|
||||||
|
# GIVEN
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
course_session = create_course_session(course=self.course, title="Test Session")
|
||||||
|
|
||||||
|
csg = CourseSessionGroup.objects.create(
|
||||||
|
name="Test Group",
|
||||||
|
course=course_session.course,
|
||||||
|
)
|
||||||
|
|
||||||
|
csg.course_session.add(course_session)
|
||||||
|
csg.supervisor.add(self.user)
|
||||||
|
|
||||||
|
# WHEN
|
||||||
|
response = self.client.get(self.url)
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertEquals(response.data["type"], "expert")
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ from rest_framework.permissions import IsAuthenticated
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from vbv_lernwelt.course.models import Course, CourseSessionUser
|
from vbv_lernwelt.course.models import Course, CourseSessionUser
|
||||||
|
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
|
||||||
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,5 +24,9 @@ def get_cockpit_type(request, course_id: int):
|
||||||
role=CourseSessionUser.Role.EXPERT,
|
role=CourseSessionUser.Role.EXPERT,
|
||||||
).exists():
|
).exists():
|
||||||
cockpit_type = "expert"
|
cockpit_type = "expert"
|
||||||
|
elif CourseSessionGroup.objects.filter(
|
||||||
|
course_session__course=course, supervisor=request.user
|
||||||
|
).exists():
|
||||||
|
cockpit_type = "expert"
|
||||||
|
|
||||||
return Response({"type": cockpit_type})
|
return Response({"type": cockpit_type})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue