Render due dates without url for `LEARNING_MENTOR`

This commit is contained in:
Daniel Egger 2024-04-25 13:56:01 +02:00
parent bb57591387
commit daa8a16e55
2 changed files with 21 additions and 7 deletions

View File

@ -30,6 +30,12 @@ const urlText = computed(() => {
return result.trim(); return result.trim();
}); });
const showAsUrl = computed(() => {
return ["SUPERVISOR", "EXPERT", "MEMBER"].includes(
props.dueDate.course_session.my_role
);
});
const url = computed(() => { const url = computed(() => {
if (["SUPERVISOR", "EXPERT"].includes(props.dueDate.course_session.my_role)) { if (["SUPERVISOR", "EXPERT"].includes(props.dueDate.course_session.my_role)) {
return props.dueDate.url_expert; return props.dueDate.url_expert;
@ -45,18 +51,24 @@ const url = computed(() => {
> >
<div class="space-y-1"> <div class="space-y-1">
<div> <div>
<a :href="url"> <a v-if="showAsUrl" :href="url">
<span class="text-bold text-gray-900"> <span class="text-bold text-gray-900">
{{ dayjs(props.dueDate.start).format("dddd D. MMMM YYYY") }} {{ dayjs(props.dueDate.start).format("dddd D. MMMM YYYY") }}
</span> </span>
</a> </a>
<span v-else class="text-bold text-gray-900">
{{ dayjs(props.dueDate.start).format("dddd D. MMMM YYYY") }}
</span>
</div> </div>
<div> <div>
<a class="underline" :href="url"> <a v-if="showAsUrl" class="underline" :href="url">
<span class="text-bold"> <span class="text-bold">
{{ urlText }} {{ urlText }}
</span> </span>
</a> </a>
<span v-else class="text-bold">
{{ urlText }}
</span>
</div> </div>
<div class="text-small text-gray-900"> <div class="text-small text-gray-900">
<div> <div>

View File

@ -117,11 +117,13 @@ def has_cs_role(roles: Set[str]) -> bool:
def user_role(roles: Set[str]) -> str: def user_role(roles: Set[str]) -> str:
return ( if "SUPERVISOR" in roles:
"SUPERVISOR" return "SUPERVISOR"
if "SUPERVISOR" in roles if "EXPERT" in roles:
else ("EXPERT" if "EXPERT" in roles else "MEMBER") return "EXPERT"
) if "MEMBER" in roles:
return "MEMBER"
return "LEARNING_MENTOR"
@api_view(["GET"]) @api_view(["GET"])