Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Add seating ordering and auto-adding of more seats (#370)
Browse files Browse the repository at this point in the history
* Add seating ordering

* Make seating automatically add more seats
  • Loading branch information
HON95 authored Aug 4, 2022
1 parent 3f45215 commit f401595
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 25 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions apps/seating/migrations/0014_seating_priority.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
20 changes: 20 additions & 0 deletions apps/seating/migrations/0015_auto_20220804_1620.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
22 changes: 10 additions & 12 deletions apps/seating/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion apps/seating/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 6 additions & 12 deletions locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -837,15 +837,18 @@ 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"

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"

Expand Down Expand Up @@ -1675,9 +1678,6 @@ msgstr "Sluttid"
msgid "Location"
msgstr "Sted"

msgid "View tickets"
msgstr "Vis billetter"

msgid "LAN List"
msgstr "LAN-liste"

Expand Down Expand Up @@ -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 <a href=\"%(update_profile_url)s\">profile settings</a>."
#~ msgstr "Ved å kjøpe en billett bekrefter du at all informasjonen om deg er korrekt. Hvis ikke, oppdater det nå i <a href=\"%(update_profile_url)s\">profilinnstillingene</a> dine."

0 comments on commit f401595

Please sign in to comment.