X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/a7e41fefbf46ad5bfa2eb97dbd1cc11d3a28a354..f1143b5bcf508dcfe7f72e90faee72cf72a2392a:/src/messaging/admin.py diff --git a/src/messaging/admin.py b/src/messaging/admin.py index 1b2bac599..854079bee 100644 --- a/src/messaging/admin.py +++ b/src/messaging/admin.py @@ -1,9 +1,10 @@ from django.contrib import admin -from .models import EmailTemplate, EmailSent +from django.utils.translation import ugettext_lazy as _ +from . import models class EmailSentInline(admin.TabularInline): - model = EmailSent + model = models.EmailSent fields = ['timestamp', 'email', 'subject'] readonly_fields = ['timestamp', 'email', 'subject'] extra = 0 @@ -15,11 +16,26 @@ class EmailSentInline(admin.TabularInline): class EmailTemplateAdmin(admin.ModelAdmin): - list_display = ['state', 'days', 'subject', 'hour'] + list_display = ['state', 'min_days_since', 'subject', 'min_hour'] inlines = [EmailSentInline] - - -admin.site.register(EmailTemplate, EmailTemplateAdmin) + fieldsets = [ + (None, {"fields": [ + 'state', + ('min_days_since', 'max_days_since'), + 'is_active', + ]}), + (_('E-mail content'), {"fields": [ + 'subject', 'body' + ]}), + (_('Sending constraints'), {"fields": [ + ('min_day_of_month', 'max_day_of_month'), + ('dow_1', 'dow_2', 'dow_3', 'dow_4', 'dow_5', 'dow_6', 'dow_7'), + ('min_hour', 'max_hour'), + ]}), + ] + + +admin.site.register(models.EmailTemplate, EmailTemplateAdmin) class EmailSentAdmin(admin.ModelAdmin): @@ -30,5 +46,14 @@ class EmailSentAdmin(admin.ModelAdmin): change_links = ['template'] -admin.site.register(EmailSent, EmailSentAdmin) +admin.site.register(models.EmailSent, EmailSentAdmin) + + +class ContactAdmin(admin.ModelAdmin): + list_filter = ['level'] + list_display = ['email', 'level', 'since', 'expires_at'] + search_fields = ['email'] + date_hierarchy = 'since' + +admin.site.register(models.Contact, ContactAdmin)