from django_xworkflows import models as xwf_models
-import xnet.accounts.models as accounts_models
+from xnet.accounts import models as accounts_models
+from xnet.groups import models as groups_models
class Event(models.Model):
NOTIFICATION_RECIPIENT_CREATOR = 'creator'
NOTIFICATION_RECIPIENT_NONE = 'none'
NOTIFICATION_RECIPIENT_CHOICES = (
- (NOTIFICATION_RECIPIENT_CREATOR, _(u"créateur")),
- (NOTIFICATION_RECIPIENT_ANIM, _(u"animateurs")),
- (NOTIFICATION_RECIPIENT_BOTH, _(u"les deux")),
- (NOTIFICATION_RECIPIENT_NONE, _(u"personne")),
+ (NOTIFICATION_RECIPIENT_CREATOR, _(u"Le créateur de l'événement")),
+ (NOTIFICATION_RECIPIENT_ANIM, _(u"Les animateurs du groupe")),
+ (NOTIFICATION_RECIPIENT_BOTH, _(u"Le créateur et les animateurs")),
+ (NOTIFICATION_RECIPIENT_NONE, _(u"Personne")),
)
- short = models.SlugField(max_length=40, verbose_name=_(u"nom raccourci"))
- main_description = models.OneToOneField('events.EventDescription', null=True, blank=True,
+ short = models.SlugField(max_length=40, unique=True, verbose_name=_(u"nom raccourci"),
+ help_text=_(u"Texte court utilisé dans les URLs."))
+ main_description = models.OneToOneField('events.EventPart', null=True, blank=True,
verbose_name=_(u"description principale"), related_name='+')
- group = models.ForeignKey(accounts_models.XGroup, verbose_name=_(u"groupe"), related_name='events')
+ group = models.ForeignKey(groups_models.XGroup, verbose_name=_(u"groupe"), related_name='events')
creator = models.ForeignKey(accounts_models.Account, verbose_name=_(u"créateur"), related_name='created_events')
- simple = models.BooleanField(verbose_name=_(u"simple"))
+ simple = models.BooleanField(verbose_name=_(u"simple"),
+ help_text=_(u"Un événement simple a un seul composant. Permet une mise en page plus légère."))
+ registration_begin = models.DateTimeField(blank=True, null=True,
+ verbose_name=_(u"date d'ouverture des inscriptions"))
registration_end = models.DateTimeField(null=True, blank=True,
verbose_name=_(u"date limite d'inscription"))
notification_recipient = models.CharField(max_length=10, choices=NOTIFICATION_RECIPIENT_CHOICES,
show_registered = models.BooleanField(verbose_name=_(u"montrer les inscriptions aux membres"))
allow_non_members = models.BooleanField(verbose_name=_(u"autoriser les non-membres"))
allow_guests = models.BooleanField(verbose_name=_(u"autoriser les invités"))
- registration_limit = models.IntegerField(verbose_name=_(u"limites du nombre d'inscrits"))
+ registration_limit = models.PositiveIntegerField(verbose_name=_(u"limites du nombre d'inscrits"))
start_date = models.DateTimeField(null=True, blank=True, verbose_name=_(u"date de début"))
end_date = models.DateTimeField(null=True, blank=True, verbose_name=_(u"date de fin"))
verbose_name_plural = _(u"événements")
-class EventDescription(models.Model):
+class EventPart(models.Model):
+ """A component of an event."""
+
name = models.CharField(max_length=100, verbose_name=_(u"nom"))
description = models.CharField(max_length=1000, verbose_name=_(u"description"))
event = models.ForeignKey(Event, verbose_name=_(u"événement parent"), related_name='descriptions')
registration_limit = models.IntegerField(verbose_name=_(u"limites du nombre d'inscrits"))
- main = models.BooleanField(verbose_name=_(u"principale"))
+ main = models.BooleanField(verbose_name=_(u"principale"),
+ help_text=_(u"S'il s'agit du composant principal de l'événement"))
def __unicode__(self):
return self.name
class Meta:
verbose_name = _(u"description d'événement")
verbose_name_plural = _(u"descriptions d'événements")
+ unique_together = ('event', 'name')
class PriceOption(models.Model):
name = models.CharField(max_length=100, verbose_name=_(u"nom"))
amount = models.IntegerField(verbose_name=_(u"montant (centimes)"))
- event_description = models.ForeignKey(EventDescription, verbose_name=_(u"description associée"),
+ event_part = models.ForeignKey(EventPart, verbose_name=_(u"description associée"),
related_name='price_options')
def __unicode__(self):
class Meta:
verbose_name = _(u"option de paiement")
verbose_name_plural = _(u"options de paiement")
+ unique_together = ('event_part', 'name')
class RegistrationWorkflow(xwf_models.Workflow):
class Registration(models.Model):
user = models.ForeignKey(accounts_models.Account, verbose_name=_(u"utilisateur enregistré"),
related_name='event_registrations')
- dn_event = models.ForeignKey(EventDescription, verbose_name=_(u"événement associé"),
- related_name='registrations')
+ dn_event = models.ForeignKey(Event, verbose_name=_(u"événement associé"),
+ related_name='registrations', editable=False)
option = models.ForeignKey(PriceOption, verbose_name=_(u"options associées"),
related_name='registrations')
date_registered = models.DateTimeField(verbose_name=_(u"date d'enregistrement"))
class Meta:
verbose_name = _(u"inscription")
verbose_name_plural = _(u"inscriptions")
+ unique_together = ('user', 'option')