First mockup pages done
This commit is contained in:
55
eventplanner/models.py
Normal file
55
eventplanner/models.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext as _
|
||||
from locpick.field import LocationField
|
||||
|
||||
from musicians.models import Musician
|
||||
|
||||
|
||||
class Event ( models.Model ):
|
||||
|
||||
EVENT_TYPES = (
|
||||
( 'Reh', _('Rehearsal') ),
|
||||
( 'Conc', _('Concert') ),
|
||||
( 'GenReh', _('General Rehearsal') ),
|
||||
)
|
||||
|
||||
title = models.CharField( max_length=40 )
|
||||
type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh' )
|
||||
date = models.DateField()
|
||||
time = models.TimeField( null=True, blank=True )
|
||||
participants = models.ManyToManyField( Musician, through='EventParticipation' )
|
||||
|
||||
desc = models.TextField( blank=True)
|
||||
location = LocationField()
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title + " ( " + self.get_type_display() + " ) "
|
||||
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# Call the "real" save() method
|
||||
super(Event, self).save(*args, **kwargs)
|
||||
|
||||
# Create a "Don't Know" participation for each Musician
|
||||
for m in Musician.objects.all():
|
||||
if not m in self.participants.all():
|
||||
EventParticipation.objects.create( event=self, musician = m, status='?', comment = '' )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class EventParticipation( models.Model ):
|
||||
OPTIONS = ( ('?' , _('?' )),
|
||||
('Yes', _('Yes')),
|
||||
('No' , _('No' ))
|
||||
)
|
||||
|
||||
event = models.ForeignKey( Event )
|
||||
musician = models.ForeignKey( Musician )
|
||||
status = models.CharField ( max_length=3, choices = OPTIONS, default='?' )
|
||||
comment = models.CharField ( max_length=64, blank=True )
|
||||
|
||||
class Meta:
|
||||
unique_together = ("event", "musician")
|
||||
Reference in New Issue
Block a user