2017-09-05 15:02:33 +02:00
|
|
|
|
from django.contrib.auth.models import Group, Permission, User
|
2017-02-09 21:04:32 +01:00
|
|
|
|
from django.db import models
|
2017-09-05 15:02:33 +02:00
|
|
|
|
from django.db.models.signals import post_delete, post_save
|
2017-02-10 20:10:45 +01:00
|
|
|
|
from django.dispatch import receiver
|
2017-08-07 18:56:56 +02:00
|
|
|
|
from django.urls import reverse
|
2017-02-10 20:10:45 +01:00
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2017-02-09 21:04:32 +01:00
|
|
|
|
|
2017-02-10 20:10:45 +01:00
|
|
|
|
from cof.petits_cours_models import choices_length
|
|
|
|
|
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
|
# User management
|
|
|
|
|
# ---
|
|
|
|
|
|
2017-02-20 01:12:06 +01:00
|
|
|
|
|
2017-02-10 20:10:45 +01:00
|
|
|
|
class Profile(models.Model):
|
2017-10-26 14:04:15 +02:00
|
|
|
|
STATUS_EXTE = "exterieur"
|
|
|
|
|
STATUS_1A = "1A"
|
|
|
|
|
STATUS_2A = "2A"
|
|
|
|
|
STATUS_3A = "3A"
|
|
|
|
|
STATUS_4A = "4A"
|
|
|
|
|
STATUS_ARCHI = "archicube"
|
|
|
|
|
STATUS_DOCTORANT = "doctorant"
|
|
|
|
|
STATUS_CST = "CST"
|
|
|
|
|
STATUS_PEI = "PEI"
|
|
|
|
|
|
|
|
|
|
OCCUPATION_CHOICES = (
|
|
|
|
|
(STATUS_EXTE, _("Extérieur")),
|
|
|
|
|
(STATUS_1A, _("1A")),
|
|
|
|
|
(STATUS_2A, _("2A")),
|
|
|
|
|
(STATUS_3A, _("3A")),
|
|
|
|
|
(STATUS_4A, _("4A")),
|
|
|
|
|
(STATUS_ARCHI, _("Archicube")),
|
|
|
|
|
(STATUS_DOCTORANT, _("Doctorant")),
|
|
|
|
|
(STATUS_CST, _("CST")),
|
|
|
|
|
(STATUS_PEI, _("PEI")),
|
|
|
|
|
)
|
|
|
|
|
|
2017-02-22 19:28:34 +01:00
|
|
|
|
user = models.OneToOneField(
|
|
|
|
|
User,
|
|
|
|
|
on_delete=models.CASCADE,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
related_name="profile",
|
|
|
|
|
verbose_name=_("utilisateur"),
|
2017-02-22 19:28:34 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
login_clipper = models.CharField(
|
|
|
|
|
_("login clipper"),
|
|
|
|
|
max_length=8,
|
|
|
|
|
blank=True,
|
2017-02-22 19:28:34 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
phone = models.CharField(_("téléphone"), max_length=20, blank=True)
|
|
|
|
|
occupation = models.CharField(_("occupation"),
|
2017-02-10 20:10:45 +01:00
|
|
|
|
default="1A",
|
|
|
|
|
choices=OCCUPATION_CHOICES,
|
|
|
|
|
max_length=choices_length(
|
|
|
|
|
OCCUPATION_CHOICES))
|
2017-06-24 14:42:33 +02:00
|
|
|
|
departement = models.CharField(_("département"), max_length=50,
|
2017-02-10 20:10:45 +01:00
|
|
|
|
blank=True)
|
|
|
|
|
comments = models.TextField(
|
2017-06-24 14:42:33 +02:00
|
|
|
|
_("commentaires visibles par l'utilisateur"), blank=True
|
|
|
|
|
)
|
2017-02-10 20:10:45 +01:00
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("profil")
|
|
|
|
|
verbose_name_plural = _("profils")
|
2017-02-10 20:10:45 +01:00
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.user.username
|
|
|
|
|
|
2017-02-20 01:12:06 +01:00
|
|
|
|
|
2017-02-10 20:10:45 +01:00
|
|
|
|
@receiver(post_save, sender=User)
|
|
|
|
|
def create_user_profile(sender, instance, created, **kwargs):
|
|
|
|
|
if created:
|
|
|
|
|
Profile.objects.get_or_create(user=instance)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(post_delete, sender=Profile)
|
|
|
|
|
def post_delete_user(sender, instance, *args, **kwargs):
|
|
|
|
|
instance.user.delete()
|
2017-02-20 01:12:06 +01:00
|
|
|
|
|
|
|
|
|
|
2017-08-11 15:56:41 +02:00
|
|
|
|
class AssociationManager(models.Manager):
|
|
|
|
|
def get_by_natural_key(self, name):
|
|
|
|
|
return self.get(name=name)
|
|
|
|
|
|
|
|
|
|
|
2017-06-24 23:35:25 +02:00
|
|
|
|
class Association(models.Model):
|
2017-08-11 15:56:41 +02:00
|
|
|
|
objects = AssociationManager()
|
|
|
|
|
|
2017-06-25 21:17:16 +02:00
|
|
|
|
name = models.CharField(
|
|
|
|
|
_("nom de l'association"),
|
2017-08-11 15:56:41 +02:00
|
|
|
|
unique=True,
|
2017-06-25 21:17:16 +02:00
|
|
|
|
max_length=30
|
|
|
|
|
)
|
2017-06-24 23:35:25 +02:00
|
|
|
|
staff_group = models.ForeignKey(
|
|
|
|
|
Group,
|
|
|
|
|
on_delete=models.PROTECT,
|
2017-08-06 20:56:11 +02:00
|
|
|
|
related_name="staff_group_of",
|
2017-06-24 23:35:25 +02:00
|
|
|
|
blank=True, null=True,
|
2017-08-06 20:56:11 +02:00
|
|
|
|
verbose_name=_("groupe des membres du bureau"),
|
2017-06-24 23:35:25 +02:00
|
|
|
|
)
|
|
|
|
|
members_group = models.ForeignKey(
|
|
|
|
|
Group,
|
|
|
|
|
on_delete=models.PROTECT,
|
2017-08-06 20:56:11 +02:00
|
|
|
|
related_name="member_group_of",
|
2017-06-24 23:35:25 +02:00
|
|
|
|
blank=True, null=True,
|
|
|
|
|
verbose_name=_("groupe des membres"),
|
|
|
|
|
)
|
|
|
|
|
|
2017-08-11 15:56:41 +02:00
|
|
|
|
def natural_key(self):
|
2017-08-11 16:42:33 +02:00
|
|
|
|
return [self.name]
|
2017-08-11 15:56:41 +02:00
|
|
|
|
|
2017-06-24 23:35:25 +02:00
|
|
|
|
class Meta:
|
|
|
|
|
verbose_name = _("association")
|
|
|
|
|
verbose_name_plural = _("associations")
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.name
|
|
|
|
|
|
2017-09-09 15:55:22 +02:00
|
|
|
|
def setup_perms(self, buro_of_apps=[], perms=[]):
|
2017-09-05 15:02:33 +02:00
|
|
|
|
"""
|
|
|
|
|
Setup permissions of the staff and members groups.
|
|
|
|
|
|
|
|
|
|
Permission '<assoc_label>.member' is added to the 'members_group' of
|
|
|
|
|
the association.
|
|
|
|
|
|
|
|
|
|
Permission '<assoc_label>.buro' is added to the 'staff_group' of the
|
|
|
|
|
association. All permissions of applications from 'buro_of_apps' are
|
|
|
|
|
also added to this group.
|
|
|
|
|
|
|
|
|
|
Arguments
|
|
|
|
|
buro_of_apps (list of 'app_label', optional)
|
2017-09-09 15:55:22 +02:00
|
|
|
|
perms (list of permission codes, optional)
|
2017-09-05 15:02:33 +02:00
|
|
|
|
|
|
|
|
|
Should be used in receiver of 'post_migrate' signal, after permissions
|
|
|
|
|
creation.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
def try_add_perm(group, app_label, codename):
|
|
|
|
|
try:
|
|
|
|
|
perm = Permission.objects.get(
|
|
|
|
|
content_type__app_label=app_label,
|
|
|
|
|
codename=codename,
|
|
|
|
|
)
|
|
|
|
|
except Permission.DoesNotExist:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
group.permissions.add(perm)
|
|
|
|
|
|
2017-09-09 15:55:22 +02:00
|
|
|
|
assoc_app_label = self.name.lower()
|
2017-09-05 15:02:33 +02:00
|
|
|
|
|
|
|
|
|
# Buro group has perm '<assoc>.buro'.
|
2017-09-09 15:55:22 +02:00
|
|
|
|
try_add_perm(self.staff_group, assoc_app_label, 'buro')
|
2017-09-05 15:02:33 +02:00
|
|
|
|
|
|
|
|
|
# Add all permissions of applications given 'buro_of_apps'.
|
|
|
|
|
apps_perms = Permission.objects.filter(
|
|
|
|
|
content_type__app_label__in=buro_of_apps,
|
|
|
|
|
)
|
|
|
|
|
self.staff_group.permissions.add(*apps_perms)
|
|
|
|
|
|
2017-09-09 15:55:22 +02:00
|
|
|
|
# Add extra permissions from 'perms'
|
|
|
|
|
for perm in perms:
|
|
|
|
|
app_label, codename = perm.split('.', maxsplit=1)
|
|
|
|
|
try_add_perm(self.staff_group, app_label, codename)
|
|
|
|
|
|
2017-09-05 15:02:33 +02:00
|
|
|
|
# Members have perm '<assoc>.member'.
|
2017-09-09 15:55:22 +02:00
|
|
|
|
try_add_perm(self.members_group, assoc_app_label, 'member')
|
2017-09-05 15:02:33 +02:00
|
|
|
|
|
2017-06-24 23:35:25 +02:00
|
|
|
|
|
2017-03-18 21:48:17 +01:00
|
|
|
|
# ---
|
|
|
|
|
# Clubs
|
|
|
|
|
# ---
|
|
|
|
|
|
2017-02-20 01:12:06 +01:00
|
|
|
|
class Club(models.Model):
|
|
|
|
|
ANNUAL = "ANN"
|
|
|
|
|
SEMESTER = "SEM"
|
|
|
|
|
COURSE = "COU"
|
|
|
|
|
|
|
|
|
|
COTISATION_FREQUENCY_CHOICES = [
|
|
|
|
|
(ANNUAL, _("Annuel")),
|
|
|
|
|
(SEMESTER, _("Semestriel")),
|
|
|
|
|
(COURSE, _("Au cours"))
|
|
|
|
|
]
|
|
|
|
|
|
2017-06-24 23:35:25 +02:00
|
|
|
|
association = models.ForeignKey(
|
|
|
|
|
Association,
|
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
|
related_name="clubs",
|
|
|
|
|
verbose_name=_("association"),
|
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
name = models.CharField(_("nom"), max_length=200, unique=True)
|
2017-08-06 20:56:11 +02:00
|
|
|
|
description = models.TextField(_("description"), blank=True)
|
2017-02-20 01:12:06 +01:00
|
|
|
|
members = models.ManyToManyField(
|
|
|
|
|
User,
|
|
|
|
|
through="ClubUser",
|
|
|
|
|
related_name="in_clubs",
|
2017-06-24 14:42:33 +02:00
|
|
|
|
blank=True,
|
|
|
|
|
verbose_name=_("membres du club"),
|
2017-02-20 01:12:06 +01:00
|
|
|
|
)
|
|
|
|
|
price = models.DecimalField(
|
2017-06-24 14:42:33 +02:00
|
|
|
|
_("cotisation (€)"),
|
2017-02-20 01:12:06 +01:00
|
|
|
|
decimal_places=2,
|
|
|
|
|
max_digits=5,
|
|
|
|
|
blank=True,
|
|
|
|
|
default=0
|
|
|
|
|
)
|
|
|
|
|
cotisation_frequency = models.CharField(
|
2017-06-24 14:42:33 +02:00
|
|
|
|
_("fréquence de la cotisation"),
|
2017-02-20 01:12:06 +01:00
|
|
|
|
default=ANNUAL,
|
|
|
|
|
choices=COTISATION_FREQUENCY_CHOICES,
|
|
|
|
|
max_length=3,
|
|
|
|
|
blank=True
|
|
|
|
|
)
|
|
|
|
|
|
2017-10-25 23:36:18 +02:00
|
|
|
|
class Meta:
|
|
|
|
|
verbose_name = _("club")
|
|
|
|
|
verbose_name_plural = _("clubs")
|
|
|
|
|
|
2017-02-20 01:12:06 +01:00
|
|
|
|
def __str__(self):
|
|
|
|
|
template = (
|
2017-08-07 18:56:56 +02:00
|
|
|
|
self.needs_cotiz and
|
2017-08-11 19:59:24 +02:00
|
|
|
|
"%(name)s (%(price).2f€ / %(cotisation_frequency)s)" or
|
|
|
|
|
"%(name)s"
|
2017-02-20 01:12:06 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
return template % vars(self)
|
2017-02-20 01:12:06 +01:00
|
|
|
|
|
2017-08-07 18:56:56 +02:00
|
|
|
|
def get_absolute_url(self):
|
|
|
|
|
return reverse('gestion:club_detail', args=[str(self.pk)])
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def needs_cotiz(self):
|
|
|
|
|
return bool(self.price)
|
|
|
|
|
|
|
|
|
|
def is_respo(self, user):
|
|
|
|
|
return self.clubuser_set.filter(user=user, is_respo=True).exists()
|
|
|
|
|
|
2017-02-20 01:12:06 +01:00
|
|
|
|
|
|
|
|
|
class ClubUser(models.Model):
|
2017-02-23 10:47:48 +01:00
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
|
|
|
club = models.ForeignKey(Club, on_delete=models.CASCADE)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
is_respo = models.BooleanField(_("est responsable du club"))
|
|
|
|
|
has_paid = models.BooleanField(_("a payé sa cotisation"))
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
2017-10-25 23:36:18 +02:00
|
|
|
|
class Meta:
|
|
|
|
|
verbose_name = _("inscription au club")
|
|
|
|
|
verbose_name_plural = _("inscriptions aux clubs")
|
|
|
|
|
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
|
# Events
|
|
|
|
|
# ---
|
|
|
|
|
|
2017-04-11 03:48:39 +02:00
|
|
|
|
class Location(models.Model):
|
2017-08-06 20:56:11 +02:00
|
|
|
|
name = models.CharField(_("nom du lieu"), max_length=200)
|
2017-04-11 03:48:39 +02:00
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("lieu")
|
|
|
|
|
verbose_name_plural = _("lieux")
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.name
|
2017-04-11 03:48:39 +02:00
|
|
|
|
|
|
|
|
|
|
2017-03-18 21:48:17 +01:00
|
|
|
|
class Event(models.Model):
|
2017-06-24 14:42:33 +02:00
|
|
|
|
associations = models.ManyToManyField(
|
2017-06-24 23:35:25 +02:00
|
|
|
|
Association,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
related_name="events",
|
|
|
|
|
verbose_name=_("associations"),
|
|
|
|
|
)
|
|
|
|
|
title = models.CharField(_("titre"), max_length=200)
|
|
|
|
|
location = models.ForeignKey(
|
|
|
|
|
Location,
|
2017-08-07 21:51:08 +02:00
|
|
|
|
blank=True, null=True,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
|
verbose_name=_("lieux"),
|
|
|
|
|
)
|
|
|
|
|
start_date = models.DateTimeField(
|
|
|
|
|
_("début de l'événement"),
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
)
|
|
|
|
|
end_date = models.DateTimeField(
|
|
|
|
|
_("fin de l'événement"),
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
)
|
|
|
|
|
description = models.TextField(_("description"), blank=True)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
image = models.ImageField(
|
2017-06-24 14:42:33 +02:00
|
|
|
|
_("image"),
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
upload_to="public/imgs/events/",
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
2017-08-06 20:56:11 +02:00
|
|
|
|
registration_open = models.NullBooleanField(
|
2017-06-24 14:42:33 +02:00
|
|
|
|
_("les inscriptions sont ouvertes"),
|
2017-08-06 20:56:11 +02:00
|
|
|
|
help_text=_("Indéfini signifie « l'inscription n'est pas requise »"),
|
|
|
|
|
default=True,
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
old = models.BooleanField(_("archiver (événement fini)"), default=False)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("événement")
|
|
|
|
|
verbose_name_plural = _("événements")
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
def __str__(self):
|
2017-08-06 20:56:11 +02:00
|
|
|
|
title, location = self.title, self.location
|
|
|
|
|
start = self.start_date.date()
|
|
|
|
|
end = self.end_date.date()
|
|
|
|
|
if not self.start_date.date():
|
|
|
|
|
return "{} @ {}".format(title, location)
|
|
|
|
|
elif start == end:
|
|
|
|
|
return "{} @ {} ({})".format(title, location, start)
|
|
|
|
|
else:
|
|
|
|
|
return "{} @ {} ({} → {})".format(title, location, start, end)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventCommentField(models.Model):
|
|
|
|
|
TEXT = "text"
|
|
|
|
|
CHAR = "char"
|
|
|
|
|
|
|
|
|
|
FIELD_TYPE = [
|
|
|
|
|
(TEXT, _("Texte long")),
|
|
|
|
|
(CHAR, _("Texte court")),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
event = models.ForeignKey(
|
|
|
|
|
Event,
|
|
|
|
|
on_delete=models.CASCADE,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
related_name="commentfields",
|
|
|
|
|
verbose_name=_("événement"),
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
name = models.CharField(_("nom du champ"), max_length=200)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
fieldtype = models.CharField(
|
2017-06-24 14:42:33 +02:00
|
|
|
|
_("type de champ"),
|
|
|
|
|
max_length=10,
|
|
|
|
|
choices=FIELD_TYPE, default=TEXT,
|
|
|
|
|
)
|
|
|
|
|
default = models.TextField(_("valeur par défaut"), blank=True)
|
|
|
|
|
ordering = models.IntegerField(
|
|
|
|
|
_("ordre des champs"),
|
2017-07-26 20:24:49 +02:00
|
|
|
|
default=0,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
help_text=_(
|
|
|
|
|
"plus petit en premier, ordre alphabétique sur le nom si "
|
|
|
|
|
"ambiguïté"
|
|
|
|
|
),
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("champ")
|
|
|
|
|
verbose_name_plural = _("champs")
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventCommentValue(models.Model):
|
|
|
|
|
commentfield = models.ForeignKey(
|
|
|
|
|
EventCommentField,
|
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
|
related_name="values"
|
|
|
|
|
)
|
|
|
|
|
registration = models.ForeignKey(
|
|
|
|
|
"EventRegistration",
|
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
|
related_name="comments"
|
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
content = models.TextField(_("contenu"), blank=True)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
unique_together = ("commentfield", "registration")
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
def __str__(self):
|
2017-06-24 14:42:33 +02:00
|
|
|
|
return (
|
|
|
|
|
_("Commentaire de %(field_name)s")
|
|
|
|
|
% {"field_name": self.commentfield}
|
|
|
|
|
)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventOption(models.Model):
|
|
|
|
|
event = models.ForeignKey(
|
|
|
|
|
Event,
|
|
|
|
|
on_delete=models.CASCADE,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
related_name="options",
|
|
|
|
|
verbose_name=_("événement"),
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
name = models.CharField(_("option"), max_length=200)
|
|
|
|
|
multi_choices = models.BooleanField(_("choix multiples"), default=False)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("option des événements")
|
|
|
|
|
verbose_name_plural = _("options des événements")
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventOptionChoice(models.Model):
|
|
|
|
|
event_option = models.ForeignKey(
|
|
|
|
|
EventOption,
|
|
|
|
|
on_delete=models.CASCADE,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
related_name="choices",
|
|
|
|
|
verbose_name=_("événement"),
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
|
|
|
|
value = models.CharField("Valeur", max_length=200)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("choix")
|
|
|
|
|
verbose_name_plural = _("choix")
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventRegistration(models.Model):
|
|
|
|
|
user = models.ForeignKey(
|
|
|
|
|
User,
|
2017-08-06 20:56:11 +02:00
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
|
null=True,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name=_("utilisateur"),
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
|
|
|
|
event = models.ForeignKey(
|
|
|
|
|
Event,
|
2017-06-24 14:42:33 +02:00
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
|
verbose_name=_("événement"),
|
|
|
|
|
)
|
|
|
|
|
options = models.ManyToManyField(
|
|
|
|
|
EventOptionChoice,
|
|
|
|
|
verbose_name=_("choix"),
|
2017-03-18 21:48:17 +01:00
|
|
|
|
)
|
2017-06-24 14:42:33 +02:00
|
|
|
|
filledcomments = models.ManyToManyField(
|
|
|
|
|
EventCommentField,
|
|
|
|
|
through=EventCommentValue,
|
|
|
|
|
verbose_name=_("commentaires"),
|
|
|
|
|
)
|
|
|
|
|
paid = models.BooleanField(_("a payé"), default=False)
|
2017-03-18 21:48:17 +01:00
|
|
|
|
|
|
|
|
|
class Meta:
|
2017-06-24 14:42:33 +02:00
|
|
|
|
verbose_name = _("inscription")
|
|
|
|
|
verbose_name_plural = _("inscriptions")
|
2017-03-18 21:48:17 +01:00
|
|
|
|
unique_together = ("user", "event")
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
2017-06-24 14:42:33 +02:00
|
|
|
|
return (
|
|
|
|
|
_("Inscription de %(user)s à %(event)s")
|
|
|
|
|
% {"user": self.user, "event": self.event}
|
|
|
|
|
)
|