X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/4603878e7fc59d5cd25ec659d5012ddfe7b5152c..243ac5a586da9e5abb87698306794b6cc173ded1:/src/messaging/admin.py diff --git a/src/messaging/admin.py b/src/messaging/admin.py index 558c34d8a..06ed21202 100644 --- a/src/messaging/admin.py +++ b/src/messaging/admin.py @@ -1,24 +1,12 @@ from django.contrib import admin from django.contrib import messages -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ +from fnpdjango.actions import export_as_csv_action from . import models -class EmailSentInline(admin.TabularInline): - model = models.EmailSent - fields = ['timestamp', 'email', 'subject'] - readonly_fields = ['timestamp', 'email', 'subject'] - extra = 0 - can_delete = False - show_change_link = True - - def has_add_permission(self, request, obj): - return False - - class EmailTemplateAdmin(admin.ModelAdmin): - list_display = ['state', 'min_days_since', 'subject', 'min_hour'] - inlines = [EmailSentInline] + list_display = ['state', 'min_days_since', 'subject', 'min_hour', 'is_active'] fieldsets = [ (None, {"fields": [ 'state', @@ -56,8 +44,8 @@ admin.site.register(models.EmailTemplate, EmailTemplateAdmin) class EmailSentAdmin(admin.ModelAdmin): list_filter = ['template'] - list_display = ['timestamp', 'template', 'email', 'subject'] - fields = ['timestamp', 'template', 'email', 'subject', 'body', 'hash_value'] + list_display = ['timestamp', 'template', 'contact', 'subject'] + fields = ['timestamp', 'template', 'contact', 'subject', 'body'] readonly_fields = fields change_links = ['template'] @@ -65,11 +53,28 @@ 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']), + export_as_csv_action('Eksport dla PHPList', fields=['email', 'wl_optout_url']) + ] admin.site.register(models.Contact, ContactAdmin)