1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-26 07:02:24 +00:00
med/media/models.py

50 lines
1.8 KiB
Python
Raw Normal View History

2017-06-30 01:25:07 +00:00
from django.db import models
2017-07-03 23:47:22 +00:00
from django.core.validators import MinValueValidator
2017-06-30 01:25:07 +00:00
class Auteur(models.Model):
2017-07-04 20:29:11 +00:00
nom = models.CharField(max_length=255, unique=True)
2017-06-30 01:25:07 +00:00
def __str__(self):
return self.nom
class Media(models.Model):
titre = models.CharField(max_length=255)
cote = models.CharField(max_length=31)
2017-06-30 14:01:44 +00:00
auteur = models.ManyToManyField('Auteur')
2017-06-30 01:25:07 +00:00
# type = TODO
def __str__(self):
2017-07-03 15:48:56 +00:00
return str(self.titre) + ' - ' + str(self.auteur.all().first())
2017-06-30 01:25:07 +00:00
class Emprunt(models.Model):
media = models.ForeignKey('Media', on_delete=models.PROTECT)
user = models.ForeignKey('users.User', on_delete=models.PROTECT)
date_emprunt = models.DateTimeField(help_text='%d/%m/%y %H:%M:%S')
date_rendu = models.DateTimeField(help_text='%d/%m/%y %H:%M:%S', blank=True, null=True)
permanencier_emprunt = models.ForeignKey('users.User', on_delete=models.PROTECT, related_name='user_permanencier_emprunt')
permanencier_rendu = models.ForeignKey('users.User', on_delete=models.PROTECT, related_name='user_permanencier_rendu', blank=True, null=True)
2017-07-06 15:30:23 +00:00
def __str__(self):
return str(self.media) + str(self.user)
2017-06-30 01:25:07 +00:00
2017-07-03 15:48:56 +00:00
class Jeu(models.Model):
DUREE = (
2017-07-03 23:47:22 +00:00
('-1h', '-1h'),
('1-2h', '1-2h'),
('2-3h', '2-3h'),
2017-07-04 20:29:11 +00:00
('3-4h', '3-4h'),
2017-07-03 23:47:22 +00:00
('4h+', '4h+'),
2017-07-03 15:48:56 +00:00
)
2017-06-30 01:25:07 +00:00
2017-07-03 15:48:56 +00:00
nom = models.CharField(max_length=255)
proprietaire = models.ForeignKey('users.User', on_delete=models.PROTECT)
duree = models.CharField(choices=DUREE, max_length=255)
2017-07-03 23:47:22 +00:00
nombre_joueurs_min = models.IntegerField(validators=[MinValueValidator(1)])
nombre_joueurs_max = models.IntegerField(validators=[MinValueValidator(1)])
2017-07-03 15:48:56 +00:00
comment = models.CharField(help_text="Commentaire", max_length=255, blank=True, null=True)
2017-07-06 15:30:23 +00:00
def __str__(self):
return str(self.nom)