|
@@ -1,6 +1,7 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
from django.contrib import admin
|
|
|
+from django.utils.html import format_html
|
|
|
|
|
|
# Register your models here.
|
|
|
from .models import Contrib
|
|
@@ -14,7 +15,7 @@ admin.site.site_title = "Wifi with me"
|
|
|
@admin.register(Contrib)
|
|
|
class ContribAdmin(admin.ModelAdmin):
|
|
|
search_fields = ["name", "email", "phone"]
|
|
|
- list_display = ("name", "date", "phone", "email")
|
|
|
+ list_display = ("name", "date", "phone", "email", "expired_string")
|
|
|
|
|
|
readonly_fields = ['date', 'expiration_date']
|
|
|
fieldsets = [
|
|
@@ -43,3 +44,11 @@ class ContribAdmin(admin.ModelAdmin):
|
|
|
'classes': ['collapse'],
|
|
|
}]
|
|
|
]
|
|
|
+
|
|
|
+ def expired_string(self, obj):
|
|
|
+ if obj.is_expired():
|
|
|
+ return format_html('<strong style="color: red; cursor: help;" title="Cette entrée excède la durée de rétention et aurait dû être supprimée automatiquement.">expiré</strong>')
|
|
|
+ else:
|
|
|
+ return 'non expiré'
|
|
|
+
|
|
|
+ expired_string.short_description = 'Expiration'
|