Merge branch 'master' of atrey:/akce/MaM/MaMweb/mamweb
* 'master' of atrey:/akce/MaM/MaMweb/mamweb: (24 commits) Smazaný termín pro účast na soustředění v AktualniZadani.html. A. Neukládej k organizátorovi fotku, nezměnila-li se Obrázky v hlavičce převedeny na jpg NOC | otoceni fotky Admin: zobrazuje celé jméno, předvyplňuje, ukládá Admin: změna způsobu zobrazování celého jména Admin: ve výběru uživatele zobraz celé jméno test | nasazovani -- problem s pravy Admin: předvyplnění autora u problémů Zobrazuj jen zadaná a veřejná témata Zadání: aktuální výsledkovka Noc | nocni tema Middleware, krery zjistuje jestli je NOC Odchyceni vyjimky u autocomplete Změna Organizator.studuje: obsahuje i činnost 400 a 403 se stejnym obrazkem jako 500 test | allow hosts Fix: APPEND_SLASH = True funguje oprava allow hosts na testu Allow hosts na testu ... Conflicts: Makefile
12
mamweb/context_processors.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
from datetime import datetime, date
|
||||
|
||||
def vzhled(request):
|
||||
''' Podle casu prida do templatu, zdali je nebo neni noc '''
|
||||
hodin = datetime.now().hour
|
||||
if (hodin <= 6) or (hodin >= 20):
|
||||
noc = True
|
||||
else:
|
||||
noc = False
|
||||
return {'noc' : noc}
|
||||
|
36
mamweb/middleware.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
from django.http import HttpResponse
|
||||
from datetime import datetime, date
|
||||
|
||||
class vzhled:
|
||||
|
||||
def process_request(self, request):
|
||||
return None
|
||||
|
||||
def process_view(self, request, view_func, view_args, view_kwargs):
|
||||
#print "====== process_request ======"
|
||||
#print view_func
|
||||
#print view_args
|
||||
#print view_kwargs
|
||||
#print "============================="
|
||||
return None
|
||||
|
||||
def process_template_response(self, request, response):
|
||||
hodin = datetime.now().hour
|
||||
if (hodin <= 6) or (hodin >= 14): # TODO 20
|
||||
response.context_data['noc'] = True
|
||||
else:
|
||||
response.context_data['noc'] = False
|
||||
return response
|
||||
|
||||
def process_response(self, request, response):
|
||||
#hodin = datetime.now().hour
|
||||
#if (hodin <= 6) or (hodin >= 14): # TODO 20
|
||||
#response.context_data['noc'] = True
|
||||
#else:
|
||||
#response.context_data['noc'] = False
|
||||
return response
|
||||
|
||||
|
||||
##def process_exception(request, exception):
|
||||
#pass
|
|
@ -78,6 +78,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||
'django.core.context_processors.tz',
|
||||
'sekizai.context_processors.sekizai',
|
||||
'django.core.context_processors.static',
|
||||
'mamweb.context_processors.vzhled',
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
|
|
|
@ -25,11 +25,11 @@ INSTALLED_APPS += (
|
|||
SECRET_KEY = ')^u=i65*zmr_k53a*@f4q_+ji^o@!pgpef*5&8c7zzv9l+zo)n'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
|
||||
TEMPLATE_DEBUG = True
|
||||
TEMPLATE_DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*.mam.mff.cuni.cz']
|
||||
ALLOWED_HOSTS = ['*.mam.mff.cuni.cz', 'atrey.karlin.mff.cuni.cz', 'mam.mff.cuni.cz']
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
||||
|
@ -45,6 +45,14 @@ DATABASES = {
|
|||
},
|
||||
}
|
||||
|
||||
import os
|
||||
|
||||
SERVER_EMAIL = 'mamweb-test-errors@mam.mff.cuni.cz'
|
||||
ADMINS = [
|
||||
('Petr Pecha', 'nejlepsitextovyeditorjevim@gmail.com'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -58,16 +58,24 @@ h2 {
|
|||
#header {
|
||||
position: relative;
|
||||
font-size: 250%;
|
||||
background: url("../images/header-bg-uvod.png") no-repeat center top;
|
||||
background: url("../images/header-bg-uvod.jpg") no-repeat center top;
|
||||
height: 255px;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
#header.cojemam { background-image: url("../images/header-bg-uvod.png"); }
|
||||
#header.soustredeni { background-image: url("../images/header-bg-soustredeni.png"); }
|
||||
#header.zadani { background-image: url("../images/header-bg-zadani.png"); }
|
||||
#header.clanky { background-image: url("../images/header-bg-clanek.png"); }
|
||||
#header.archiv { background-image: url("../images/header-bg-archiv.png"); }
|
||||
|
||||
#header.cojemam { background-image: url("../images/header-bg-uvod.jpg"); }
|
||||
#header.soustredeni { background-image: url("../images/header-bg-soustredeni.jpg"); }
|
||||
#header.zadani { background-image: url("../images/header-bg-zadani.jpg"); }
|
||||
#header.clanky { background-image: url("../images/header-bg-clanek.jpg"); }
|
||||
#header.archiv { background-image: url("../images/header-bg-archiv.jpg"); }
|
||||
|
||||
#header.NOC {background-image: url("../images/header-bg-uvod-NOC.jpg"); }
|
||||
#header.NOCcojemam { background-image: url("../images/header-bg-uvod-NOC.jpg"); }
|
||||
#header.NOCsoustredeni { background-image: url("../images/header-bg-soustredeni-NOC.jpg"); }
|
||||
#header.NOCzadani { background-image: url("../images/header-bg-zadani-NOC.jpg"); }
|
||||
#header.NOCclanky { background-image: url("../images/header-bg-clanek-NOC.jpg"); }
|
||||
#header.NOCarchiv { background-image: url("../images/header-bg-archiv-NOC.jpg"); }
|
||||
|
||||
#header img.logo {
|
||||
position: absolute;
|
||||
|
|
BIN
mamweb/static/images/header-bg-archiv-NOC.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
mamweb/static/images/header-bg-archiv.jpg
Normal file
After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 400 KiB |
BIN
mamweb/static/images/header-bg-clanek-NOC.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
mamweb/static/images/header-bg-clanek.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 519 KiB |
BIN
mamweb/static/images/header-bg-odevzdat-NOC.jpg
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
mamweb/static/images/header-bg-soustredeni-NOC.jpg
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
mamweb/static/images/header-bg-soustredeni.jpg
Normal file
After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 562 KiB |
BIN
mamweb/static/images/header-bg-uvod-NOC.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
mamweb/static/images/header-bg-uvod.jpg
Normal file
After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 512 KiB |
BIN
mamweb/static/images/header-bg-zadani-NOC.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
mamweb/static/images/header-bg-zadani.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 456 KiB |
BIN
mamweb/static/images/header-bg.jpg
Normal file
After Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 679 KiB |
19
mamweb/templates/400.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block content %}
|
||||
<h2>
|
||||
{% block nadpis1a %}{% block nadpis1b %}
|
||||
O-jo-jo-jo-joj
|
||||
{% endblock %}{% endblock %}
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
Chybička se vloudila.
|
||||
Zkuste přejít na <a href="/">titulní stránku</a>
|
||||
nebo se podívat na <a href="/zadani/aktualni/">aktuální zadání</a>.
|
||||
</p>
|
||||
<img src="{% static '500.png' %}">
|
||||
{% endblock %}
|
||||
|
19
mamweb/templates/403.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block content %}
|
||||
<h2>
|
||||
{% block nadpis1a %}{% block nadpis1b %}
|
||||
Vrrrrrrrrr
|
||||
{% endblock %}{% endblock %}
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
Tady pravděpodobně nemáte co dělat.
|
||||
Zkuste přejít na <a href="/">titulní stránku</a>
|
||||
nebo se podívat na <a href="/zadani/aktualni/">aktuální zadání</a>.
|
||||
</p>
|
||||
<img src="{% static '500.png' %}">
|
||||
{% endblock %}
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<a href='/'>
|
||||
<div id="header" class="{% block header %}{% endblock %}">
|
||||
<div id="header" class="{% if noc %}NOC{% endif %}{% block header %}{% endblock %}">
|
||||
<img class="logo" src="{% static 'images/logo.png' %}" />
|
||||
<!--<h1>{% block nadpis1b %}Nadpis 1. úrovně{% endblock %}</h1>-->
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
{% endblock %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div>
|
||||
{{ flatpage.content }}
|
||||
</div>
|
||||
|
|
|
@ -19,8 +19,6 @@ urlpatterns = patterns('',
|
|||
url(r'^comments_dj/', include('django_comments.urls')),
|
||||
url(r'^comments_fl/', include('fluent_comments.urls')),
|
||||
|
||||
# Obsah - flatpages
|
||||
url(r'^', include('django.contrib.flatpages.urls')), # Pozor: musi byt posledni
|
||||
)
|
||||
|
||||
# This is only needed when using runserver.
|
||||
|
|
|
@ -9,10 +9,26 @@ from ckeditor.widgets import CKEditorWidget
|
|||
from django.db.models import Count
|
||||
from django.db import models
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky, Organizator
|
||||
import autocomplete_light
|
||||
|
||||
|
||||
class UserModelChoiceField(forms.ModelChoiceField):
|
||||
u"""Vlastní ModelChoiceField pro uživatele. Zobrazí kromě loginu i jméno.
|
||||
"""
|
||||
def label_from_instance(self, obj):
|
||||
return u"{} ({})".format(obj.get_full_name(), obj.username)
|
||||
|
||||
def get_form_predvypln_autora(self, request, obj=None, *args, **kwargs):
|
||||
u"""get_form fce pro Adminy. Předvyplňí přihlášeného uživatele jako autora.
|
||||
"""
|
||||
form = super(self.__class__, self).get_form(request, *args, **kwargs)
|
||||
form.base_fields['autor'].initial = request.user.id
|
||||
return form
|
||||
|
||||
|
||||
def make_set_action(atribut, hodnota, nazev):
|
||||
u"""
|
||||
Pomocnik pro rychle vytvareni hromadnych admin akci ktere jen nastavuji
|
||||
|
@ -271,13 +287,14 @@ admin.site.register(Reseni, ReseniAdmin)
|
|||
|
||||
from autocomplete_light.contrib.taggit_field import TaggitField, TaggitWidget
|
||||
|
||||
#TODO: Autocomplete autor/opravovatel
|
||||
|
||||
class ProblemAdminForm(forms.ModelForm):
|
||||
text_zadani = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Problem, 'text_zadani'))
|
||||
text_reseni = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Problem, 'text_reseni'))
|
||||
text_org = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Problem, 'text_org'))
|
||||
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False)
|
||||
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
||||
opravovatel = UserModelChoiceField(User.objects.filter(is_staff=True), required=False)
|
||||
class Meta:
|
||||
model = Problem
|
||||
exclude = []
|
||||
|
@ -302,13 +319,16 @@ class ProblemAdmin(reversion.VersionAdmin):
|
|||
return obj.pocet_reseni
|
||||
|
||||
class ProblemNavrhAdmin(ProblemAdmin):
|
||||
list_display = ['nazev', 'typ', 'stav', 'autor', 'timestamp']
|
||||
list_filter = ['typ', 'stav', 'timestamp']
|
||||
list_display = ['nazev', 'typ', 'zamereni', 'stav', 'autor', 'timestamp']
|
||||
list_filter = ['typ', 'zamereni', 'timestamp', 'stav']
|
||||
|
||||
def get_queryset(self, request):
|
||||
qs = super(ProblemNavrhAdmin, self).get_queryset(request)
|
||||
return qs.filter(stav__in=[Problem.STAV_NAVRH, Problem.STAV_SMAZANY])
|
||||
|
||||
get_form = get_form_predvypln_autora
|
||||
|
||||
|
||||
create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Problém (návrh)', verbose_name_plural=u'Problémy (návrhy)')
|
||||
|
||||
class ProblemZadanyAdmin(ProblemAdmin):
|
||||
|
@ -320,6 +340,8 @@ class ProblemZadanyAdmin(ProblemAdmin):
|
|||
qs = super(ProblemZadanyAdmin, self).get_queryset(request)
|
||||
return qs.filter(stav=Problem.STAV_ZADANY).annotate(pocet_reseni=Count('reseni'))
|
||||
|
||||
get_form = get_form_predvypln_autora
|
||||
|
||||
create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'Problém (zadaný)', verbose_name_plural=u'Problémy (zadané)')
|
||||
|
||||
#admin.site.register(Problem, ProblemAdmin)
|
||||
|
@ -356,6 +378,8 @@ admin.site.register(Soustredeni, SoustredeniAdmin)
|
|||
class NovinkyAdminForm(forms.ModelForm):
|
||||
text = forms.CharField(widget=CKEditorWidget(), required=False,
|
||||
**field_labels(Novinky, 'text'))
|
||||
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
||||
|
||||
class Meta:
|
||||
model = Novinky
|
||||
exclude = []
|
||||
|
@ -380,13 +404,7 @@ class NovinkyAdmin(admin.ModelAdmin):
|
|||
list_display = ['datum', 'autor', 'text', 'zverejneno', 'obrazek']
|
||||
actions = [zverejnit_novinky, zneverejnit_novinky]
|
||||
|
||||
# předvyplnění přihlášeného uživatele jako autora novinky
|
||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
||||
if db_field.name == 'autor':
|
||||
kwargs['initial'] = request.user.id
|
||||
return super(NovinkyAdmin, self).formfield_for_foreignkey(
|
||||
db_field, request, **kwargs
|
||||
)
|
||||
get_form = get_form_predvypln_autora
|
||||
|
||||
|
||||
admin.site.register(Novinky, NovinkyAdmin)
|
||||
|
|
|
@ -77,7 +77,12 @@ class ProblemAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|||
|
||||
def choice_label(self, p):
|
||||
if p.stav == Problem.STAV_ZADANY:
|
||||
return u"%s (%s, %s.%s)" % (p.nazev, p.typ, p.cislo_zadani.rocnik.rocnik, p.kod_v_rocniku())
|
||||
popisek = ""
|
||||
try:
|
||||
popisek = u"%s (%s, %s.%s)" % (p.nazev, p.typ, p.cislo_zadani.rocnik.rocnik, p.kod_v_rocniku())
|
||||
except:
|
||||
popisek = u"%s (%s, %s.%s)" % (p.nazev, p.typ, p.stav)
|
||||
return popisek
|
||||
else:
|
||||
return u"%s (%s, %s)" % (p.nazev, p.typ, p.stav)
|
||||
|
||||
|
|
20
seminar/migrations/0033_organizator_studuje_popisek.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('seminar', '0032_cislo_pdf_blank_typos'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='organizator',
|
||||
name='studuje',
|
||||
field=models.CharField(help_text=b"Nap\xc5\x99. 'Studuje Obecnou fyziku (Bc.), 3. ro\xc4\x8dn\xc3\xadk', 'Vystudovala Diskr\xc3\xa9tn\xc3\xad modely a algoritmy (Mgr.)' nebo 'P\xc5\x99edn\xc3\xa1\xc5\xa1\xc3\xad na MFF'", max_length=256, null=True, verbose_name=b'Studium aj.', blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -772,8 +772,11 @@ class Organizator(models.Model):
|
|||
null = True, blank = True)
|
||||
organizuje_do_roku = models.IntegerField('Organizuje do roku',
|
||||
null = True, blank = True)
|
||||
studuje = models.CharField('Studuje', max_length = 256,
|
||||
null = True, blank = True)
|
||||
studuje = models.CharField('Studium aj.', max_length = 256,
|
||||
null = True, blank = True,
|
||||
help_text="Např. 'Studuje Obecnou fyziku (Bc.), 3. ročník', "
|
||||
"'Vystudovala Diskrétní modely a algoritmy (Mgr.)' nebo "
|
||||
"'Přednáší na MFF'")
|
||||
strucny_popis_organizatora = models.TextField('Stručný popis organizátora',
|
||||
null = True, blank = True)
|
||||
foto = models.ImageField('Fotografie organizátora',
|
||||
|
@ -790,11 +793,14 @@ class Organizator(models.Model):
|
|||
verbose_name_plural = 'Organizátoři'
|
||||
|
||||
def save(self):
|
||||
if self.id is not None:
|
||||
puvodni = Organizator.objects.get(id=self.id)
|
||||
if self.foto:
|
||||
original = Image.open(self.foto)
|
||||
jmeno = os.path.basename(self.foto.file.name)
|
||||
Organizator._vyrobMiniaturu(original, jmeno, 500, self.foto)
|
||||
Organizator._vyrobMiniaturu(original, jmeno, 200, self.foto_male)
|
||||
if not puvodni or puvodni.foto != self.foto:
|
||||
original = Image.open(self.foto)
|
||||
jmeno = os.path.basename(self.foto.file.name)
|
||||
Organizator._vyrobMiniaturu(original, jmeno, 500, self.foto)
|
||||
Organizator._vyrobMiniaturu(original, jmeno, 200, self.foto_male)
|
||||
super(Organizator, self).save()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -29,38 +29,8 @@
|
|||
{% endif %}
|
||||
|
||||
{% if vysledkovka %}
|
||||
<h3>Výsledkovka</h3>
|
||||
<table class='vysledkovka'>
|
||||
<tr class='border-b'>
|
||||
<th class='border-r'>#
|
||||
<th class='border-r'>Jméno
|
||||
<th class='border-r'>R.
|
||||
<th class='border-r'>Odjakživa
|
||||
{% for c in rocnik.verejna_cisla %}
|
||||
{% if c.verejna_vysledkovka %}
|
||||
<th class='border-r'><a href="{{ c.verejne_url }}">
|
||||
{{c.rocnik.rocnik}}.{{ c.cislo }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<th class='border-r'>Celkem
|
||||
|
||||
{% for rv in vysledkovka %}
|
||||
<tr>
|
||||
<td class='border-r'>{% autoescape off %}{{ rv.poradi }}{% endautoescape %}
|
||||
<th class='border-r'>
|
||||
{% if rv.titul %}
|
||||
{{ rv.titul }}<sup>MM</sup>
|
||||
{% endif %}
|
||||
{{ rv.resitel.plne_jmeno }}
|
||||
<td class='border-r'>{{ rv.resitel.rocnik }}
|
||||
<td class='border-r'>{{ rv.body_odjakziva }}
|
||||
{% for b in rv.body_cisla %}
|
||||
<td class='border-r'>{{ b }}
|
||||
{% endfor %}
|
||||
<td class='border-r'><b>{{ rv.body_rocnik }}</b>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<h3>Výsledková listina</h3>
|
||||
{% include "seminar/vysledkovka_rocnik.html" %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
Aktivní v letech {{org.organizuje_od_roku | default:"?" }}–{{org.organizuje_do_roku | default:"?" }}
|
||||
{% endif %}
|
||||
{% if org.studuje %}
|
||||
<li>Studuje: {{org.studuje}}
|
||||
<li>{{org.studuje}}
|
||||
{% endif %}
|
||||
{% if org.user.email %}
|
||||
<li>Pošta:
|
||||
|
|
31
seminar/templates/seminar/vysledkovka_rocnik.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<table class='vysledkovka'>
|
||||
<tr class='border-b'>
|
||||
<th class='border-r'>#
|
||||
<th class='border-r'>Jméno
|
||||
<th class='border-r'>R.
|
||||
<th class='border-r'>Odjakživa
|
||||
{% for c in rocnik.verejna_cisla %}
|
||||
{% if c.verejna_vysledkovka %}
|
||||
<th class='border-r'><a href="{{ c.verejne_url }}">
|
||||
{{c.rocnik.rocnik}}.{{ c.cislo }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<th class='border-r'>Celkem
|
||||
|
||||
{% for rv in vysledkovka %}
|
||||
<tr>
|
||||
<td class='border-r'>{% autoescape off %}{{ rv.poradi }}{% endautoescape %}
|
||||
<th class='border-r'>
|
||||
{% if rv.titul %}
|
||||
{{ rv.titul }}<sup>MM</sup>
|
||||
{% endif %}
|
||||
{{ rv.resitel.plne_jmeno }}
|
||||
<td class='border-r'>{{ rv.resitel.rocnik }}
|
||||
<td class='border-r'>{{ rv.body_odjakziva }}
|
||||
{% for b in rv.body_cisla %}
|
||||
<td class='border-r'>{{ b }}
|
||||
{% endfor %}
|
||||
<td class='border-r'><b>{{ rv.body_rocnik }}</b>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
19
seminar/templates/seminar/zadani/AktualniVysledkovka.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% extends "seminar/zadani/base.html" %}
|
||||
|
||||
{% block submenu %}
|
||||
{% with "vysledkova-listina" as selected %}
|
||||
{% include 'seminar/zadani/submenu.html' %}
|
||||
{% endwith %}
|
||||
{% endblock submenu %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
{% with nastaveni.aktualni_rocnik as rocnik %}
|
||||
<h2>Výsledky</h2>
|
||||
{% if vysledkovka %}
|
||||
{% include "seminar/vysledkovka_rocnik.html" %}
|
||||
{% else %}
|
||||
V tomto ročníku zatím žádné výsledky nejsou
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endblock content %}
|
|
@ -18,8 +18,6 @@
|
|||
{% if ac.zadane_problemy.all %}
|
||||
<div class="zadani_azad_termin">
|
||||
Termín odeslání {{ac.cislo}}. série: {{ac.datum_deadline}}
|
||||
<br>
|
||||
Termín odeslání 1. série pro účast na soustředění: 21. září 2015
|
||||
</div>
|
||||
{% endif %}
|
||||
{#TODO a co speciální deadline pro účast na soustředění? #}
|
||||
|
|
|
@ -19,6 +19,7 @@ urlpatterns = patterns('',
|
|||
|
||||
url(r'^zadani/aktualni/$', views.AktualniZadaniView, name='seminar_aktualni_zadani'),
|
||||
url(r'^zadani/temata/$', views.ZadaniTemataView, name='seminar_temata'),
|
||||
url(r'^zadani/vysledkova-listina/$', views.ZadaniAktualniVysledkovkaView, name='seminar_vysledky'),
|
||||
url(r'^$', views.TitulniStranaView.as_view(), name='titulni_strana'),
|
||||
url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'),
|
||||
|
||||
|
|
111
seminar/views.py
|
@ -15,17 +15,22 @@ from datetime import timedelta, date, datetime
|
|||
from itertools import groupby
|
||||
|
||||
|
||||
def verejna_temata(rocnik):
|
||||
"""Vrací queryset zveřejněných témat v daném ročníku.
|
||||
"""
|
||||
return Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=rocnik, cislo_zadani__verejne_db=True).order_by('kod')
|
||||
|
||||
|
||||
def AktualniZadaniView(request):
|
||||
nastaveni = get_object_or_404(Nastaveni)
|
||||
problemy = Problem.objects.filter(cislo_zadani=nastaveni.aktualni_cislo).filter(stav = 'zadany')
|
||||
ulohy = problemy.filter(typ = 'uloha').order_by('kod')
|
||||
serialy = problemy.filter(typ = 'serial').order_by('kod')
|
||||
temata = problemy.filter(typ = 'tema').order_by('kod')
|
||||
jednorazove_problemy = [ulohy, serialy]
|
||||
return render(request, 'seminar/zadani/AktualniZadani.html',
|
||||
{'nastaveni': nastaveni,
|
||||
'jednorazove_problemy': jednorazove_problemy,
|
||||
'temata': temata,
|
||||
'temata': verejna_temata(nastaveni.aktualni_rocnik),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -33,10 +38,21 @@ def ZadaniTemataView(request):
|
|||
nastaveni = get_object_or_404(Nastaveni)
|
||||
return render(request, 'seminar/zadani/Temata.html',
|
||||
{
|
||||
'temata': Problem.objects.filter(typ=Problem.TYP_TEMA, stav=Problem.STAV_ZADANY, cislo_zadani__rocnik=nastaveni.aktualni_rocnik).order_by('kod'),
|
||||
'temata': verejna_temata(nastaveni.aktualni_rocnik)
|
||||
}
|
||||
)
|
||||
|
||||
def ZadaniAktualniVysledkovkaView(request):
|
||||
nastaveni = get_object_or_404(Nastaveni)
|
||||
vysledkovka = vysledkovka_rocniku(nastaveni.aktualni_rocnik)
|
||||
return render(request, 'seminar/zadani/AktualniVysledkovka.html',
|
||||
{
|
||||
'nastaveni': nastaveni,
|
||||
'vysledkovka': vysledkovka,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
### Titulni strana
|
||||
|
||||
class TitulniStranaView(generic.ListView):
|
||||
|
@ -110,6 +126,53 @@ def sloupec_s_poradim(vysledky):
|
|||
return poradi_l
|
||||
|
||||
|
||||
def vysledkovka_rocniku(rocnik):
|
||||
"""Přebírá ročník (např. context["rocnik"]) a vrací výsledkovou listinu ve
|
||||
formě vhodné pro šablonu "seminar/vysledkovka_rocniku.html"
|
||||
"""
|
||||
|
||||
#vyberu vsechny verejne vysledky z rocniku
|
||||
cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__verejna_vysledkovka=True, cislo__rocnik=rocnik).order_by('cislo')
|
||||
|
||||
#pokud žádné nejsou, výsledkovka se nezobrazí
|
||||
if not cisla_v_rocniku:
|
||||
return None
|
||||
|
||||
#vybere vsechny vysledky z posledniho verejneho cisla a setridi sestupne dle bodu
|
||||
vysledky = list(cisla_v_rocniku.filter(cislo = cisla_v_rocniku[0].cislo).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno').select_related('resitel'))
|
||||
|
||||
vysledkovka = []
|
||||
|
||||
# doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
|
||||
for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
|
||||
v.poradi = poradi
|
||||
v.resitel.rocnik = v.resitel.rocnik(rocnik)
|
||||
|
||||
verejne_vysl_odjakziva = VysledkyKCisluOdjakziva.objects.filter(cislo__verejna_vysledkovka=True, cislo__rocnik=rocnik, cislo=cisla_v_rocniku[0].cislo)
|
||||
|
||||
v.body_odjakziva = verejne_vysl_odjakziva.filter(resitel = v.resitel)[0].body
|
||||
v.titul = v.resitel.get_titul(v.body_odjakziva)
|
||||
v.body_rocnik = v.body
|
||||
v.body_cisla = []
|
||||
|
||||
#pokud pro dany rok a cislo nema resitel vysledky, ma defaultne 0
|
||||
for cis in rocnik.verejna_cisla():
|
||||
if cis.verejna_vysledkovka:
|
||||
#seznam vysledku se spravnym rocnikem a cislem pro resitele
|
||||
#zobrazim jen je-li vysledkovka verejna
|
||||
body_za_cislo = VysledkyZaCislo.objects.filter(cislo__rocnik=rocnik).filter(cislo = cis).filter(resitel = v.resitel)
|
||||
if body_za_cislo:
|
||||
#neprazdne vysledky by mely obsahovat prave jeden vysledek
|
||||
v.body_cisla.append(body_za_cislo[0].body)
|
||||
else:
|
||||
#resitel nema za cislo body
|
||||
v.body_cisla.append(0)
|
||||
|
||||
vysledkovka.append(v)
|
||||
|
||||
return vysledkovka
|
||||
|
||||
|
||||
class RocnikView(generic.DetailView):
|
||||
model = Rocnik
|
||||
template_name = 'seminar/archiv/rocnik.html'
|
||||
|
@ -131,46 +194,8 @@ class RocnikView(generic.DetailView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(RocnikView, self).get_context_data(**kwargs)
|
||||
|
||||
cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__verejna_vysledkovka = True).filter(cislo__rocnik = context['rocnik']).order_by('cislo')
|
||||
#vyberu vsechny verejne vysledky z rocniku
|
||||
#pokud žádné nejsou, výsledkovka se nezobrazí
|
||||
if cisla_v_rocniku:
|
||||
vysledky = list(cisla_v_rocniku.filter(cislo = cisla_v_rocniku[0].cislo).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno').select_related('resitel'))
|
||||
#vybere vsechny vysledky z posledniho verejneho cisla a setridi sestupne dle bodu
|
||||
vysledkovka = []
|
||||
|
||||
# doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
|
||||
for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
|
||||
v.poradi = poradi
|
||||
v.resitel.rocnik = v.resitel.rocnik(context['rocnik'])
|
||||
|
||||
verejne_vysl_odjakziva = VysledkyKCisluOdjakziva.objects.filter(cislo__verejna_vysledkovka = True).filter(cislo__rocnik = context['rocnik']).filter(cislo = cisla_v_rocniku[0].cislo)
|
||||
|
||||
v.body_odjakziva = verejne_vysl_odjakziva.filter(resitel = v.resitel)[0].body
|
||||
v.titul = v.resitel.get_titul(v.body_odjakziva)
|
||||
v.body_rocnik = v.body
|
||||
v.body_cisla = []
|
||||
|
||||
#pokud pro dany rok a cislo nema resitel vysledky, ma defaultne 0
|
||||
for cis in context['rocnik'].verejna_cisla():
|
||||
if cis.verejna_vysledkovka:
|
||||
body_za_cislo = VysledkyZaCislo.objects.filter(cislo__rocnik = context['rocnik']).filter(cislo = cis).filter(resitel = v.resitel)
|
||||
#seznam vysledku se spravnym rocnikem a cislem pro resitele
|
||||
#zobrazim jen je-li vysledkovka verejna
|
||||
if body_za_cislo:
|
||||
v.body_cisla.append(body_za_cislo[0].body)
|
||||
#neprazdne vysledky by mely obsahovat prave jeden vysledek
|
||||
else:
|
||||
v.body_cisla.append(0)
|
||||
#resitel nema za cislo body
|
||||
|
||||
vysledkovka.append(v)
|
||||
|
||||
|
||||
context['vysledkovka'] = vysledkovka
|
||||
|
||||
temata_v_rocniku = Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=context['rocnik']).order_by('kod')
|
||||
context['temata_v_rocniku'] = temata_v_rocniku
|
||||
context['vysledkovka'] = vysledkovka_rocniku(context["rocnik"])
|
||||
context['temata_v_rocniku'] = verejna_temata(context["rocnik"])
|
||||
|
||||
return context
|
||||
|
||||
|
|