aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/models.py b/models.py
index 4903b11..60be95c 100644
--- a/models.py
+++ b/models.py
@@ -42,7 +42,6 @@ class Year(SlugModel):
def __str__(self):
return self.name
-
class Meta:
verbose_name = "année"
verbose_name_plural = "années"
@@ -50,16 +49,17 @@ class Year(SlugModel):
class Source(models.Model):
url = models.URLField(max_length=255, verbose_name="URL", unique=True)
- last_update_date = models.DateTimeField(verbose_name="dernière mise à jour Celcat",
- null=True, blank=True)
+ last_update_date = models.DateTimeField(null=True, blank=True,
+ verbose_name="dernière mise à jour"
+ "Celcat")
def __str__(self):
return self.url
@property
def formatted_timetables(self):
- return ", ".join([str(timetable) for timetable in self.timetables.iterator()])
-
+ return ", ".join([str(timetable) for timetable in
+ self.timetables.iterator()])
class Meta:
verbose_name = "source d’emploi du temps"
@@ -79,12 +79,12 @@ class Timetable(SlugModel):
name = models.CharField(max_length=64, verbose_name="nom")
slug = models.SlugField(max_length=64, default="")
source = models.ForeignKey(Source, on_delete=models.CASCADE,
- verbose_name="source", related_name="timetables")
+ verbose_name="source",
+ related_name="timetables")
def __str__(self):
return self.year.name + " " + self.name
-
class Meta:
unique_together = (("year", "name"), ("year", "slug"),)
verbose_name = "emploi du temps"
@@ -95,11 +95,12 @@ class GroupManager(Manager):
def get_parents(self, group):
groups_criteria = reduce(lambda x, y: x | y,
[Q(subgroup=group.subgroup[:i])
- for i in range(1, len(group.subgroup) + 1)],
+ for i in range(1, len(group.subgroup) + 1)],
Q(subgroup=""))
return self.get_queryset().filter(groups_criteria,
- Q(semester=None) | Q(semester=group.semester),
+ Q(semester=None) |
+ Q(semester=group.semester),
mention=group.mention,
source=group.source)
@@ -115,7 +116,8 @@ class Group(SlugModel):
mention = models.CharField(max_length=128)
semester = models.IntegerField(verbose_name="semestre", null=True)
- subgroup = models.CharField(max_length=16, verbose_name="sous-groupe", default="")
+ subgroup = models.CharField(max_length=16, verbose_name="sous-groupe",
+ default="")
slug = models.SlugField(max_length=64, default="")
@@ -126,10 +128,10 @@ class Group(SlugModel):
if self.subgroup is not None and subgroup is not None:
subgroup_corresponds = self.subgroup.startswith(subgroup)
- return (self.mention.startswith(mention) or \
+ return (self.mention.startswith(mention) or
mention.startswith(self.mention)) and \
- (self.semester == semester or semester is None) and \
- subgroup_corresponds
+ (self.semester == semester or semester is None) and \
+ subgroup_corresponds
@property
def group_info(self):
@@ -148,7 +150,6 @@ class Group(SlugModel):
super(Group, self).save()
-
class Meta:
index_together = ("mention", "semester", "subgroup",)
unique_together = (("name", "source",),
@@ -175,8 +176,8 @@ class CourseManager(Manager):
def get_courses(self, obj, **criteria):
qs = self.get_queryset()
if isinstance(obj, Group):
- qs = qs.filter(groups__in=Group.objects.get_parents(obj), **criteria) \
- .prefetch_related("rooms")
+ qs = qs.filter(groups__in=Group.objects.get_parents(obj),
+ **criteria).prefetch_related("rooms")
elif isinstance(obj, Room):
qs = qs.filter(rooms__in=(obj,), **criteria)
else:
@@ -197,7 +198,8 @@ class CourseManager(Manager):
class Course(models.Model):
objects = CourseManager()
- name = models.CharField(max_length=255, verbose_name="nom", default="Sans nom")
+ name = models.CharField(max_length=255, verbose_name="nom",
+ default="Sans nom")
type_ = models.CharField(name="type", max_length=255,
verbose_name="type de cours", null=True)
source = models.ForeignKey(Source, on_delete=models.CASCADE,
@@ -225,7 +227,6 @@ class Course(models.Model):
super(Course, self).save(*args, **kwargs)
-
class Meta:
verbose_name = "cours"
verbose_name_plural = "cours"