Browse Source

Korektury: rozdělení aktuálních a starých na dvě stránky

middleware_test
LEdoian 6 years ago
parent
commit
2e9ff73eac
  1. 4
      korektury/templates/korektury/base.html
  2. 7
      korektury/templates/korektury/help.html
  3. 12
      korektury/templates/korektury/seznam.html
  4. 13
      korektury/templates/korektury/submenu.html
  5. 3
      korektury/urls.py
  6. 13
      korektury/views.py

4
korektury/templates/korektury/base.html

@ -1,5 +1,9 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block submenu %}
{% include "korektury/submenu.html" %}
{% endblock %}
{% block content %} {% block content %}
{# blok do kterého se nacita text, v pripade jinyhc templatu obalit vlastnim blokem #} {# blok do kterého se nacita text, v pripade jinyhc templatu obalit vlastnim blokem #}
{% endblock %} {% endblock %}

7
korektury/templates/korektury/help.html

@ -1,4 +1,11 @@
{% extends "korektury/base.html" %} {% extends "korektury/base.html" %}
{% block submenu %}
{% with "help" as selected %}
{% include "korektury/submenu.html" %}
{% endwith %}
{% endblock %}
{% load staticfiles %} {% load staticfiles %}
{% block title %} Nápověda ke korigovátku {% endblock title %} {% block title %} Nápověda ke korigovátku {% endblock title %}

12
korektury/templates/korektury/seznam.html

@ -1,6 +1,18 @@
{% extends "korektury/base.html" %} {% extends "korektury/base.html" %}
{% load staticfiles %} {% load staticfiles %}
{% block submenu %}
{% if aktualni %}
{% with "aktualni" as selected %}
{% include "korektury/submenu.html" %}
{% endwith %}
{% else %}
{% with "zastarale" as selected %}
{% include "korektury/submenu.html" %}
{% endwith %}
{% endif %}
{% endblock %}
{% block script%} {% block script%}
<link rel="stylesheet" type="text/css" media="screen, projection" href="{% static "korektury/opraf-list.css" %}" /> <link rel="stylesheet" type="text/css" media="screen, projection" href="{% static "korektury/opraf-list.css" %}" />
{% endblock %} {% endblock %}

13
korektury/templates/korektury/submenu.html

@ -0,0 +1,13 @@
{% with "/korektury" as cesta %}
<div id='submenu'>
<ul>
<li class="{% if selected == "aktualni" %}selected{% endif %}"><a href="{{cesta}}/">Aktuální</a>
<li class="{% if selected == "zastarale" %}selected{% endif %}"><a href="{{cesta}}/zastarale/">Zastaralé</a>
<li class="{% if selected == "help" %}selected{% endif %}"><a href="{{cesta}}/help/">Nápověda</a>
</ul>
</div>
{% endwith %}

3
korektury/urls.py

@ -6,7 +6,8 @@ from . import views
staff_member_required = user_passes_test(lambda u: u.is_staff) staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = [ urlpatterns = [
url(r'^korektury/$', staff_member_required(views.KorekturyListView.as_view()), name='korektury-list'), url(r'^korektury/$', staff_member_required(views.KorekturyAktualniListView.as_view()), name='korektury-list'),
url(r'^korektury/zastarale/$', staff_member_required(views.KorekturyZastaraleListView.as_view()), name='korektury-list-zastarale'),
url(r'^korektury/(?P<pdf>\d+)/$', staff_member_required(views.KorekturyView.as_view()), name='korektury'), url(r'^korektury/(?P<pdf>\d+)/$', staff_member_required(views.KorekturyView.as_view()), name='korektury'),
url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'), url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'),
] ]

13
korektury/views.py

@ -21,6 +21,19 @@ class KorekturyListView(generic.ListView):
model = KorekturovanePDF model = KorekturovanePDF
template_name = 'korektury/seznam.html' template_name = 'korektury/seznam.html'
class KorekturyAktualniListView(KorekturyListView):
def __init__ (self):
self.queryset=self.get_queryset().exclude(status="zastarale")
def get_context_data(self, **kwargs):
context = super(KorekturyAktualniListView,self).get_context_data(**kwargs)
context['aktualni'] = True
return context
class KorekturyZastaraleListView(KorekturyListView):
def __init__ (self):
self.queryset=self.get_queryset().filter(status="zastarale")
### Korektury ### Korektury
class KorekturyView(generic.TemplateView): class KorekturyView(generic.TemplateView):
model = Oprava model = Oprava

Loading…
Cancel
Save