Merge branch 'master' into Kerl/fix_32_do_tirage

This commit is contained in:
Martin Pépin 2016-07-16 18:31:36 +02:00
commit 6d613def4c
30 changed files with 368 additions and 163 deletions

View file

@ -1,4 +1,8 @@
# coding: utf-8
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import calendar
@ -8,6 +12,7 @@ from django.template import loader, Context
from django.core import mail
from django.conf import settings
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
def render_template(template_name, data):
@ -16,6 +21,7 @@ def render_template(template_name, data):
return tmpl.render(ctxt)
@python_2_unicode_compatible
class Tirage(models.Model):
title = models.CharField("Titre", max_length=300)
ouverture = models.DateTimeField("Date et heure d'ouverture du tirage")
@ -28,18 +34,20 @@ class Tirage(models.Model):
def date_no_seconds(self):
return self.fermeture.strftime('%d %b %Y %H:%M')
def __unicode__(self):
return u"%s - %s" % (self.title, self.date_no_seconds())
def __str__(self):
return "%s - %s" % (self.title, self.date_no_seconds())
@python_2_unicode_compatible
class Salle(models.Model):
name = models.CharField("Nom", max_length=300)
address = models.TextField("Adresse")
def __unicode__(self):
def __str__(self):
return self.name
@python_2_unicode_compatible
class Spectacle(models.Model):
title = models.CharField("Titre", max_length=300)
date = models.DateTimeField("Date & heure")
@ -59,7 +67,7 @@ class Spectacle(models.Model):
ordering = ("priority", "date", "title",)
def __repr__(self):
return u"[%s]" % self.__unicode__()
return "[%s]" % self
def timestamp(self):
return "%d" % calendar.timegm(self.date.utctimetuple())
@ -67,9 +75,9 @@ class Spectacle(models.Model):
def date_no_seconds(self):
return self.date.strftime('%d %b %Y %H:%M')
def __unicode__(self):
return u"%s - %s, %s, %.02f" % (self.title, self.date_no_seconds(),
self.location, self.price)
def __str__(self):
return "%s - %s, %s, %.02f" % (self.title, self.date_no_seconds(),
self.location, self.price)
def send_rappel(self):
# On récupère la liste des participants
@ -104,13 +112,14 @@ class Spectacle(models.Model):
return members.values()
PAYMENT_TYPES = (
("cash", u"Cash"),
("cash", "Cash"),
("cb", "CB"),
("cheque", u"Chèque"),
("autre", u"Autre"),
("cheque", "Chèque"),
("autre", "Autre"),
)
@python_2_unicode_compatible
class Participant(models.Model):
user = models.ForeignKey(User)
choices = models.ManyToManyField(Spectacle,
@ -119,14 +128,14 @@ class Participant(models.Model):
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",
paid = models.BooleanField("A payé", default=False)
paymenttype = models.CharField("Moyen de paiement",
max_length=6, choices=PAYMENT_TYPES,
blank=True)
tirage = models.ForeignKey(Tirage)
def __unicode__(self):
return u"%s" % (self.user)
def __str__(self):
return "%s - %s" % (self.user, self.tirage.title)
DOUBLE_CHOICES = (
("1", "1 place"),
@ -135,6 +144,7 @@ DOUBLE_CHOICES = (
)
@python_2_unicode_compatible
class ChoixSpectacle(models.Model):
participant = models.ForeignKey(Participant)
spectacle = models.ForeignKey(Spectacle, related_name="participants")
@ -151,6 +161,11 @@ class ChoixSpectacle(models.Model):
return self.double_choice == "autoquit"
autoquit = property(get_autoquit)
def __str__(self):
return "Vœux de %s pour %s" % (
self.participant.user.get_full_name,
self.spectacle.title)
class Meta:
ordering = ("priority",)
unique_together = (("participant", "spectacle",),)
@ -158,10 +173,11 @@ class ChoixSpectacle(models.Model):
verbose_name_plural = "voeux"
@python_2_unicode_compatible
class Attribution(models.Model):
participant = models.ForeignKey(Participant)
spectacle = models.ForeignKey(Spectacle, related_name="attribues")
given = models.BooleanField(u"Donnée", default=False)
given = models.BooleanField("Donnée", default=False)
def __unicode__(self):
return u"%s -- %s" % (self.participant, self.spectacle)
def __str__(self):
return "%s -- %s" % (self.participant, self.spectacle)