Nove sketche views pro seminar
This commit is contained in:
parent
f56a37edfa
commit
467c7c53b3
9 changed files with 75 additions and 24 deletions
|
@ -18,7 +18,7 @@
|
|||
</div>
|
||||
<div class='row'>
|
||||
<div class='col-md-4' style=''>
|
||||
Menu
|
||||
{% include "menu.html" %}
|
||||
</div>
|
||||
<div class='col-md-8'>
|
||||
{% block content %}
|
||||
|
|
|
@ -1,18 +1,3 @@
|
|||
{% load i18n menu_tags cache %}
|
||||
{% load i18n cache %}
|
||||
|
||||
{% for child in children %}
|
||||
|
||||
|
||||
<li class="{% if child.ancestor %}ancestor{% endif %}{% if child.selected %} active{% endif %}{% if child.children %} dropdown{% endif %}">
|
||||
{% if child.children %}<a class="dropdown-toggle" data-toggle="dropdown" href="#">{{ child.get_menu_title }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<a href="{{ child.get_absolute_url }}"><span>{{ child.get_menu_title }}</span></a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
||||
{% if class and forloop.last and not forloop.parentloop %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
MENU
|
||||
|
|
|
@ -7,6 +7,7 @@ from django.conf import settings
|
|||
urlpatterns = i18n_patterns('',
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)), # NOQA
|
||||
url(r'^r/', include('django.conf.urls.shortcut')),
|
||||
url(r'^admin_tools/', include('admin_tools.urls')),
|
||||
url(r'^ckeditor/', include('ckeditor.urls')),
|
||||
url(r'^', include('seminar.urls')),
|
||||
|
|
|
@ -9,6 +9,7 @@ from django.utils import timezone
|
|||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from django_countries.fields import CountryField
|
||||
from solo.models import SingletonModel
|
||||
|
@ -161,6 +162,12 @@ class Rocnik(models.Model):
|
|||
else:
|
||||
return force_unicode(self.rocnik)
|
||||
|
||||
def verejna_cisla(self):
|
||||
return [c for c in self.cisla.all() if c.verejne()]
|
||||
|
||||
def druhy_rok(self):
|
||||
return self.prvni_rok + 1
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Cislo(models.Model):
|
||||
|
||||
|
@ -173,7 +180,7 @@ class Cislo(models.Model):
|
|||
# Interní ID
|
||||
id = models.AutoField(primary_key = True)
|
||||
|
||||
rocnik = models.ForeignKey(Rocnik, verbose_name=u'ročník')
|
||||
rocnik = models.ForeignKey(Rocnik, verbose_name=u'ročník', related_name='cisla')
|
||||
|
||||
cislo = models.CharField(u'název čísla', max_length=32,
|
||||
help_text=u'Většinou jen "1", vyjímečně "7-8", lexikograficky určije pořadí v ročníku!')
|
||||
|
@ -191,6 +198,12 @@ class Cislo(models.Model):
|
|||
def __str__(self):
|
||||
return force_unicode(u'%s' % (self.kod(),))
|
||||
|
||||
def verejne(self):
|
||||
return (self.datum_vydani and self.datum_vydani <= datetime.date.today())
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('seminar.cislo', args=[str(self.id)])
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Problem(models.Model):
|
||||
|
@ -252,6 +265,13 @@ class Problem(models.Model):
|
|||
def __str__(self):
|
||||
return force_unicode(u'%s (%s)' % (self.nazev, self.stav))
|
||||
|
||||
def kod_v_rocniku(self):
|
||||
if self.typ == self.TYP_ULOHA:
|
||||
return force_unicode(u"%s.u%s" % (self.cislo_zadani.cislo, self.kod,))
|
||||
if self.typ == self.TYP_TEMA:
|
||||
return force_unicode(u"t%s" % (self.kod,))
|
||||
return ''
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Reseni(models.Model):
|
||||
|
|
|
@ -3,14 +3,32 @@
|
|||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h2>Číslo {{ cislo }} [id {{ cislo.id}}]</h2>
|
||||
<h2>Číslo {{ cislo }}</h2>
|
||||
|
||||
<p>Ročník {% url 'seminar.rocnik' cislo.rocnik.id %}
|
||||
|
||||
<h3>Zadané problémy</h3>
|
||||
<ul>
|
||||
{% for p in cislo.zadane_problemy.all %}
|
||||
<li><a href='{% url 'seminar.problem' p.id %}'>{{ p.kod_v_rocniku }} {{ p.nazev }} ({{ p.body }}b)</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3>Řešené problémy</h3>
|
||||
<ul>
|
||||
{% for p in cislo.resene_problemy.all %}
|
||||
<li><a href='{% url 'seminar.problem' p.id %}'>{{ p.kod_v_rocniku }} {{ p.nazev }} ({{ p.body }}b)</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3>Výsledkovka</h3>
|
||||
|
||||
<table class='vysledkovka'>
|
||||
<tr class='border-b'>
|
||||
<th class='border-r'>#
|
||||
<th class='border-r'>Jméno
|
||||
{% for p in problemy %}
|
||||
<th class='border-r'>{{ p.cislo_zadani.cislo }}.{{ p.kod }}
|
||||
<th class='border-r'><a href="{% url 'seminar.problem' p.id %}">{{ p.cislo_zadani.cislo }}.{{ p.kod }}</a>
|
||||
{% endfor %}
|
||||
<th class='border-r'>Sum
|
||||
<th>Celkem
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h2>Problém {{ problem.nazev }}</h2>
|
||||
<h2>Problém {{ problem.kod_v_rocniku }} {{ problem.nazev }}</h2>
|
||||
|
||||
<p>Zadáno v čísle <a href='{% url 'seminar.cislo' problem.cislo_zadani.id %}'>{{ problem.cislo_zadani.kod }}</a>,
|
||||
<p>řešeno v čísle <a href='{% url 'seminar.cislo' problem.cislo_reseni.id %}'>{{ problem.cislo_reseni.kod }}</a>,
|
||||
|
||||
|
||||
<h3>Text</h3>
|
||||
{{ problem.text_problemu |safe }}
|
||||
|
|
18
seminar/templates/seminar/rocnik.html
Normal file
18
seminar/templates/seminar/rocnik.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% extends "base.html" %}
|
||||
{% load staticfiles sekizai_tags %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h2>Ročník {{ rocnik.roman }}</h2>
|
||||
|
||||
<p>Ročník číslo {{ rocnik.rocnik }} ({{ rocnik.prvni_rok }}/{{ rocnik.druhy_rok }})
|
||||
|
||||
<ul>
|
||||
{% for c in rocnik.verejna_cisla %}
|
||||
<li><a href="{% url 'seminar.cislo' c.id %}">Číslo {{ c.kod }}</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -2,7 +2,8 @@ from django.conf.urls import patterns, url
|
|||
from . import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^problem/(?P<pk>\d+)/$', views.ProblemView.as_view(), name='seminar.problem'),
|
||||
url(r'^rocnik/(?P<pk>\d+)/$', views.RocnikView.as_view(), name='seminar.rocnik'),
|
||||
url(r'^cislo/(?P<pk>\d+)/$', views.CisloView.as_view(), name='seminar.cislo'),
|
||||
url(r'^problem/(?P<pk>\d+)/$', views.ProblemView.as_view(), name='seminar.problem'),
|
||||
url(r'^zadani/$', 'seminar.views.AktualZadaniView'),
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@ 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 .models import Problem, Cislo, Reseni, VysledkyKCislu, Nastaveni
|
||||
from .models import Problem, Cislo, Reseni, VysledkyKCislu, Nastaveni, Rocnik
|
||||
|
||||
|
||||
def AktualZadaniView(request):
|
||||
|
@ -12,6 +12,10 @@ def AktualZadaniView(request):
|
|||
},
|
||||
)
|
||||
|
||||
class RocnikView(generic.DetailView):
|
||||
model = Rocnik
|
||||
template_name = 'seminar/rocnik.html'
|
||||
|
||||
class ProblemView(generic.DetailView):
|
||||
model = Problem
|
||||
template_name = 'seminar/problem.html'
|
||||
|
|
Loading…
Reference in a new issue