temata | prispevek | zakladni zobrazeni prispevku
Zobrazeni prispevku na strankach, potrebuje doladit konecnou podobu nadpisu. Pokud neni zaskrtnuto zverejnit haze 404 a orgum se zobrazi, pokud je zaskrtnuto zobrazit zobrazi se vsem stejne
This commit is contained in:
parent
abd392e1fe
commit
285eaaa672
3 changed files with 50 additions and 1 deletions
22
seminar/templates/seminar/archiv/prispevek.html
Normal file
22
seminar/templates/seminar/archiv/prispevek.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{% extends "seminar/archiv/base_temata.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{prispevek.nazev}}
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if not prispevek.zverejnit %}<div class="mam-org-only">{% endif %}
|
||||||
|
<h1>Příspěvek k tématu {{prispevek.problem.nazev}}
|
||||||
|
řešitele {{prispevek.reseni.resitel}}<h1>
|
||||||
|
|
||||||
|
{% if prispevek.text_org %}
|
||||||
|
<h2>Organizátorský komentář:</h2>
|
||||||
|
<i>{% autoescape off %}{{prispevek.text_org}}{% endautoescape %}</i>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if prispevek.text_resitel %}
|
||||||
|
<h2>Text od Řešitele</h2>
|
||||||
|
{% autoescape off %}{{prispevek.text_resitel}}{% endautoescape %}
|
||||||
|
{% endif %}
|
||||||
|
{% if not prispevek.zverejnit %}</div>{% endif %}
|
||||||
|
{% endblock content %}
|
|
@ -16,6 +16,7 @@ urlpatterns = [
|
||||||
url(r'^rocnik/(?P<rocnik>\d+)/$', views.RocnikView.as_view(), name='seminar_rocnik'),
|
url(r'^rocnik/(?P<rocnik>\d+)/$', views.RocnikView.as_view(), name='seminar_rocnik'),
|
||||||
url(r'^cislo/(?P<rocnik>\d+)\.(?P<cislo>[0-9-]+)/$', views.CisloView.as_view(), name='seminar_cislo'),
|
url(r'^cislo/(?P<rocnik>\d+)\.(?P<cislo>[0-9-]+)/$', views.CisloView.as_view(), name='seminar_cislo'),
|
||||||
url(r'^problem/(?P<pk>\d+)/$', views.ProblemView.as_view(), name='seminar_problem'),
|
url(r'^problem/(?P<pk>\d+)/$', views.ProblemView.as_view(), name='seminar_problem'),
|
||||||
|
url(r'^problem/(?P<pk>\d+)/(?P<prispevek>\d+)/$', views.PrispevekView.as_view(), name='seminar_problem_prispevek'),
|
||||||
|
|
||||||
url(r'^soustredeni/probehlo/$', views.SoustredeniListView.as_view(),
|
url(r'^soustredeni/probehlo/$', views.SoustredeniListView.as_view(),
|
||||||
name = 'seminar_seznam_soustredeni'),
|
name = 'seminar_seznam_soustredeni'),
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.db.models import Q
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||||
from django.contrib.auth import authenticate, login
|
from django.contrib.auth import authenticate, login
|
||||||
|
|
||||||
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka
|
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Prispevek
|
||||||
from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
@ -247,6 +247,32 @@ class ProblemView(generic.DetailView):
|
||||||
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
|
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
class PrispevekView(generic.DetailView):
|
||||||
|
model = Prispevek
|
||||||
|
template_name = 'seminar/archiv/prispevek.html'
|
||||||
|
|
||||||
|
# Vlastni ziskavani objektu z databaze podle prispevku
|
||||||
|
# pokud je prispevek neverejny zobrazi se jenom orgum
|
||||||
|
def get_object(self, queryset=None):
|
||||||
|
if queryset is None:
|
||||||
|
queryset = self.get_queryset()
|
||||||
|
problem_arg = self.kwargs.get('pk')
|
||||||
|
prispevek_arg = self.kwargs.get('prispevek')
|
||||||
|
queryset = queryset.filter(pk=prispevek_arg)
|
||||||
|
|
||||||
|
print queryset
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
if self.request.user.is_staff or obj.zverejnit:
|
||||||
|
return obj
|
||||||
|
else:
|
||||||
|
raise Http404()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RadekVysledkovky(object):
|
class RadekVysledkovky(object):
|
||||||
|
|
Loading…
Reference in a new issue