From a6eebb2d59d35dc61e5a49cbc41b28d94234aa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Sun, 4 Aug 2024 18:15:01 +0200 Subject: [PATCH] =?UTF-8?q?Seznam=20organiz=C3=A1tor=C5=AF=20do=20person?= =?UTF-8?q?=C3=A1ln=C3=ADho?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/personalni}/organizatori.html | 0 personalni/urls.py | 12 +++++++ personalni/views.py | 29 +++++++++++++++++ seminar/urls.py | 4 --- seminar/views/views_all.py | 31 +------------------ 5 files changed, 42 insertions(+), 34 deletions(-) rename {seminar/templates/seminar/cojemam => personalni/templates/personalni}/organizatori.html (100%) diff --git a/seminar/templates/seminar/cojemam/organizatori.html b/personalni/templates/personalni/organizatori.html similarity index 100% rename from seminar/templates/seminar/cojemam/organizatori.html rename to personalni/templates/personalni/organizatori.html diff --git a/personalni/urls.py b/personalni/urls.py index 73a6f720..eae46257 100644 --- a/personalni/urls.py +++ b/personalni/urls.py @@ -21,4 +21,16 @@ urlpatterns = [ # Obecný view na profil -- orgům dá rozcestník, řešitelům jejich stránku path('profil/', views.profilView, name='profil'), + # Seznam organizátorů + path( + 'o-nas/organizatori/', + views.CojemamOrganizatoriView.as_view(), + name='organizatori' + ), + path( + 'o-nas/organizatori/organizovali/', + views.CojemamOrganizatoriStariView.as_view(), + name='stari_organizatori' + ), + ] diff --git a/personalni/views.py b/personalni/views.py index 96ef2405..da3ed07e 100644 --- a/personalni/views.py +++ b/personalni/views.py @@ -8,6 +8,7 @@ from django.contrib.auth.models import User, Permission, Group, AnonymousUser from django.contrib.auth.mixins import LoginRequiredMixin from django.db import transaction from django.http import HttpResponse +from django.utils import timezone import seminar.models as s import seminar.models as m @@ -23,6 +24,34 @@ from various.autentizace.utils import posli_reset_hesla from django.forms.models import model_to_dict +from .models import Organizator + + +def aktivniOrganizatori(datum=timezone.now()): + return Organizator.objects.exclude( + organizuje_do__isnull=False, + organizuje_do__lt=datum + ).order_by('osoba__jmeno') + + +class CojemamOrganizatoriView(generic.ListView): + model = Organizator + template_name = 'personalni/organizatori.html' + queryset = aktivniOrganizatori() + + def get_context_data(self, **kwargs): + context = super(CojemamOrganizatoriView, self).get_context_data(**kwargs) + context['aktivni'] = True + return context + + +class CojemamOrganizatoriStariView(generic.ListView): + model = Organizator + template_name = 'personalni/organizatori.html' + queryset = Organizator.objects.exclude( + id__in=aktivniOrganizatori() + ).order_by('-organizuje_do') + class OrgoRozcestnikView(TemplateView): """ Zobrazí organizátorský rozcestník.""" diff --git a/seminar/urls.py b/seminar/urls.py index afc2cd1d..275f64ba 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -6,10 +6,6 @@ urlpatterns = [ # path('aktualni/temata/', views.TemataRozcestnikView), # path('/t/', views.TematkoView), - # Organizatori - path('o-nas/organizatori/', views.CojemamOrganizatoriView.as_view(), name='organizatori'), - path('o-nas/organizatori/organizovali/', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'), - # Archiv path('archiv/rocniky/', views.ArchivView.as_view(), name="seminar_archiv_rocniky"), path('archiv/temata/', views.ArchivTemataView.as_view(), name="seminar_archiv_temata"), diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 3c3d4b16..f838481c 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -13,7 +13,7 @@ from django.contrib.staticfiles.finders import find import seminar.models as s import seminar.models as m from seminar.models import Problem, Cislo, Reseni, Nastaveni, Rocnik, \ - Organizator, Resitel, Novinky, Tema, Clanek, \ + Resitel, Novinky, Tema, Clanek, \ Deadline # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci #from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva from seminar import utils @@ -24,7 +24,6 @@ from vysledkovky.utils import body_resitelu, VysledkovkaCisla, \ VysledkovkaRocniku, VysledkovkaDoTeXu from datetime import date, datetime -from django.utils import timezone from itertools import groupby from collections import OrderedDict import tempfile @@ -224,34 +223,6 @@ def aktualni_temata(rocnik): return Tema.objects.filter(rocnik=rocnik, stav='zadany').order_by('kod') -### Co je M&M - - -# Organizatori -def aktivniOrganizatori(datum=timezone.now()): - return Organizator.objects.exclude( - organizuje_do__isnull=False, - organizuje_do__lt=datum - ).order_by('osoba__jmeno') - - -class CojemamOrganizatoriView(generic.ListView): - model = Organizator - template_name = 'seminar/cojemam/organizatori.html' - queryset = aktivniOrganizatori() - - def get_context_data(self, **kwargs): - context = super(CojemamOrganizatoriView, self).get_context_data(**kwargs) - context['aktivni'] = True - return context - - -class CojemamOrganizatoriStariView(generic.ListView): - model = Organizator - template_name = 'seminar/cojemam/organizatori.html' - queryset = Organizator.objects.exclude( - id__in=aktivniOrganizatori()).order_by('-organizuje_do') - ### Archiv