Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lukesneeringer/personal
base: 52fa6d9ce7
...
head fork: lukesneeringer/personal
compare: 91b2ff74ef
  • 3 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
1  settings/defaults.py
@@ -142,6 +142,7 @@
# wedding app
'wedding.accounts',
'wedding.reservations',
+ 'wedding.seating',
'wedding.static',
)
View
7 wedding/reservations/managers.py
@@ -2,4 +2,9 @@
class InvitationManager(models.Manager):
def get_query_set(self):
- return super(InvitationManager, self).get_query_set().distinct().prefetch_related('invitee_set')
+ return super(InvitationManager, self).get_query_set().distinct().prefetch_related('invitee_set')
+
+
+class RSVPManager(models.Manager):
+ def get_query_set(self):
+ return super(RSVPManager, self).get_query_set().select_related('invitee')
View
4 wedding/reservations/models.py
@@ -172,6 +172,8 @@ class RSVP(models.Model):
"""A response from an individual on whether they will attend,
and their food order."""
+ objects = managers.RSVPManager()
+
invitee = models.OneToOneField(Invitee, related_name='rsvp')
accepts = models.BooleanField(default=True, verbose_name='attending', choices=(
(True, 'Accepts'),
@@ -198,7 +200,7 @@ class Meta:
verbose_name = 'RSVP'
def __unicode__(self):
- return u'RSVP: %s' % self.invitee
+ return unicode(self.invitee)
class Gift(models.Model):
View
0  wedding/seating/__init__.py
No changes.
View
13 wedding/seating/admin.py
@@ -0,0 +1,13 @@
+from django.contrib import admin
+from tools.decorators import admin_register
+from wedding.seating.models import *
+
+
+class SeatInline(admin.TabularInline):
+ model = Seat
+
+
+@admin_register(Table)
+class TableAdmin(admin.ModelAdmin):
+ inlines = (SeatInline,)
+ list_display = ('label', '__len__', 'description')
View
15 wedding/seating/forms.py
@@ -0,0 +1,15 @@
+from django import forms
+from wedding.seating.models import Seat
+
+
+class SeatForm(forms.ModelForm):
+ """Form to add validation for seats."""
+
+ def clean_person(self):
+ # sanity check: make sure this person is actually
+ # attending the wedding
+ person = self.cleaned_data['person']
+ if not person.accepts:
+ raise forms.ValidationError, 'This person is not attending the wedding, and therefore cannot have a seat.'
+
+ return self.cleaned_data
View
6 wedding/seating/managers.py
@@ -0,0 +1,6 @@
+from django.db import models
+
+
+class TableManager(models.Manager):
+ def get_query_set(self):
+ return super(TableManager, self).get_query_set().prefetch_related('seat_set')
View
45 wedding/seating/models.py
@@ -0,0 +1,45 @@
+from django.db import models
+from wedding.reservations.models import RSVP
+from wedding.seating import managers
+
+
+class Table(models.Model):
+ """A model representing a table within a scheme."""
+
+ objects = managers.TableManager()
+
+ label = models.CharField(max_length=10, help_text='A short label, used at the venue, to identify a table. Example: "A1", "B4"')
+ description = models.CharField(max_length=255, help_text='A human-readable description of who is being placed at this table. Example: "RotD", "Meagan\'s Family - Maternal"')
+ created = models.DateTimeField(auto_now_add=True)
+ modified = models.DateTimeField(auto_now=True)
+
+ class Meta:
+ ordering = ('label',)
+
+ def __unicode__(self):
+ return '%s (%s)' % (self.label, self.description)
+
+ def __nonzero__(self):
+ return True
+
+ def __len__(self):
+ return len(self.seat_set.all())
+
+
+class Seat(models.Model):
+ """A model representing a seat at a table, occupied by
+ an invitee who is coming to the wedding."""
+
+ person = models.OneToOneField(RSVP, limit_choices_to={
+ 'accepts': True,
+ })
+ table = models.ForeignKey(Table)
+ position = models.PositiveIntegerField(help_text='A position at a table, zero-indexed. Tables are assumed to be circular; seat 0 is adjacent to seat N - 1 (where N is the table\'s capacity).')
+ created = models.DateTimeField(auto_now_add=True)
+ modified = models.DateTimeField(auto_now=True)
+
+ class Meta:
+ ordering = ('table', 'position')
+
+ def __unicode__(self):
+ return '%s(%d): %s' % (self.table.label, self.position, self.person)

No commit comments for this range

Something went wrong with that request. Please try again.