From acac1a6234f7cc28d1bce27741d37ef598674ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Thu, 5 Nov 2020 01:29:21 +0100 Subject: [PATCH] Introduce possibility to mark an AK Slot as fixed This prevents it from being edited in scheduling view --- AKModel/migrations/0042_akslot_fixed.py | 18 ++++++++++++++++++ AKModel/models.py | 2 ++ AKScheduling/api.py | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 AKModel/migrations/0042_akslot_fixed.py diff --git a/AKModel/migrations/0042_akslot_fixed.py b/AKModel/migrations/0042_akslot_fixed.py new file mode 100644 index 00000000..c33ee8f3 --- /dev/null +++ b/AKModel/migrations/0042_akslot_fixed.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.6 on 2020-11-04 23:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('AKModel', '0041_constraint_violation'), + ] + + operations = [ + migrations.AddField( + model_name='akslot', + name='fixed', + field=models.BooleanField(default=False, help_text='Length and time of this AK should not be changed', verbose_name='Scheduling Fixed'), + ), + ] diff --git a/AKModel/models.py b/AKModel/models.py index d247fbb7..a02e9920 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -316,6 +316,8 @@ class AKSlot(models.Model): duration = models.DecimalField(max_digits=4, decimal_places=2, default=2, verbose_name=_('Duration'), help_text=_('Length in hours')) + fixed = models.BooleanField(default=False, verbose_name=_('Scheduling Fixed'), help_text=_('Length and time of this AK should not be changed')) + event = models.ForeignKey(to=Event, on_delete=models.CASCADE, verbose_name=_('Event'), help_text=_('Associated event')) diff --git a/AKScheduling/api.py b/AKScheduling/api.py index 3601b551..687704a8 100644 --- a/AKScheduling/api.py +++ b/AKScheduling/api.py @@ -48,10 +48,10 @@ class EventsView(LoginRequiredMixin, EventSlugMixin, ListView): "start": timezone.localtime(slot.start, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"), "end": timezone.localtime(slot.end, self.event.timezone).strftime("%Y-%m-%d %H:%M:%S"), "backgroundColor": slot.ak.category.color, - # TODO Mark conflicts here? - "borderColor": slot.ak.category.color, + "borderColor": "#ff291d" if slot.fixed else slot.ak.category.color, "constraint": 'roomAvailable', - 'url': str(reverse('submit:ak_detail', kwargs={"event_slug": self.event.slug, "pk": slot.ak.pk})), + "editable": not slot.fixed, + 'url': str(reverse('admin:AKModel_akslot_change', args=[slot.pk])), } for slot in context["object_list"]], safe=False, **response_kwargs -- GitLab