Merge branch 'test' into 'master'
Vylepšení korekturovátka
This commit is contained in:
commit
37030aab52
8 changed files with 58 additions and 7 deletions
|
@ -1,5 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block submenu %}
|
||||
{% include "korektury/submenu.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{# blok do kterého se nacita text, v pripade jinyhc templatu obalit vlastnim blokem #}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
{% extends "korektury/base.html" %}
|
||||
|
||||
{% block submenu %}
|
||||
{% with "help" as selected %}
|
||||
{% include "korektury/submenu.html" %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block title %} Nápověda ke korigovátku {% endblock title %}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
{% extends "korektury/base.html" %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block submenu %}
|
||||
{% include "korektury/submenu.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script%}
|
||||
<link rel="stylesheet" type="text/css" media="screen, projection" href="{% static "korektury/opraf-list.css" %}" />
|
||||
{% endblock %}
|
||||
|
|
13
korektury/templates/korektury/submenu.html
Normal file
13
korektury/templates/korektury/submenu.html
Normal file
|
@ -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 %}
|
||||
|
||||
|
|
@ -6,7 +6,8 @@ from . import views
|
|||
staff_member_required = user_passes_test(lambda u: u.is_staff)
|
||||
|
||||
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/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'),
|
||||
]
|
||||
|
|
|
@ -21,6 +21,28 @@ class KorekturyListView(generic.ListView):
|
|||
model = KorekturovanePDF
|
||||
template_name = 'korektury/seznam.html'
|
||||
|
||||
class KorekturyAktualniListView(KorekturyListView):
|
||||
def get_queryset(self, *args, **kwargs):
|
||||
queryset=super(KorekturyAktualniListView,self).get_queryset()
|
||||
queryset=queryset.exclude(status="zastarale")
|
||||
return queryset
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(KorekturyAktualniListView,self).get_context_data(**kwargs)
|
||||
context['selected'] = 'aktualni'
|
||||
return context
|
||||
|
||||
class KorekturyZastaraleListView(KorekturyListView):
|
||||
def get_queryset(self, *args, **kwargs):
|
||||
queryset=super(KorekturyZastaraleListView,self).get_queryset()
|
||||
queryset=queryset.filter(status="zastarale")
|
||||
return queryset
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(KorekturyZastaraleListView,self).get_context_data(**kwargs)
|
||||
context['selected'] = 'zastarale'
|
||||
return context
|
||||
|
||||
### Korektury
|
||||
class KorekturyView(generic.TemplateView):
|
||||
model = Oprava
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
u"""Vypiš username přihlášeného orga s daným session_key.
|
||||
|
||||
Příkaz pro manage.py, který ze vstupu přečte session_key (tak, jak je
|
||||
uložen v cookie sessionid) a pokud session existuje a příslušný přihlášený
|
||||
uživatel má právo přihlásit se do admina, vypíše jeho username.
|
||||
"""
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, *args, **options):
|
||||
session_key = raw_input()
|
||||
s = Session.objects.get(pk=session_key).get_decoded()
|
||||
user_id = s['_auth_user_id']
|
||||
|
|
|
@ -4,7 +4,7 @@ import datetime
|
|||
import os
|
||||
import random
|
||||
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management import call_command
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -14,10 +14,10 @@ import django.contrib.auth
|
|||
User = django.contrib.auth.get_user_model()
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = "Clear database and load testing data."
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, *args, **options):
|
||||
assert settings.DEBUG == True
|
||||
dbfile = settings.DATABASES['default']['NAME']
|
||||
if os.path.exists(dbfile):
|
||||
|
|
Loading…
Reference in a new issue