Eventplanner
- cleaned up urls - permissions
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext as _
|
||||
from locpick.field import LocationField
|
||||
|
||||
from musicians.models import Musician
|
||||
|
||||
@@ -10,19 +9,21 @@ class Event ( models.Model ):
|
||||
EVENT_TYPES = (
|
||||
( 'Reh', _('Rehearsal') ),
|
||||
( 'Conc', _('Concert') ),
|
||||
( 'GenReh', _('General Rehearsal') ),
|
||||
( 'GenReh', _('General Rehearsal') ),
|
||||
( 'Party', _('Party') ),
|
||||
)
|
||||
|
||||
title = models.CharField( max_length=40, verbose_name = _("title") )
|
||||
type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh', verbose_name= _("type") )
|
||||
type = models.CharField( max_length=6, choices=EVENT_TYPES, default='Reh', verbose_name= _("type") )
|
||||
location = models.TextField( blank=False, verbose_name=_("location") )
|
||||
desc = models.TextField( blank=True, verbose_name=_("description"))
|
||||
|
||||
date = models.DateField( verbose_name= _("date") )
|
||||
time = models.TimeField( null=True, blank=True, verbose_name = _("time") )
|
||||
meeting_time = models.TimeField( null=True, blank=True, verbose_name = _("meeting_time") )
|
||||
|
||||
participants = models.ManyToManyField( Musician, through='EventParticipation', verbose_name=_("participants") )
|
||||
|
||||
desc = models.TextField( blank=True, verbose_name=_("description"))
|
||||
location = LocationField( verbose_name=_("location") )
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title + " ( " + self.get_type_display() + " ) "
|
||||
|
||||
@@ -51,10 +52,25 @@ class EventParticipation( models.Model ):
|
||||
status = models.CharField ( max_length=3, choices = OPTIONS, default='?', verbose_name=_("status") )
|
||||
comment = models.CharField ( max_length=64, blank=True, verbose_name=_("comment") )
|
||||
|
||||
|
||||
def get_musician_username(self):
|
||||
return self.musician.user.username
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_or_create( musician , event ):
|
||||
try:
|
||||
result = EventParticipation.objects.get( event = event, musician = musician )
|
||||
except EventParticipation.DoesNotExist:
|
||||
result = EventParticipation.objects.create( event = event, musician = musician, status='?', comment = '' )
|
||||
|
||||
return result
|
||||
|
||||
class Meta:
|
||||
unique_together = ("event", "musician")
|
||||
permissions = (
|
||||
("change_others_participation", _("Can modify participation status of other users") ),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user