chore: cleanup get_cockpit_type a bit
This commit is contained in:
parent
49f2c68889
commit
9706b41413
|
|
@ -14,19 +14,25 @@ from vbv_lernwelt.learning_mentor.models import LearningMentor
|
|||
def get_cockpit_type(request, course_id: int):
|
||||
course = get_object_or_404(Course, id=course_id)
|
||||
|
||||
cockpit_type = None
|
||||
is_mentor = LearningMentor.objects.filter(
|
||||
mentor=request.user, course=course
|
||||
).exists()
|
||||
|
||||
if LearningMentor.objects.filter(mentor=request.user, course=course).exists():
|
||||
cockpit_type = "mentor"
|
||||
elif CourseSessionUser.objects.filter(
|
||||
is_expert = CourseSessionUser.objects.filter(
|
||||
user=request.user,
|
||||
course_session__course=course,
|
||||
role=CourseSessionUser.Role.EXPERT,
|
||||
).exists():
|
||||
cockpit_type = "expert"
|
||||
elif CourseSessionGroup.objects.filter(
|
||||
).exists()
|
||||
|
||||
is_supervisor = CourseSessionGroup.objects.filter(
|
||||
course_session__course=course, supervisor=request.user
|
||||
).exists():
|
||||
).exists()
|
||||
|
||||
if is_mentor:
|
||||
cockpit_type = "mentor"
|
||||
elif is_expert or is_supervisor:
|
||||
cockpit_type = "expert"
|
||||
else:
|
||||
cockpit_type = None
|
||||
|
||||
return Response({"type": cockpit_type})
|
||||
|
|
|
|||
Loading…
Reference in New Issue