From ed798cbf8ebf5fcdb9f295f5e5292ada166301e9 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 3 Nov 2023 12:39:27 +0100 Subject: [PATCH] Allow setting both rowclass and rowtitle in backend lists And use this to explain the different colors in the tweet lists. --- postgresqleu/confreg/backendforms.py | 10 +++++----- postgresqleu/util/backendforms.py | 4 ++-- postgresqleu/util/backendviews.py | 3 +-- template/confreg/admin_backend_list.html | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/postgresqleu/confreg/backendforms.py b/postgresqleu/confreg/backendforms.py index 7616f914..2e1c345a 100644 --- a/postgresqleu/confreg/backendforms.py +++ b/postgresqleu/confreg/backendforms.py @@ -1607,16 +1607,16 @@ class BackendTweetQueueForm(BackendForm): ] @classmethod - def get_rowclass(self, obj): + def get_rowclass_and_title(self, obj, cache): if obj.sent: if obj.errorcount > 0: - return "warning" + return "warning", "Sent, but had errors" else: - return "info" + return "info", "Sent" else: if obj.errorcount > 0: - return "danger" - return None + return "danger", "Errors present" + return None, None @classmethod def get_column_filters(cls, conference): diff --git a/postgresqleu/util/backendforms.py b/postgresqleu/util/backendforms.py index efffc06e..8af4ea28 100644 --- a/postgresqleu/util/backendforms.py +++ b/postgresqleu/util/backendforms.py @@ -184,8 +184,8 @@ class BackendForm(ConcurrentProtectedModelForm): return {} @classmethod - def get_rowclass(self, obj): - return None + def get_rowclass_and_title(self, obj, cache): + return None, None @classmethod def get_field_verbose_name(self, f): diff --git a/postgresqleu/util/backendviews.py b/postgresqleu/util/backendviews.py index f260e7ba..c4d233b7 100644 --- a/postgresqleu/util/backendviews.py +++ b/postgresqleu/util/backendviews.py @@ -289,8 +289,7 @@ def backend_list_editor(request, urlname, formclass, resturl, allow_new=True, al values = [{ 'id': o.pk, 'vals': [getattr(o, '_display_{0}'.format(f))(cache) if hasattr(o, '_display_{0}'.format(f)) else getattr(o, f) for f in formclass.list_fields], - 'rowclass': formclass.get_rowclass(o), - } for o in objects] + } | dict(zip(["rowclass", "rowtitle"], formclass.get_rowclass_and_title(o, cache))) for o in objects] return render(request, 'confreg/admin_backend_list.html', { 'conference': conference, diff --git a/template/confreg/admin_backend_list.html b/template/confreg/admin_backend_list.html index c7487826..c1f99ebb 100644 --- a/template/confreg/admin_backend_list.html +++ b/template/confreg/admin_backend_list.html @@ -99,7 +99,7 @@ $(document).ready(function() { {%for o in values%} - + {%for v in o.vals%} {%if forloop.first and not noeditlinks%} {%endif%}{%if v|isboolean%}{%if v%}{%else%}{%endif%}{%elif v|vartypename == "LineBreakString"%}{{v|default:""|linebreaks}}{%else%}{{v|default:""}}{%endif%} {%endfor%} -- 2.39.5