1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Finish script, finish view, make some progress on template

This commit is contained in:
quark
2025-02-16 18:10:53 +01:00
parent 19d1ecfc66
commit 5f1b698d58
20 changed files with 1211 additions and 68 deletions

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from hashlib import md5
import json
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
@ -39,12 +40,17 @@ class WrappedListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView)
def get_queryset(self, **kwargs):
return super().get_queryset(**kwargs).distinct()
def get_table_data(self):
def get_table_data(self):
return Wrapped.objects.filter(PermissionBackend.filter_queryset(
self.request, Wrapped, "change", field='public')).distinct().order_by("-bde__date_start")
def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs)
context = super().get_context_data(**kwargs)
W = self.object_list.filter(note__noteclub__club__pk__gte=-1, public=False)
if W:
context['club_not_public'] = 'true'
else: context['club_not_public'] = 'false'
return context
class WrappedDetailView(ProtectQuerysetMixin, DetailView):
"""
@ -55,9 +61,14 @@ class WrappedDetailView(ProtectQuerysetMixin, DetailView):
def get(self, *args, **kwargs):
bde_id = Wrapped.objects.get(pk=kwargs['pk']).bde.id
self.template_name = 'wrapped/' + str(bde_id) + '/wrapped_view.html'
note_type = 'user' if 'user' in Wrapped.objects.get(pk=kwargs['pk']).note.__dir__() else 'club'
self.template_name = 'wrapped/' + str(bde_id) + '/wrapped_view_' + note_type + '.html'
return super().get(*args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context = super().get_context_data( **kwargs)
d = json.loads(self.object.data_json)
for key in d:
context[key] = d[key]
context['title'] = str(self.object)
return context