From 94d8d7a50b6dd8a90dfbe8dd0aaef7c4d2fda9b3 Mon Sep 17 00:00:00 2001 From: alpcentaur Date: Mon, 27 Feb 2023 17:09:28 +0000 Subject: [PATCH] dates in tabulatures, based on django style with almost no new code. only applied to projects change list page --- input/admin.py | 9 +++++++-- input/models.py | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/input/admin.py b/input/admin.py index 55d5cc8..536c91a 100644 --- a/input/admin.py +++ b/input/admin.py @@ -32,13 +32,18 @@ class ProjectAdmin(admin.ModelAdmin): search_fields = ('name', 'pid','finance_id', 'realname', 'start', 'end', 'participants_estimated', 'participants_real', 'cost', 'status') list_display = ('name', 'pid','finance_id', 'realname', 'start', 'end', 'participants_estimated', 'participants_real', 'cost', 'status') # action = ['export_as_csv'] + date_hierarchy = 'start' @admin.register(BusinessCard) class BusinessCardAdmin(admin.ModelAdmin): - save_as = True - search_fields = ('realname', 'service_id', 'granted', 'granted_date', 'project') + save_as = True + search_fields = (('realname', 'service_id'), 'granted', 'granted_date', 'project') list_display = ('realname', 'service_id', 'granted', 'granted_date', 'project') + list_display_links = ('realname', 'service_id') # action = ['export_as_csv'] + classes = ['collapse'] + + admin.site.register([ Account, diff --git a/input/models.py b/input/models.py index 997a3a5..ec412d3 100644 --- a/input/models.py +++ b/input/models.py @@ -93,12 +93,14 @@ class Project(Volunteer): # we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors # but maybe there is a better solution? super().save() - self.pid = str(self.account.code) + str(self.pk).zfill(3) + self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3) + # self.pid = str(self.account.code) + str(self.pk).zfill(3) # generation of finance_id if not self.project_of_year: - #print('AAA') + print('AAA') # we need to determine if this is a new year with its first new project... year = self.start.year + print(year) projects = Project.objects.filter(start__year=year) if not projects: #print('BBB')