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):