aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-19 13:51:46 +0100
committerAlban Gruin2017-01-19 13:51:46 +0100
commite9d4b61b1fb0d5efa78df56a2529185d3d8fabf5 (patch)
tree23e5bc9abdfdcf1e4db9b9d6f6c7635715a87b4d /models.py
parent7855fc164a16e0303f3d9aa7ee5c2ee9c719b4de (diff)
Association des cours et groupes à des emplois du temps spécifiques
Diffstat (limited to 'models.py')
-rw-r--r--models.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/models.py b/models.py
index a70e15c..09bf876 100644
--- a/models.py
+++ b/models.py
@@ -1,8 +1,23 @@
from django.db import models
+class Timetable(models.Model):
+ name = models.CharField(max_length=64, unique=True, verbose_name="nom")
+ url = models.URLField(max_length=255, unique=True, verbose_name="URL")
+ slug = models.SlugField(max_length=64, unique=True, default="")
+
+ def __str__(self):
+ return self.name
+
+
+ class Meta:
+ verbose_name = "emploi du temps"
+ verbose_name_plural = "emplois du temps"
+
+
class Group(models.Model):
- name = models.CharField(max_length=255, unique=True, verbose_name="nom")
+ name = models.CharField(max_length=255, verbose_name="nom")
+ timetable = models.ForeignKey(Timetable, on_delete=models.CASCADE, verbose_name="emploi du temps")
def __str__(self):
return self.name
@@ -11,6 +26,7 @@ class Group(models.Model):
class Meta:
verbose_name = "groupe"
verbose_name_plural = "groupes"
+ unique_together = ("name", "timetable",)
class Room(models.Model):
@@ -28,6 +44,7 @@ class Room(models.Model):
class Course(models.Model):
name = models.CharField(max_length=255, verbose_name="nom")
type_ = models.CharField(name="type", max_length=255, verbose_name="type de cours")
+ timetable = models.ForeignKey(Timetable, on_delete=models.CASCADE, verbose_name="emploi du temps")
groups = models.ManyToManyField(Group, verbose_name="groupes")
rooms = models.ManyToManyField(Room, verbose_name="salles")