diff --git a/data/sitetree.json b/data/sitetree.json index b910e5be..6cada534 100644 --- a/data/sitetree.json +++ b/data/sitetree.json @@ -832,5 +832,29 @@ }, "model": "sitetree.treeitem", "pk": 42 + }, + { + "fields": { + "access_guest": false, + "access_loggedin": false, + "access_perm_type": 1, + "access_permissions": [], + "access_restricted": false, + "alias": null, + "description": "", + "hidden": false, + "hint": "", + "inbreadcrumbs": true, + "inmenu": true, + "insitetree": true, + "parent": 3, + "sort_order": 43, + "title": "Aktuální ročník", + "tree": 1, + "url": "seminar_aktualni_rocnik", + "urlaspattern": true + }, + "model": "sitetree.treeitem", + "pk": 43 } ] \ No newline at end of file diff --git a/seminar/urls.py b/seminar/urls.py index 755e1efd..2818f1c9 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -61,6 +61,7 @@ urlpatterns = [ path('aktualni/zadani/', views.AktualniZadaniView, name='seminar_aktualni_zadani'), #path('aktualni/temata/', views.ZadaniTemataView, name='seminar_temata'), path('aktualni/vysledkova-listina/', views.ZadaniAktualniVysledkovkaView, name='seminar_aktualni_vysledky'), + path('aktualni/rocnik/', views.AktualniRocnikRedirectView.as_view(), name='seminar_aktualni_rocnik'), path('stare-novinky/', views.StareNovinkyView.as_view(), name='stare_novinky'), # Clanky diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 3ba73886..750a4718 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -11,7 +11,7 @@ from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect from django.db.models import Q, Sum, Count from django.views.decorators.csrf import ensure_csrf_cookie from django.views.generic.edit import FormView, CreateView -from django.views.generic.base import TemplateView +from django.views.generic.base import TemplateView, RedirectView from django.contrib.auth import authenticate, login, get_user_model, logout from django.contrib.auth import views as auth_views from django.contrib.auth.models import User, Permission @@ -1327,3 +1327,11 @@ class JakResitView(generic.ListView): def get_queryset(self): return None + +class AktualniRocnikRedirectView(RedirectView): + permanent=False + pattern_name = 'seminar_rocnik' + + def get_redirect_url(self, *args, **kwargs): + aktualni_rocnik = m.Nastaveni.get_solo().aktualni_rocnik.rocnik + return super().get_redirect_url(rocnik=aktualni_rocnik, *args, **kwargs)