diff --git a/AKModel/locale/de_DE/LC_MESSAGES/django.po b/AKModel/locale/de_DE/LC_MESSAGES/django.po index 20298dd1bcaf17e2d368fa9ac67c75ca4e48633a..297ebfad2a3427e3addbaaa8314bd9a67bc0846f 100644 --- a/AKModel/locale/de_DE/LC_MESSAGES/django.po +++ b/AKModel/locale/de_DE/LC_MESSAGES/django.po @@ -1084,6 +1084,10 @@ msgid "" "Name to identify a participant by (in case of questions from the organizers)" msgstr "Name, zur Identifikation bei Rückfragen von den Organisator*innen" +#: AKModel/models.py:1370 +msgid "Participant's Requirements" +msgstr "Anforderungen der Teilnehmer*in" + #: AKModel/models.py:1370 #, python-brace-format msgid "Anonymous {pk}" diff --git a/AKModel/migrations/0067_eventparticipant_requirements_and_more.py b/AKModel/migrations/0067_eventparticipant_requirements_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..8f1bd8e211af2c60a8d539c63f9011ab4c5dbf3c --- /dev/null +++ b/AKModel/migrations/0067_eventparticipant_requirements_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 4.2.13 on 2025-02-11 00:23 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "AKModel", + "0066_akpreference_slot_alter_akpreference_unique_together_and_more", + ), + ] + + operations = [ + migrations.AddField( + model_name="eventparticipant", + name="requirements", + field=models.ManyToManyField( + blank=True, + help_text="Participant's Requirements", + to="AKModel.akrequirement", + verbose_name="Requirements", + ), + ), + migrations.AlterField( + model_name="akpreference", + name="slot", + field=models.ForeignKey( + help_text="AK Slot this preference belongs to", + on_delete=django.db.models.deletion.CASCADE, + to="AKModel.akslot", + verbose_name="AK Slot", + ), + ), + ] diff --git a/AKModel/models.py b/AKModel/models.py index 86e0e925351409d0292bc75cf677f8ffd084beff..89b40671997c7fe906c19409033e3c1b8a0e6ae6 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -1629,6 +1629,9 @@ class EventParticipant(models.Model): event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'), help_text=_('Associated event')) + requirements = models.ManyToManyField(to=AKRequirement, blank=True, verbose_name=_('Requirements'), + help_text=_("Participant's Requirements")) + def __str__(self) -> str: string = _("Anonymous {pk}").format(pk=self.pk) if not self.name else self.name if self.institution: @@ -1659,7 +1662,7 @@ class EventParticipant(models.Model): data = { "id": self.pk, "info": {"name": str(self)}, - "room_constraints": [], + "room_constraints": [constraint.name for constraint in self.requirements.all()], "time_constraints": [], } data["preferences"] = [ @@ -1680,7 +1683,6 @@ class EventParticipant(models.Model): # partipant is actually required for AKs data["time_constraints"].append(f"availability-participant-{self.pk}") - # TODO: Add room constraints? return data @@ -1699,7 +1701,7 @@ class AKPreference(models.Model): help_text=_('Participant this preference belongs to')) slot = models.ForeignKey(to=AKSlot, on_delete=models.CASCADE, verbose_name=_('AK Slot'), - help_text=_('AKSlot this preference belongs to')) + help_text=_('AK Slot this preference belongs to')) class PreferenceLevel(models.IntegerChoices): """ diff --git a/AKModel/tests/test_json_export.py b/AKModel/tests/test_json_export.py index ea01bc164e9c6a6b94c603201748f9f766fe6285..8932df6a23e9ec25a447db8ba9d96865f01d190b 100644 --- a/AKModel/tests/test_json_export.py +++ b/AKModel/tests/test_json_export.py @@ -805,7 +805,12 @@ class JSONExportTest(TestCase): export_participant = self.export_objects["participants"][ participant.pk ] - self.assertEqual(export_participant["room_constraints"], []) + room_constraints = [ + constr.name for constr in participant.requirements.all() + ] + self.assertCountEqual( + export_participant["room_constraints"], room_constraints + ) for idx, owner in enumerate(self.owners, self.max_participant_pk + 1): if not self._owner_has_ak(owner):