X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e852900e42eb0bde98daf7070d84816e44c3308e..2a54a1a2eaf66e7d65dcfbb6023a9ebc0ef138a0:/src/messaging/admin.py?ds=inline diff --git a/src/messaging/admin.py b/src/messaging/admin.py index 9ac76b53d..6749106d6 100644 --- a/src/messaging/admin.py +++ b/src/messaging/admin.py @@ -1,6 +1,7 @@ from django.contrib import admin from django.contrib import messages from django.utils.translation import ugettext_lazy as _ +from fnpdjango.actions import export_as_csv_action from . import models @@ -65,11 +66,25 @@ class EmailSentAdmin(admin.ModelAdmin): admin.site.register(models.EmailSent, EmailSentAdmin) +class ContactEmailSentInline(admin.TabularInline): + model = models.EmailSent + fields = ['timestamp', 'template', 'subject'] + readonly_fields = ['timestamp', 'template', 'subject'] + extra = 0 + can_delete = False + show_change_link = True + + def has_add_permission(self, request, obj): + return False + + class ContactAdmin(admin.ModelAdmin): + inlines = [ContactEmailSentInline] list_filter = ['level'] list_display = ['email', 'level', 'since', 'expires_at'] search_fields = ['email'] date_hierarchy = 'since' + actions = [export_as_csv_action(fields=['id', 'email', 'get_level_display', 'since', 'expires_at'])] admin.site.register(models.Contact, ContactAdmin)