forked from DGNum/gestioCOF
Ajout d'un modèle et nettoyage
- Ajout du modèle `Tirage` avec - Un titre / intitulé - Une date de début. - Une date de fin. - La graine, qui peut être nulle au moment ou on crée le tirage. - Formatage du code sur 80 colonnes. - Suppression des espaces autour des signes `=` dans les arguments nommés conformément à [PEP8](https://www.python.org/dev/peps/pep-0008/)
This commit is contained in:
parent
ac641a5d95
commit
77f678c791
1 changed files with 37 additions and 18 deletions
|
@ -7,6 +7,18 @@ from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
|
|
||||||
|
class Tirage(models.Model):
|
||||||
|
title = models.CharField("Titre", max_length=300)
|
||||||
|
ouverture = models.DateTimeField("Date et heure d'ouverture du tirage")
|
||||||
|
fermeture = models.DateTimeField("Date et heure de fermerture du tirage")
|
||||||
|
token = models.TextField("Graine du tirage", blank=True)
|
||||||
|
|
||||||
|
def date_no_seconds(self):
|
||||||
|
return self.fermeture.strftime('%d %b %Y %H:%M')
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return u"Tirage au sort du BdA du %s" % (self.date_no_seconds())
|
||||||
|
|
||||||
class Salle (models.Model):
|
class Salle (models.Model):
|
||||||
name = models.CharField ("Nom", max_length = 300)
|
name = models.CharField ("Nom", max_length = 300)
|
||||||
address = models.TextField ("Adresse")
|
address = models.TextField ("Adresse")
|
||||||
|
@ -15,15 +27,15 @@ class Salle (models.Model):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Spectacle (models.Model):
|
class Spectacle (models.Model):
|
||||||
title = models.CharField ("Titre", max_length = 300)
|
title = models.CharField ("Titre", max_length=300)
|
||||||
date = models.DateTimeField ("Date & heure")
|
date = models.DateTimeField ("Date & heure")
|
||||||
location = models.ForeignKey(Salle)
|
location = models.ForeignKey(Salle)
|
||||||
description = models.TextField ("Description", blank = True)
|
description = models.TextField ("Description", blank=True)
|
||||||
slots_description = models.TextField ("Description des places", blank = True)
|
slots_description = models.TextField ("Description des places", blank=True)
|
||||||
price = models.FloatField("Prix d'une place", blank = True)
|
price = models.FloatField("Prix d'une place", blank=True)
|
||||||
slots = models.IntegerField ("Places")
|
slots = models.IntegerField ("Places")
|
||||||
priority = models.IntegerField ("Priorité", default = 1000)
|
priority = models.IntegerField ("Priorité", default=1000)
|
||||||
tirage = models.IntegerField ("Tirage")
|
tirage = models.ForeignKey (Tirage)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Spectacle"
|
verbose_name = "Spectacle"
|
||||||
|
@ -39,7 +51,8 @@ class Spectacle (models.Model):
|
||||||
return self.date.strftime('%d %b %Y %H:%M')
|
return self.date.strftime('%d %b %Y %H:%M')
|
||||||
|
|
||||||
def __unicode__ (self):
|
def __unicode__ (self):
|
||||||
return u"%s - %s, %s, %.02f€" % (self.title, self.date_no_seconds(), self.location, self.price)
|
return u"%s - %s, %s, %.02f€" % (self.title, self.date_no_seconds(),
|
||||||
|
self.location, self.price)
|
||||||
|
|
||||||
PAYMENT_TYPES = (
|
PAYMENT_TYPES = (
|
||||||
("cash",u"Cash"),
|
("cash",u"Cash"),
|
||||||
|
@ -49,11 +62,17 @@ PAYMENT_TYPES = (
|
||||||
)
|
)
|
||||||
|
|
||||||
class Participant (models.Model):
|
class Participant (models.Model):
|
||||||
user = models.OneToOneField(User)
|
user = models.ForeignKey(User)
|
||||||
choices = models.ManyToManyField(Spectacle, through = "ChoixSpectacle", related_name = "chosen_by")
|
choices = models.ManyToManyField(Spectacle,
|
||||||
attributions = models.ManyToManyField(Spectacle, through = "Attribution", related_name = "attributed_to")
|
through="ChoixSpectacle",
|
||||||
paid = models.BooleanField (u"A payé", default = False)
|
related_name="chosen_by")
|
||||||
paymenttype = models.CharField(u"Moyen de paiement", max_length = 6, choices = PAYMENT_TYPES, blank = True)
|
attributions = models.ManyToManyField(Spectacle,
|
||||||
|
through="Attribution",
|
||||||
|
related_name="attributed_to")
|
||||||
|
paid = models.BooleanField (u"A payé", default=False)
|
||||||
|
paymenttype = models.CharField(u"Moyen de paiement",
|
||||||
|
max_length=6, choices=PAYMENT_TYPES, blank=True)
|
||||||
|
tirage = models.ForeignKey(Tirage)
|
||||||
|
|
||||||
def __unicode__ (self):
|
def __unicode__ (self):
|
||||||
return u"%s" % (self.user)
|
return u"%s" % (self.user)
|
||||||
|
@ -66,10 +85,10 @@ DOUBLE_CHOICES = (
|
||||||
|
|
||||||
class ChoixSpectacle (models.Model):
|
class ChoixSpectacle (models.Model):
|
||||||
participant = models.ForeignKey(Participant)
|
participant = models.ForeignKey(Participant)
|
||||||
spectacle = models.ForeignKey(Spectacle, related_name = "participants")
|
spectacle = models.ForeignKey(Spectacle, related_name="participants")
|
||||||
priority = models.PositiveIntegerField("Priorité")
|
priority = models.PositiveIntegerField("Priorité")
|
||||||
double_choice = models.CharField("Nombre de places", default = "1", choices = DOUBLE_CHOICES, max_length = 10)
|
double_choice = models.CharField("Nombre de places",
|
||||||
tirage = models.IntegerField("Tirage")
|
default="1", choices=DOUBLE_CHOICES, max_length=10)
|
||||||
|
|
||||||
def get_double(self):
|
def get_double(self):
|
||||||
return self.double_choice != "1"
|
return self.double_choice != "1"
|
||||||
|
@ -87,9 +106,9 @@ class ChoixSpectacle (models.Model):
|
||||||
|
|
||||||
class Attribution (models.Model):
|
class Attribution (models.Model):
|
||||||
participant = models.ForeignKey(Participant)
|
participant = models.ForeignKey(Participant)
|
||||||
spectacle = models.ForeignKey(Spectacle, related_name = "attribues")
|
spectacle = models.ForeignKey(Spectacle, related_name="attribues")
|
||||||
given = models.BooleanField(u"Donnée", default = False)
|
given = models.BooleanField(u"Donnée", default=False)
|
||||||
tirage = models.IntegerField("Tirage")
|
|
||||||
|
|
||||||
def __unicode__ (self):
|
def __unicode__ (self):
|
||||||
return u"%s -- %s" % (self.participant, self.spectacle)
|
return u"%s -- %s" % (self.participant, self.spectacle)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue