X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/3c6061e46736c8673316f609ad5b5cb86dcd7096..dbe0a80a192f561f29f917cd741b78329834a89f:/src/messaging/admin.py?ds=inline diff --git a/src/messaging/admin.py b/src/messaging/admin.py index 6749106d6..3610f05d4 100644 --- a/src/messaging/admin.py +++ b/src/messaging/admin.py @@ -1,35 +1,21 @@ 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 -class EmailSentInline(admin.TabularInline): - model = models.EmailSent - fields = ['timestamp', 'contact', 'subject'] - readonly_fields = ['timestamp', 'contact', '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', ('min_days_since', 'max_days_since'), 'is_active', ]}), - (_('E-mail content'), {"fields": [ + ('Zawartość e-maila', {"fields": [ 'subject', 'body' ]}), - (_('Sending constraints'), {"fields": [ + ('Ograniczenia wysyłki', {"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'), @@ -39,9 +25,17 @@ class EmailTemplateAdmin(admin.ModelAdmin): def _test_email(self, request, obj): if request.user.email: obj.send_test_email(request.user.email) - messages.info(request, _('Test e-mail has been sent to %(email)s.') % {"email": request.user.email}) + messages.info( + request, + 'Na adres %(email)s została wysłana testowa wiadomość.' % { + "email": request.user.email + } + ) else: - messages.warning(request, _('You have no email set. Test e-mail not sent.')) + messages.warning( + request, + 'Nie masz ustawionego adresu e-mail. Wiadomość testowa nie została wysłana.' + ) def response_add(self, request, obj): self._test_email(request, obj) @@ -84,7 +78,10 @@ class ContactAdmin(admin.ModelAdmin): 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'])] + 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)