feat: mentor can remove mentee

This commit is contained in:
Livio Bieri 2024-03-20 14:42:07 +01:00
parent 5f9b7a86fd
commit dd121fe1ac
4 changed files with 33 additions and 10 deletions

View File

@ -1,9 +1,17 @@
<script setup lang="ts">
import { useLearningMentees } from "@/services/learningMentees";
import { useCurrentCourseSession } from "@/composables";
import { useCSRFFetch } from "@/fetchHelpers";
const courseSession = useCurrentCourseSession();
const { summary } = useLearningMentees(courseSession.value.id);
const { summary, fetchData } = useLearningMentees(courseSession.value.id);
const removeMyMentee = async (menteeId: string) => {
await useCSRFFetch(
`/api/mentor/${courseSession.value.id}/mentors/${summary.value?.mentor_id}/remove/${menteeId}`
).delete();
fetchData();
};
</script>
<template>
@ -32,15 +40,23 @@ const { summary } = useLearningMentees(courseSession.value.id);
{{ participant.email }}
</div>
</div>
<router-link
:to="{
name: 'profileLearningPath',
params: { userId: participant.id, courseSlug: courseSession.course.slug },
}"
class="underline"
>
{{ $t("cockpit.profileLink") }}
</router-link>
<div class="space-x-5">
<router-link
:to="{
name: 'profileLearningPath',
params: {
userId: participant.id,
courseSlug: courseSession.course.slug,
},
}"
class="underline"
>
{{ $t("cockpit.profileLink") }}
</router-link>
<button class="underline" @click="removeMyMentee(participant.id)">
{{ $t("a.Entfernen") }}
</button>
</div>
</div>
</div>
</template>

View File

@ -41,6 +41,7 @@ export interface Assignment {
}
export interface Summary {
mentor_id: string;
participants: Participant[];
circles: Circle[];
assignments: Assignment[];

View File

@ -113,6 +113,11 @@ class LearningMentorAPITest(APITestCase):
self.assertEqual(participant_1["first_name"], "Test")
self.assertEqual(participant_1["last_name"], "Participant_1")
self.assertEqual(
response.data["mentor_id"],
mentor.id,
)
def test_api_self_evaluation_feedback(self) -> None:
# GIVEN
participants = [self.participant_1, self.participant_2, self.participant_3]

View File

@ -71,6 +71,7 @@ def mentor_summary(request, course_session_id: int):
)
return Response(
{
"mentor_id": mentor.id,
"participants": [UserSerializer(user).data for user in users],
"circles": list(
Circle.objects.filter(id__in=circle_ids).values("id", "title")