creates initial models
This commit is contained in:
parent
3e634e70c1
commit
f44b3fc33c
2 changed files with 43 additions and 1 deletions
|
@ -5,6 +5,7 @@ from __future__ import print_function
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import calendar
|
||||
import datetime
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
@ -179,3 +180,25 @@ class Attribution(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return "%s -- %s" % (self.participant, self.spectacle)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SpectacleRevente(models.Model):
|
||||
attribution = models.OneToOneField(Attribution)
|
||||
date = models.DateTimeField("Date de mise en vente",
|
||||
default=timezone.now)
|
||||
sold = models.BooleanField("Vendue", default=False)
|
||||
|
||||
def get_expiration_time(self):
|
||||
remaining_time = (self.attribution.spectacle.date - self.date)
|
||||
delay = max(datetime.timedelta(hours=2),
|
||||
min(remaining_time/2, datetime.timedelta(days=2)))
|
||||
return self.date + delay
|
||||
expiration_time = property(get_expiration_time)
|
||||
|
||||
def get_shotgun(self):
|
||||
return timezone.now > self.expiration_time
|
||||
shotgun = property(get_shotgun)
|
||||
|
||||
def __str__(self):
|
||||
return "%s" % self.attribution
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue