aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.py12
-rw-r--r--models.py24
2 files changed, 25 insertions, 11 deletions
diff --git a/admin.py b/admin.py
index fba80c6..1493b0f 100644
--- a/admin.py
+++ b/admin.py
@@ -15,13 +15,19 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.contrib import admin
-from .models import Timetable, LastUpdate, Group, Subscription, Room, Course
+from .models import Timetable, LastUpdate, Group, Subscription, Room, Course, Year
+
+
+@admin.register(Year)
+class YearAdmin(admin.ModelAdmin):
+ pass
@admin.register(Timetable)
class TimetableAdmin(admin.ModelAdmin):
- prepopulated_fields = {"slug": ("year", "name",)}
- list_display = ("full_name", "url",)
+ prepopulated_fields = {"slug": ("name",)}
+ list_display = ("name", "year", "url",)
+ list_filter = ("year",)
@admin.register(LastUpdate)
diff --git a/models.py b/models.py
index 01819d6..f10f649 100644
--- a/models.py
+++ b/models.py
@@ -25,22 +25,30 @@ import hashlib
import os
+class Year(models.Model):
+ name = models.CharField(max_length=16, verbose_name="année")
+ slug = models.SlugField(max_length=16, unique=True, default="")
+
+ def __str__(self):
+ return self.name
+
+
+ class Meta:
+ verbose_name = "année"
+ verbose_name_plural = "années"
+
+
class Timetable(models.Model):
- year = models.CharField(max_length=16, verbose_name="année")
- name = models.CharField(max_length=64, verbose_name="nom")
+ year = models.ForeignKey(Year, verbose_name="année")
+ 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.full_name()
-
- def full_name(self):
- return self.year + " " + self.name
+ return self.name
- full_name.short_description = "Nom complet"
class Meta:
- unique_together = ("year", "name",)
verbose_name = "emploi du temps"
verbose_name_plural = "emplois du temps"