diff --git a/CHANGELOG.md b/CHANGELOG.md index 25848c84..7324050d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security +## [v1.10.1] - 2022-08-04 + +### Added + +- Added seating priority, to avoid unpredictable ordering of seating tabs. + +### Changed + +- Made seatings automatically add more seats if the layout is changed to one with more seats. + + ## [v1.10.0] - 2022-08-03 ### Added diff --git a/apps/seating/migrations/0014_seating_priority.py b/apps/seating/migrations/0014_seating_priority.py new file mode 100644 index 00000000..1a06bd7b --- /dev/null +++ b/apps/seating/migrations/0014_seating_priority.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2022-08-04 15:58 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seating', '0013_auto_20200909_0513'), + ] + + operations = [ + migrations.AddField( + model_name='seating', + name='priority', + field=models.IntegerField(default=0, help_text='For ordering of seatings, higher number will show first.', verbose_name='priority'), + ), + ] diff --git a/apps/seating/migrations/0015_auto_20220804_1620.py b/apps/seating/migrations/0015_auto_20220804_1620.py new file mode 100644 index 00000000..11ca9b1f --- /dev/null +++ b/apps/seating/migrations/0015_auto_20220804_1620.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2022-08-04 16:20 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seating', '0014_seating_priority'), + ] + + operations = [ + migrations.AlterField( + model_name='seating', + name='number_of_seats', + field=models.IntegerField(default=0, editable=False, help_text='This field is automatically updated to match the chosen layout. Change the chosen layout to alter this field.', verbose_name='number of seats'), + ), + ] diff --git a/apps/seating/models.py b/apps/seating/models.py index 2d70b8c0..e156366a 100644 --- a/apps/seating/models.py +++ b/apps/seating/models.py @@ -39,20 +39,17 @@ class Seating(models.Model): lan = models.ForeignKey(LAN, verbose_name=_(u'LAN')) title = models.CharField(_(u'title'), max_length=50) desc = models.CharField(_(u'description'), max_length=250) - number_of_seats = models.IntegerField(_(u'number of seats'), default=0, help_text=_(u'This field is automatically updated ' - 'to match the chosen layout. Change the chosen layout to alter this field.')) + priority = models.IntegerField(_(u'priority'), default=0, help_text=_(u'For ordering of seatings, higher number will show first.')) closing_date = models.DateTimeField(_(u'closing date')) layout = models.ForeignKey(Layout, verbose_name=_(u'layout')) ticket_types = models.ManyToManyField(TicketType, verbose_name=_(u'ticket types'), blank=True, related_name='ticket_types') + number_of_seats = models.IntegerField(_(u'number of seats'), default=0, editable=False, help_text=_(u'This field is automatically updated ' + 'to match the chosen layout. Change the chosen layout to alter this field.')) def save(self, *args, **kwargs): - if not self.pk: - self.number_of_seats = self.layout.number_of_seats - super(Seating, self).save(*args, **kwargs) - self.populate_seats() - else: - self.number_of_seats = self.layout.number_of_seats - super(Seating, self).save(*args, **kwargs) + self.number_of_seats = self.layout.number_of_seats + super(Seating, self).save(*args, **kwargs) + self.populate_seats() def get_user_registered(self): return map(lambda x: getattr(x, 'user'), Seat.objects.filter(~Q(user=None), Q(seating=self))) @@ -76,9 +73,10 @@ def get_absolute_url(self): return reverse('seating_details', kwargs={'lan_id': self.lan.id, 'seating_id': self.id}) def populate_seats(self): - for k in range(0, self.number_of_seats): - seat = Seat(seating=self, placement=k + 1) - seat.save() + for k in range(1, self.number_of_seats + 1): + if not Seat.objects.filter(seating=self, placement=k).exists(): + seat = Seat(seating=self, placement=k) + seat.save() class Meta: verbose_name = _(u'seating') diff --git a/apps/seating/views.py b/apps/seating/views.py index 402d145d..73658bcb 100644 --- a/apps/seating/views.py +++ b/apps/seating/views.py @@ -63,7 +63,7 @@ def main_filtered(request, lan_id): @require_safe def seating_details(request, lan_id, seating_id=None, seat_id=None): lan = get_object_or_404(LAN, pk=lan_id) - seatings = Seating.objects.filter(lan=lan) + seatings = Seating.objects.filter(lan=lan).order_by('-priority') if not seating_id: if seatings: diff --git a/locale/nb/LC_MESSAGES/django.po b/locale/nb/LC_MESSAGES/django.po index f192f4e4..6271f217 100644 --- a/locale/nb/LC_MESSAGES/django.po +++ b/locale/nb/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-08-03 15:18+0200\n" +"POT-Creation-Date: 2022-08-04 15:58+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -837,8 +837,8 @@ msgstr "setekartmal" msgid "seating layouts" msgstr "setekartmaler" -msgid "This field is automatically updated to match the chosen layout. Change the chosen layout to alter this field." -msgstr "Dette feltet oppdateres automatisk for å matche malen. Endre malen for å oppdatere dette feltet." +msgid "For ordering of seatings, higher number will show first." +msgstr "For rekkefølge av setekart, høyere nummer vises først." msgid "closing date" msgstr "stengningsdato" @@ -846,6 +846,9 @@ msgstr "stengningsdato" msgid "layout" msgstr "mal" +msgid "This field is automatically updated to match the chosen layout. Change the chosen layout to alter this field." +msgstr "Dette feltet oppdateres automatisk for å matche malen. Endre malen for å oppdatere dette feltet." + msgid "seating" msgstr "setekart" @@ -1675,9 +1678,6 @@ msgstr "Sluttid" msgid "Location" msgstr "Sted" -msgid "View tickets" -msgstr "Vis billetter" - msgid "LAN List" msgstr "LAN-liste" @@ -2303,9 +2303,3 @@ msgstr "Adminpanel" msgid "Log out" msgstr "Logg ut" - -#~ msgid "Ticket confirmation" -#~ msgstr "Billettbekreftelse" - -#~ msgid "By purchasing a ticket, you are confirming that all of the information about you is correct. If not, update it now in your profile settings." -#~ msgstr "Ved å kjøpe en billett bekrefter du at all informasjonen om deg er korrekt. Hvis ikke, oppdater det nå i profilinnstillingene dine."