Browse Source

Struktura pro články

remotes/origin/noc
Matěj Kocián 9 years ago
parent
commit
1ae9bb5e04
  1. 28
      seminar/templates/seminar/archiv/problem.html
  2. 38
      seminar/templates/seminar/archiv/problem_clanek.html
  3. 27
      seminar/templates/seminar/archiv/problem_uloha_tema.html
  4. 5
      seminar/templates/seminar/clanky/organizatorske_clanky.html
  5. 24
      seminar/templates/seminar/clanky/resitelske_clanky.html
  6. 4
      seminar/templates/seminar/clanky/submenu.html
  7. 4
      seminar/urls.py
  8. 29
      seminar/views.py

28
seminar/templates/seminar/archiv/problem.html

@ -4,31 +4,10 @@
{% block content %} {% block content %}
<div> <div>
{% if problem.cislo_zadani %} {% block problem %}
<h2> {% endblock %}
{% block nadpis1a %}{% block nadpis1b %}
{{ problem.nazev_typu }} {{ problem.kod_v_rocniku }}: {{ problem.nazev }} {{ problem.body_v_zavorce }}
{% endblock %}{% endblock %}
</h2>
<p>Zadáno v čísle <a href='{{ problem.cislo_zadani.verejne_url }}'>{{ problem.cislo_zadani.kod }}</a>. {% if user.is_staff %}
{% if problem.cislo_reseni %}
<p>Řešeno v čísle <a href='{{ problem.cislo_reseni.verejne_url }}'>{{ problem.cislo_reseni.kod }}</a>.
{% endif %}
{% else %}
<h2>Problém {{ problem.nazev }}</h2>
{% endif %}
<h3>Zadání</h3>
{{ problem.text_zadani |safe }}
{% if problem.text_reseni %}
<h3>Řešení</h3>
{{ problem.text_reseni |safe }}
{% endif %}
{# TODO Kontrola, zda je uzivatel org #}
{% if user.is_authenticated %}
<div class='mam-org-only'> <div class='mam-org-only'>
<h3>Text - org</h3> <h3>Text - org</h3>
@ -43,4 +22,3 @@
</div> </div>
{% endblock content %} {% endblock content %}

38
seminar/templates/seminar/archiv/problem_clanek.html

@ -0,0 +1,38 @@
{% extends "seminar/archiv/problem.html" %}
{% block problem %}
{% if problem.cislo_zadani %}
<h2>
{{ problem.nazev_typu }}:
{% block nadpis1a %}{% block nadpis1b %}
{{ problem.nazev }}
{% endblock %}{% endblock %}
</h2>
<div class='problem-autori'>
{% if problem.typ == 'res-clanek' %}
{# pozor na mezery #}
{% for r in reseni %}{% if not forloop.first %}, {% endif %}
{{ r.resitel.jmeno }} {{ r.resitel.prijmeni }}{% if r.body %} ({{ r.body }} b){% endif %}{% endfor %}
{% else %}
{{ problem.autor.first_name }}
{% if problem.autor.organizator.prezdivka %}
&bdquo;{{ problem.autor.organizator.prezdivka }}&ldquo;
{% endif %}
{{ problem.autor.last_name }}
{% endif %}
</div>
{% if problem.cislo_reseni %}
<p>Vyšlo v čísle <a href='{{ problem.cislo_reseni.verejne_url }}'>{{ problem.cislo_reseni.kod }}</a>.
{% endif %}
{% else %}
{# TODO ? #}
<h2>Problém {{ problem.nazev }}</h2>
{% endif %}
{{ problem.text_zadani |safe }}
{% endblock %}

27
seminar/templates/seminar/archiv/problem_uloha_tema.html

@ -0,0 +1,27 @@
{% extends "seminar/archiv/problem.html" %}
{% block problem %}
<h2>
{% block nadpis1a %}{% block nadpis1b %}
{{ problem.nazev_typu }} {{ problem.kod_v_rocniku }}: {{ problem.nazev }} {{ problem.body_v_zavorce }}
{% endblock %}{% endblock %}
</h2>
{% if problem.cislo_zadani %}
<p>Zadáno v čísle <a href='{{ problem.cislo_zadani.verejne_url }}'>{{ problem.cislo_zadani.kod }}</a>.
{% if problem.cislo_reseni %}
<p>Řešeno v čísle <a href='{{ problem.cislo_reseni.verejne_url }}'>{{ problem.cislo_reseni.kod }}</a>.
{% endif %}
{% else %}
{# TODO ? #}
<h2>Problém {{ problem.nazev }}</h2>
{% endif %}
<h3>Zadání</h3>
{{ problem.text_zadani |safe }}
{% if problem.text_reseni %}
<h3>Řešení</h3>
{{ problem.text_reseni |safe }}
{% endif %}
{% endblock %}

5
seminar/templates/seminar/clanky/organizatorske_clanky.html

@ -0,0 +1,5 @@
{% extends 'seminar/clanky/resitelske_clanky.html' %}
{% block nadpis1a %}{% block nadpis1b %}
Organizátorské články
{% endblock %}{% endblock %}

24
seminar/templates/seminar/clanky/resitelske_clanky.html

@ -0,0 +1,24 @@
{% extends 'base.html' %}
{% block content %}
<h2>
{% block nadpis1a %}{% block nadpis1b %}
Řešitelské články
{% endblock %}{% endblock %}
</h2>
{% for clanek in object_list %}
{% with clanek.cislo_zadani.rocnik.rocnik as rocnik %}
{% ifchanged rocnik %}
{% if not forloop.first %}</ul>{% endif %}
<h3>{{ rocnik }}. ročník</h3>
<ul>
{% endifchanged %}
<li>
<a href="{{ clanek.verejne_url }}">{{ clanek.nazev }}</a>
{% endwith %}
{% endfor %}
</ul>
{% endblock %}

4
seminar/templates/seminar/clanky/submenu.html

@ -2,8 +2,8 @@
<ul> <ul>
<li class="{% if selected == "uvod" %}selected{% endif %}"><a href="{{cesta}}/uvod/">Úvod</a> <li class="{% if selected == "uvod" %}selected{% endif %}"><a href="{{cesta}}/uvod/">Úvod</a>
{# TODO až budou <li class="{% if selected == "org" %}selected{% endif %}"><a href="{{cesta}}/org/">Organizátorské články</a> #} <li class="{% if selected == "org" %}selected{% endif %}"><a href="{{cesta}}/org/">Organizátorské články</a>
{# TODO až budou <li class="{% if selected == "resitel" %}selected{% endif %}"><a href="{{cesta}}/resitel/">Řešitelské články</a> #} <li class="{% if selected == "resitel" %}selected{% endif %}"><a href="{{cesta}}/resitel/">Řešitelské články</a>
<li class="{% if selected == "jak-psat-vedecky-clanek" %}selected{% endif %}"><a href="{{cesta}}/jak-psat-vedecky-clanek/">Jak napsat článek</a> <li class="{% if selected == "jak-psat-vedecky-clanek" %}selected{% endif %}"><a href="{{cesta}}/jak-psat-vedecky-clanek/">Jak napsat článek</a>
</ul> </ul>

4
seminar/urls.py

@ -22,6 +22,10 @@ urlpatterns = patterns('',
url(r'^$', views.TitulniStranaView.as_view(), name='titulni_strana'), url(r'^$', views.TitulniStranaView.as_view(), name='titulni_strana'),
url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'), url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'),
url(r'^clanky/resitel/$', views.ClankyResitelView.as_view(), name='clanky_resitel'),
url(r'^clanky/org/$', views.ClankyOrganizatorView.as_view(), name='clanky_organizator'),
url(r'^stav$', views.StavDatabazeView, name='stav_databaze'), url(r'^stav$', views.StavDatabazeView, name='stav_databaze'),
url(r'^aesop-export/mam-rocnik-(?P<prvni_rok>\d+)\.csv$', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'), url(r'^aesop-export/mam-rocnik-(?P<prvni_rok>\d+)\.csv$', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'),

29
seminar/views.py

@ -159,9 +159,23 @@ class RocnikView(generic.DetailView):
context['temata_v_rocniku'] = temata_v_rocniku context['temata_v_rocniku'] = temata_v_rocniku
return context return context
class ProblemView(generic.DetailView): class ProblemView(generic.DetailView):
model = Problem model = Problem
template_name = 'seminar/archiv/problem.html'
def _je_clanek(self, problem):
return problem.typ in [Problem.TYP_ORG_CLANEK, Problem.TYP_RES_CLANEK]
def get_template_names(self, **kwargs):
context = super(ProblemView, self).get_context_data(**kwargs)
return ['seminar/archiv/problem_' + ('clanek.html' if self._je_clanek(context['problem']) else 'uloha_tema.html')]
def get_context_data(self, **kwargs):
context = super(ProblemView, self).get_context_data(**kwargs)
if context['problem'].typ == Problem.TYP_RES_CLANEK:
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
return context
class RadekVysledkovky(object): class RadekVysledkovky(object):
pass pass
@ -271,6 +285,19 @@ class SoustredeniView(generic.DetailView):
model = Soustredeni model = Soustredeni
template_name = 'seminar/archiv/soustredeni.html' template_name = 'seminar/archiv/soustredeni.html'
### Články
class ClankyResitelView(generic.ListView):
model = Problem
template_name = 'seminar/clanky/resitelske_clanky.html'
queryset = Problem.objects.filter(typ=Problem.TYP_RES_CLANEK, stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
class ClankyOrganizatorView(generic.ListView):
model = Problem
template_name = 'seminar/clanky/organizatorske_clanky.html'
queryset = Problem.objects.filter(typ=Problem.TYP_ORG_CLANEK, stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
### Status ### Status
def StavDatabazeView(request): def StavDatabazeView(request):

Loading…
Cancel
Save