aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2019-09-01 20:47:49 +0200
committerAlban Gruin2019-09-01 20:47:49 +0200
commit00d70c4d65967987c254c72f8bef5fda991f859b (patch)
tree670b2a78bfeb151096cfa844d6b48559dfc3641b /models.py
parentfe83f55800f78ff6ced9a13cf5a9c22fde0ead12 (diff)
parenta6eaecf48f63c37cf851386a45cd4b25ac3ed1e0 (diff)
Merge branch 'futur'
Diffstat (limited to 'models.py')
-rw-r--r--models.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/models.py b/models.py
index c8e7b3d..448b996 100644
--- a/models.py
+++ b/models.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2018 Alban Gruin
+# Copyright (C) 2017-2019 Alban Gruin
#
# celcatsanitizer is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
@@ -48,13 +48,15 @@ class Year(SlugModel):
class Source(models.Model):
- url = models.URLField(max_length=255, verbose_name="URL", unique=True)
+ url = models.URLField(max_length=255, verbose_name="URL")
+ metadata = models.CharField(max_length=256, verbose_name="Métadonnée",
+ blank=True, null=True)
last_update_date = models.DateTimeField(null=True, blank=True,
verbose_name="dernière mise à jour"
" Celcat")
def __str__(self):
- return self.url
+ return "{}, {}".format(self.url, self.metadata)
@property
def formatted_timetables(self):
@@ -62,6 +64,7 @@ class Source(models.Model):
self.timetables.all()])
class Meta:
+ unique_together = (("url", "metadata",),)
verbose_name = "source d’emploi du temps"
verbose_name_plural = "sources d’emploi du temps"
@@ -200,6 +203,18 @@ class Room(SlugModel):
verbose_name_plural = "salles"
+class Module(SlugModel):
+ name = models.CharField(max_length=255, unique=True, verbose_name="nom")
+ slug = models.SlugField(max_length=64, default="", unique=True)
+
+ def __str__(self):
+ return self.name
+
+ class Meta:
+ verbose_name = "module"
+ verbose_name_plural = "modules"
+
+
class CourseManager(Manager):
def get_courses(self, obj, **criteria):
qs = self.get_queryset()
@@ -246,6 +261,12 @@ class Course(models.Model):
last_update = models.DateTimeField(verbose_name="dernière mise à jour",
default=timezone.now)
+ celcat_id = models.CharField(max_length=64, verbose_name="ID Celcat",
+ null=True)
+ module = models.ForeignKey(Module, on_delete=models.SET_NULL, null=True)
+
+ buggy = models.BooleanField(verbose_name="Bogué", default=False)
+
def __str__(self):
return self.name
@@ -253,6 +274,7 @@ class Course(models.Model):
if self.type is not None:
self.type = self.type.replace("COURS", "cours")
self.type = self.type.replace("REUNION", "réunion")
+ self.type = self.type.replace("RENCONTRE", "rencontre")
if self.name is not None:
self.name = self.name.split("(")[0].strip()