ernestophone.ens.fr/calendrier/models.py

54 lines
1.8 KiB
Python
Raw Normal View History

2015-04-13 18:56:43 +02:00
from django.db import models
import uuid
2015-07-22 22:08:59 +02:00
from gestion.models import ErnestoUser
from django.utils.translation import gettext_lazy as _
2021-03-31 16:05:26 +02:00
from colorful.fields import RGBColorField
2015-07-22 22:08:59 +02:00
ANSWERS = (
('oui', _('Oui')),
('non', _('Non')),
('pe', _('Peut-etre')),
2015-07-22 22:08:59 +02:00
)
2015-04-13 18:56:43 +02:00
class Event(models.Model):
nom = models.CharField(max_length=100)
nomcourt = models.CharField(max_length=9, verbose_name=_("Nom court"))
2015-04-13 18:56:43 +02:00
date = models.DateField()
debut = models.TimeField()
fin = models.TimeField(blank=True, null=True)
slug = models.CharField(max_length=7, editable=False, unique=True, default=uuid.uuid1)
2015-04-13 18:56:43 +02:00
lieu = models.CharField(max_length=200)
description = models.TextField(blank=True)
description_en = models.TextField(blank=True)
desc_users = models.TextField(
blank=True,
verbose_name=_("Infos (visible seulement des fanfaron-ne-s)"),
null=True)
desc_users_en = models.TextField(
blank=True,
verbose_name=_("Infos en anglais (visible seulement des fanfaron-ne-s)"),
null=True)
CALENDRIER_CHOICES = [
('F', _('Visible seulement par les fanfarons')),
('T', _('Afficher dans le calendrier pour tous')),
('H', _('Hall of fame')),
]
calendrier = models.CharField(
max_length=1,
choices=CALENDRIER_CHOICES,
default='F',
)
2015-04-13 18:56:43 +02:00
def __str__(self):
return self.nom
2015-07-22 22:08:59 +02:00
class Meta:
verbose_name = _("Evenement")
2015-07-22 22:08:59 +02:00
class Participants(models.Model):
2018-01-04 23:43:10 +01:00
event = models.ForeignKey(Event, on_delete=models.CASCADE)
participant = models.ForeignKey(ErnestoUser, on_delete=models.CASCADE)
reponse = models.CharField(_("Réponse"), max_length=20, default="non",
choices=ANSWERS)
details = models.CharField(max_length=50, blank=True)