From 20a7dbe7d0f5187b637c94d68a02e5d5dde02c36 Mon Sep 17 00:00:00 2001 From: Schlabonski Date: Wed, 19 Oct 2016 20:30:10 +0200 Subject: [PATCH] change MaterialPart.should_be_replaced to .not_too_old It is more convenient to show the logical negation of should_be_replaced as booleans are shown as little green or red items by django. Having a green tick when the item is NOT okay seems a bit counterintuitive. --- jdav_web/material/admin.py | 2 +- jdav_web/material/models.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jdav_web/material/admin.py b/jdav_web/material/admin.py index 2879af2..97518a9 100644 --- a/jdav_web/material/admin.py +++ b/jdav_web/material/admin.py @@ -16,7 +16,7 @@ class OwnershipInline(admin.StackedInline): class MaterialAdmin(admin.ModelAdmin): """Edit view of a MaterialPart""" fields = ['name', 'buy_date', 'lifetime'] - list_display = ('name', 'buy_date', 'lifetime', 'should_be_replaced') + list_display = ('name', 'buy_date', 'lifetime', 'not_too_old') inlines = [OwnershipInline] admin.site.register(MaterialPart, MaterialAdmin) diff --git a/jdav_web/material/models.py b/jdav_web/material/models.py index 2cbc1fa..3a4709e 100644 --- a/jdav_web/material/models.py +++ b/jdav_web/material/models.py @@ -21,15 +21,15 @@ class MaterialPart(models.Model): """String representation""" return self.name - def should_be_replaced(self): + def not_too_old(self): """Returns wether the part should be replaced cause of age""" buy_time = timezone.make_aware(datetime.combine(self.buy_date, datetime.min.time())) - return yearsago(self.lifetime) >= buy_time + return yearsago(self.lifetime) < buy_time - should_be_replaced.admin_order_field = 'buy_date' - should_be_replaced.boolean = True - should_be_replaced.short_description = 'Should be replaced?' + not_too_old.admin_order_field = 'buy_date' + not_too_old.boolean = True + not_too_old.short_description = 'Not too old?' class Ownership(models.Model):