Tabellen Ansicht erweitert: Emailstate

main
Samuel Zielke 8 months ago
parent 61d754e060
commit 2deccd57ce

@ -12,6 +12,8 @@ from django.utils.html import strip_tags
from django.utils.timezone import now from django.utils.timezone import now
from django.shortcuts import redirect from django.shortcuts import redirect
from django.urls import path from django.urls import path
from django.utils.timezone import now
from datetime import timedelta
from .models import contributors from .models import contributors
@ -53,14 +55,25 @@ class MainDB_contributorsAdmin(ExportMixin, ImportMixin, admin.ModelAdmin):
resource_class = contributorsResource 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') search_fields = ('name', 'firstname', 'congregation__title', 'deparment__title', 'mobilnumber', 'email', 'jwpub')
actions = [send_custom_email] 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'<span style="color: {color}; font-size: 16px;">●</span>')
get_emailstate.short_description = "E-Mail"
get_emailstate.admin_order_field = "email_sent_at"
def get_urls(self): def get_urls(self):
urls = super().get_urls() urls = super().get_urls()
custom_urls = [ custom_urls = [

Loading…
Cancel
Save

Powered by TurnKey Linux.