From 2deccd57ce6488fe888c8d8157bb9029a79f15a3 Mon Sep 17 00:00:00 2001 From: Samuel Zielke Date: Wed, 26 Mar 2025 17:16:28 +0100 Subject: [PATCH] Tabellen Ansicht erweitert: Emailstate --- main/admin.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main/admin.py b/main/admin.py index 04ef2af..4658dfe 100644 --- a/main/admin.py +++ b/main/admin.py @@ -12,6 +12,8 @@ from django.utils.html import strip_tags from django.utils.timezone import now from django.shortcuts import redirect from django.urls import path +from django.utils.timezone import now +from datetime import timedelta from .models import contributors @@ -53,13 +55,24 @@ class MainDB_contributorsAdmin(ExportMixin, ImportMixin, admin.ModelAdmin): resource_class = contributorsResource - list_display = ('full_name', 'actual', 'da_approval', 'leader', 'tage_anzeige', 'get_deparment', 'gender', 'birthday_year', 'get_congregation', 'mobilnumber', 'email') + list_display = ('full_name', 'actual', 'get_emailstate', 'da_approval', 'leader', 'tage_anzeige', 'get_deparment', 'gender', 'birthday_year', 'get_congregation', 'mobilnumber', 'email') - list_filter = ('gender', 'roles', 'deparment', 'da_approval', 'actual') + list_filter = ('gender', 'roles', 'deparment', 'da_approval', 'actual', 'email_sent_at') search_fields = ('name', 'firstname', 'congregation__title', 'deparment__title', 'mobilnumber', 'email', 'jwpub') actions = [send_custom_email] + + def get_emailstate(self, obj): + if obj.email_sent_at != None: + color = 'green' + if obj.email_sent_at < now() - timedelta(days=30): + color = 'gold' + else: + color = 'red' + return format_html(f'') + get_emailstate.short_description = "E-Mail" + get_emailstate.admin_order_field = "email_sent_at" def get_urls(self): urls = super().get_urls()