1 from django.contrib import admin
2 from django.utils.translation import ugettext_lazy as _
6 class EmailSentInline(admin.TabularInline):
7 model = models.EmailSent
8 fields = ['timestamp', 'email', 'subject']
9 readonly_fields = ['timestamp', 'email', 'subject']
12 show_change_link = True
14 def has_add_permission(self, request, obj):
18 class EmailTemplateAdmin(admin.ModelAdmin):
19 list_display = ['state', 'min_days_since', 'subject', 'min_hour']
20 inlines = [EmailSentInline]
24 ('min_days_since', 'max_days_since'),
27 (_('E-mail content'), {"fields": [
30 (_('Sending constraints'), {"fields": [
31 ('min_day_of_month', 'max_day_of_month'),
32 ('dow_1', 'dow_2', 'dow_3', 'dow_4', 'dow_5', 'dow_6', 'dow_7'),
33 ('min_hour', 'max_hour'),
38 admin.site.register(models.EmailTemplate, EmailTemplateAdmin)
41 class EmailSentAdmin(admin.ModelAdmin):
42 list_filter = ['template']
43 list_display = ['timestamp', 'template', 'email', 'subject']
44 fields = ['timestamp', 'template', 'email', 'subject', 'body', 'hash_value']
45 readonly_fields = fields
46 change_links = ['template']
49 admin.site.register(models.EmailSent, EmailSentAdmin)
52 class ContactAdmin(admin.ModelAdmin):
53 list_filter = ['level']
54 list_display = ['email', 'level', 'since', 'expires_at']
55 search_fields = ['email']
56 date_hierarchy = 'since'
59 admin.site.register(models.Contact, ContactAdmin)