diff options
-rw-r--r-- | admin.py | 3 | ||||
-rw-r--r-- | management/commands/timetables.py | 11 | ||||
-rw-r--r-- | models.py | 9 |
3 files changed, 9 insertions, 14 deletions
@@ -65,8 +65,7 @@ class CourseAdmin(admin.ModelAdmin): @admin.register(CourseDelta) class CourseDeltaAdmin(admin.ModelAdmin): fieldsets = ( - (None, {"fields": ("course", "update", "operation",)}), - ) + (None, {"fields": ("course", "update", "operation",)}),) list_display = ("course", "update", "operation",) list_filter = ("operation",) ordering = ("update",) diff --git a/management/commands/timetables.py b/management/commands/timetables.py index d596233..0984c92 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.py @@ -39,13 +39,10 @@ def process_timetable_week(timetable, year, week, soup, weeks_in_soup): course.save() date = timezone.make_aware(datetime.datetime.now()) - try: - last_update = LastUpdate.objects.get(timetable=timetable, year=year, week=week) - last_update.date = date - except: - last_update = LastUpdate(timetable=timetable, year=year, week=week, date=date) - finally: - last_update.save() + + Course.objects.filter(checked=True).update(checked=False) + last_update = LastUpdate(timetable=timetable, year=year, week=week, date=date) + last_update.save() def process_timetable(timetable, year, weeks): soup = get_xml(timetable.url) @@ -50,9 +50,9 @@ class LastUpdate(models.Model): class Meta: - unique_together = ("timetable", "week", "year",) - verbose_name = "dernière mise à jour" - verbose_name_plural = "dernières mises à jour" + unique_together = ("timetable", "week", "year", "date",) + verbose_name = "mise à jour" + verbose_name_plural = "mises à jour" class GroupManager(Manager): @@ -183,8 +183,7 @@ class CourseDelta(models.Model): DELETED = 1 OPERATION_CHOICE = ( (ADDED, "Ajouté"), - (DELETED, "Supprimé"), - ) + (DELETED, "Supprimé"),) course = models.ForeignKey(Course, verbose_name="cours") update = models.ForeignKey(LastUpdate, verbose_name="mise à jour") |