Add `BERUFSBILDNER`-role
This commit is contained in:
parent
57384fcf5d
commit
b6590c0b86
|
|
@ -66,6 +66,7 @@ class RoleKeyType(Enum):
|
||||||
MENTOR_UK = "MentorUK"
|
MENTOR_UK = "MentorUK"
|
||||||
SUPERVISOR = "Supervisor"
|
SUPERVISOR = "Supervisor"
|
||||||
TRAINER = "Trainer"
|
TRAINER = "Trainer"
|
||||||
|
BERUFSBILDNER = "Berufsbildner"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|
@ -89,7 +90,6 @@ class CourseConfig:
|
||||||
role_key: str
|
role_key: str
|
||||||
is_uk: bool
|
is_uk: bool
|
||||||
is_vv: bool
|
is_vv: bool
|
||||||
is_mentor: bool
|
|
||||||
widgets: List[str]
|
widgets: List[str]
|
||||||
has_preview: bool
|
has_preview: bool
|
||||||
session_to_continue_id: str | None
|
session_to_continue_id: str | None
|
||||||
|
|
@ -121,15 +121,15 @@ def get_course_sessions_with_roles_for_user(user: User) -> List[CourseSessionWit
|
||||||
result_course_sessions[cs.id] = cs
|
result_course_sessions[cs.id] = cs
|
||||||
|
|
||||||
# enrich with mentor course sessions
|
# enrich with mentor course sessions
|
||||||
lm_qs = AgentParticipantRelation.objects.filter(agent=user).prefetch_related(
|
agent_qs = AgentParticipantRelation.objects.filter(agent=user).prefetch_related(
|
||||||
"participant__course_session", "participant__course_session__course"
|
"participant__course_session", "participant__course_session__course"
|
||||||
)
|
)
|
||||||
for lm in lm_qs:
|
for agent_relation in agent_qs:
|
||||||
cs = lm.participant.course_session
|
cs = agent_relation.participant.course_session
|
||||||
cs.roles = set()
|
cs.roles = set()
|
||||||
cs = result_course_sessions.get(cs.id, cs)
|
cs = result_course_sessions.get(cs.id, cs)
|
||||||
|
|
||||||
cs.roles.add(lm.role)
|
cs.roles.add(agent_relation.role)
|
||||||
result_course_sessions[cs.id] = cs
|
result_course_sessions[cs.id] = cs
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
@ -358,7 +358,7 @@ def get_dashboard_due_dates(request):
|
||||||
|
|
||||||
|
|
||||||
def get_widgets_for_course(
|
def get_widgets_for_course(
|
||||||
role_key: RoleKeyType, is_uk: bool, is_vv: bool, is_mentor: bool
|
role_key: RoleKeyType, is_uk: bool, is_vv: bool
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
widgets = []
|
widgets = []
|
||||||
|
|
||||||
|
|
@ -371,7 +371,7 @@ def get_widgets_for_course(
|
||||||
if role_key in [RoleKeyType.SUPERVISOR, RoleKeyType.TRAINER] and is_uk:
|
if role_key in [RoleKeyType.SUPERVISOR, RoleKeyType.TRAINER] and is_uk:
|
||||||
widgets.append(WidgetType.UK_STATISTICS_WIDGET.value)
|
widgets.append(WidgetType.UK_STATISTICS_WIDGET.value)
|
||||||
|
|
||||||
if is_mentor:
|
if role_key in [RoleKeyType.MENTOR_UK, RoleKeyType.MENTOR_VV]:
|
||||||
widgets.append(WidgetType.MENTOR_PERSON_WIDGET.value)
|
widgets.append(WidgetType.MENTOR_PERSON_WIDGET.value)
|
||||||
if is_uk:
|
if is_uk:
|
||||||
widgets.append(WidgetType.MENTOR_COMPETENCE_WIDGET.value)
|
widgets.append(WidgetType.MENTOR_COMPETENCE_WIDGET.value)
|
||||||
|
|
@ -400,9 +400,10 @@ def get_role_key_and_mentor(
|
||||||
role = RoleKeyType.MENTOR_UK
|
role = RoleKeyType.MENTOR_UK
|
||||||
elif is_vv:
|
elif is_vv:
|
||||||
role = RoleKeyType.MENTOR_VV
|
role = RoleKeyType.MENTOR_VV
|
||||||
|
elif "BERUFSBILDNER" in roles:
|
||||||
|
role = RoleKeyType.BERUFSBILDNER
|
||||||
|
|
||||||
is_mentor = "LEARNING_MENTOR" in roles
|
return role
|
||||||
return role, is_mentor
|
|
||||||
|
|
||||||
|
|
||||||
def collect_course_sessions_by_course(
|
def collect_course_sessions_by_course(
|
||||||
|
|
@ -444,7 +445,7 @@ def get_course_config(
|
||||||
for _id, cs_in_course in cs_by_course.items():
|
for _id, cs_in_course in cs_by_course.items():
|
||||||
is_uk = cs_in_course[0].course.configuration.is_uk
|
is_uk = cs_in_course[0].course.configuration.is_uk
|
||||||
is_vv = cs_in_course[0].course.configuration.is_vv
|
is_vv = cs_in_course[0].course.configuration.is_vv
|
||||||
role_key, is_mentor = get_role_key_and_mentor(cs_in_course, is_uk, is_vv)
|
role_key = get_role_key_and_mentor(cs_in_course, is_uk, is_vv)
|
||||||
session_to_continue = get_newest_cs(cs_in_course)
|
session_to_continue = get_newest_cs(cs_in_course)
|
||||||
course_configs.append(
|
course_configs.append(
|
||||||
CourseConfig(
|
CourseConfig(
|
||||||
|
|
@ -454,8 +455,7 @@ def get_course_config(
|
||||||
role_key=role_key.value,
|
role_key=role_key.value,
|
||||||
is_uk=is_uk,
|
is_uk=is_uk,
|
||||||
is_vv=is_vv,
|
is_vv=is_vv,
|
||||||
is_mentor=is_mentor,
|
widgets=get_widgets_for_course(role_key, is_uk, is_vv),
|
||||||
widgets=get_widgets_for_course(role_key, is_uk, is_vv, is_mentor),
|
|
||||||
has_preview=has_preview(role_key),
|
has_preview=has_preview(role_key),
|
||||||
session_to_continue_id=(
|
session_to_continue_id=(
|
||||||
str(session_to_continue.id) if session_to_continue else None
|
str(session_to_continue.id) if session_to_continue else None
|
||||||
|
|
@ -511,9 +511,7 @@ def get_mentor_open_tasks_count(request, course_id: str):
|
||||||
return Response(
|
return Response(
|
||||||
status=200,
|
status=200,
|
||||||
data={
|
data={
|
||||||
"open_task_count": _get_mentor_open_tasks_count(
|
"open_task_count": _get_mentor_open_tasks_count(course_id, request.user) # noqa
|
||||||
course_id, request.user
|
|
||||||
) # noqa
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except PermissionDenied as e:
|
except PermissionDenied as e:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue