# coding: utf-8
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import post_save
class Spectacle (models.Model):
title = models.CharField ("Titre", max_length = 300)
date = models.DateTimeField ("Date & heure")
location = models.CharField ("Lieu", max_length = 300,
blank = True, null = True)
description = models.TextField ("Description", blank = True)
slots_description = models.TextField ("Description des places", blank = True)
slots = models.IntegerField ("Places")
priority = models.IntegerField ("Priorité", default = 1000)
class Meta:
verbose_name = "Spectacle"
ordering = ("priority", "date","title",)
def __repr__ (self):
return u"[%s]" % self.__unicode__()
def __unicode__ (self):
return u"%s - %s @ %s" % (self.title, self.date, self.location)
class Participant (models.Model):
user = models.ForeignKey(User, unique = True)
choices = models.ManyToManyField(Spectacle, through = "ChoixSpectacle")
def __unicode__ (self):
return u"%s" % (self.user)
class ChoixSpectacle (models.Model):
participant = models.ForeignKey(Participant)
spectacle = models.ForeignKey(Spectacle, related_name = "participants")
priority = models.PositiveIntegerField("Priorité")
double = models.BooleanField("Deux places1")
autoquit = models.BooleanField("Abandon2")
class Meta:
ordering = ("priority",)
#unique_together = (("participant", "spectacle",),)
verbose_name = "voeu"