From 35ecadcbe283b2c1368141be5bec16d66c443f7c Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 22 Jan 2017 15:27:02 +0100 Subject: Ajout du modèle des inscriptions pour les notifications par email --- admin.py | 7 ++++++- models.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/admin.py b/admin.py index d49c123..b1edf2f 100644 --- a/admin.py +++ b/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from edt.models import Timetable, LastUpdate, Group, Room, Course +from edt.models import Timetable, LastUpdate, Group, Subscription, Room, Course @admin.register(Timetable) @@ -24,6 +24,11 @@ class GroupAdmin(admin.ModelAdmin): readonly_fields = ("mention", "subgroup", "td", "tp",) +@admin.register(Subscription) +class SubscriptionAdmin(admin.ModelAdmin): + list_display = ("email", "group", "active",) + + @admin.register(Room) class RoomAdmin(admin.ModelAdmin): pass diff --git a/models.py b/models.py index d01dbf0..9f9387d 100644 --- a/models.py +++ b/models.py @@ -64,9 +64,23 @@ class Group(models.Model): class Meta: + unique_together = ("name", "timetable",) verbose_name = "groupe" verbose_name_plural = "groupes" - unique_together = ("name", "timetable",) + + +class Subscription(models.Model): + email = models.EmailField(verbose_name="adresse") + group = models.ForeignKey(Group, on_delete=models.CASCADE, verbose_name="groupe") + active = models.BooleanField(verbose_name="activé", default=False) + token = models.CharField(max_length=64, unique=True, default="") + + + class Meta: + index_together = ("group", "active",) + unique_together = ("email", "group",) + verbose_name = "abonnement" + verbose_name_plural = "abonnements" class Room(models.Model): -- cgit v1.2.1