|
|
@ -2,6 +2,9 @@ from django.shortcuts import get_object_or_404, render |
|
|
|
from django.http import HttpResponseRedirect |
|
|
|
from django.core.urlresolvers import reverse |
|
|
|
from django.views import generic |
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
from django.http import Http404 |
|
|
|
|
|
|
|
from .models import Problem, Cislo, Reseni, VysledkyKCislu, Nastaveni, Rocnik, Soustredeni |
|
|
|
|
|
|
|
|
|
|
@ -25,6 +28,20 @@ class RocnikView(generic.DetailView): |
|
|
|
model = Rocnik |
|
|
|
template_name = 'seminar/archiv/rocnik.html' |
|
|
|
|
|
|
|
# Vlastni ziskavani objektu z databaze podle (Rocnik.rocnik) |
|
|
|
def get_object(self, queryset=None): |
|
|
|
if queryset is None: |
|
|
|
queryset = self.get_queryset() |
|
|
|
rocnik_arg = self.kwargs.get('rocnik') |
|
|
|
queryset = queryset.filter(rocnik=rocnik_arg) |
|
|
|
|
|
|
|
try: |
|
|
|
obj = queryset.get() |
|
|
|
except queryset.model.DoesNotExist: |
|
|
|
raise Http404(_("No %(verbose_name)s found matching the query") % |
|
|
|
{'verbose_name': queryset.model._meta.verbose_name}) |
|
|
|
return obj |
|
|
|
|
|
|
|
class SoustredeniView(generic.DetailView): |
|
|
|
model = Soustredeni |
|
|
|
template_name = 'seminar/archiv/soustredeni.html' |
|
|
@ -39,6 +56,22 @@ class RadekVysledkovky(object): |
|
|
|
class CisloView(generic.DetailView): |
|
|
|
model = Cislo |
|
|
|
template_name = 'seminar/archiv/cislo.html' |
|
|
|
|
|
|
|
# Vlastni ziskavani objektu z databaze podle (Rocnik.rocnik) |
|
|
|
def get_object(self, queryset=None): |
|
|
|
if queryset is None: |
|
|
|
queryset = self.get_queryset() |
|
|
|
rocnik_arg = self.kwargs.get('rocnik') |
|
|
|
cislo_arg = self.kwargs.get('cislo') |
|
|
|
queryset = queryset.filter(rocnik__rocnik=rocnik_arg, cislo=cislo_arg) |
|
|
|
|
|
|
|
try: |
|
|
|
obj = queryset.get() |
|
|
|
except queryset.model.DoesNotExist: |
|
|
|
raise Http404(_("No %(verbose_name)s found matching the query") % |
|
|
|
{'verbose_name': queryset.model._meta.verbose_name}) |
|
|
|
return obj |
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
context = super(CisloView, self).get_context_data(**kwargs) |
|
|
|
|
|
|
|