Merged in bugfix/VBV-642-lernbegleitung-lehrgang (pull request #287)
fix: allow same mentor in different courses Approved-by: Christian Cueni
This commit is contained in:
commit
b5381caf3c
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 3.2.20 on 2024-02-12 09:25
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
("learning_mentor", "0004_alter_mentorinvitation_unique_together"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="learningmentor",
|
||||||
|
name="mentor",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -8,7 +8,7 @@ from vbv_lernwelt.course.models import CourseSessionUser
|
||||||
|
|
||||||
|
|
||||||
class LearningMentor(models.Model):
|
class LearningMentor(models.Model):
|
||||||
mentor = models.OneToOneField(User, on_delete=models.CASCADE)
|
mentor = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
course = models.ForeignKey("course.Course", on_delete=models.CASCADE)
|
course = models.ForeignKey("course.Course", on_delete=models.CASCADE)
|
||||||
|
|
||||||
participants = models.ManyToManyField(
|
participants = models.ManyToManyField(
|
||||||
|
|
|
||||||
|
|
@ -232,3 +232,15 @@ class LearningMentorAPITest(APITestCase):
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
LearningMentor.objects.filter(participants=participant_cs_user).exists()
|
LearningMentor.objects.filter(participants=participant_cs_user).exists()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_mentor_multiple_courses(self) -> None:
|
||||||
|
# GIVEN
|
||||||
|
course_a, _ = create_course("Course A")
|
||||||
|
course_b, _ = create_course("Course B")
|
||||||
|
|
||||||
|
# WHEN
|
||||||
|
LearningMentor.objects.create(mentor=self.mentor, course=course_a)
|
||||||
|
LearningMentor.objects.create(mentor=self.mentor, course=course_b)
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
self.assertEqual(LearningMentor.objects.count(), 2)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue