From 222c97d63c34ab56c3bcbb299c6cf70a0eee7360 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 18 Sep 2020 21:19:31 +0200 Subject: [PATCH] Added voucher validity boolean icon display. --- django_lostplaces/lostplaces/admin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/django_lostplaces/lostplaces/admin.py b/django_lostplaces/lostplaces/admin.py index d56db16..977bc23 100644 --- a/django_lostplaces/lostplaces/admin.py +++ b/django_lostplaces/lostplaces/admin.py @@ -17,6 +17,11 @@ class VoucherAdmin(admin.ModelAdmin): readonly_fields = ['created_when'] list_display = ('__str__', 'code', 'created_when', 'expires_when', 'valid') + def valid(self, instance): + return timezone.now() <= instance.expires_when + + valid.boolean = True + class PhotoAlbumsAdmin(admin.ModelAdmin): list_display = ('label', 'place', 'url' )