uprava na python3 (obcas) a novy model (hlavne)
This commit is contained in:
parent
9ffcd604db
commit
b6a3012d1e
8 changed files with 343 additions and 315 deletions
|
@ -43,7 +43,7 @@ class KorekturyView(generic.TemplateView):
|
|||
scroll = 0
|
||||
|
||||
action = q.get('action')
|
||||
if (action == u''): # Přidej
|
||||
if (action == ''): # Přidej
|
||||
x = int(q.get('x'))
|
||||
y = int(q.get('y'))
|
||||
text = q.get('txt')
|
||||
|
@ -53,62 +53,62 @@ class KorekturyView(generic.TemplateView):
|
|||
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
|
||||
op.save()
|
||||
self.send_email_notification_komentar(op, autor, text)
|
||||
elif (action == u'del'):
|
||||
elif (action == 'del'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.delete()
|
||||
elif (action == u'update'):
|
||||
elif (action == 'update'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
text = q.get('txt')
|
||||
op.autor = autor
|
||||
op.text = text
|
||||
op.save()
|
||||
elif (action == u'undone'):
|
||||
elif (action == 'undone'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.status = op.STATUS_K_OPRAVE
|
||||
op.save()
|
||||
elif (action == u'done'):
|
||||
elif (action == 'done'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.status = op.STATUS_OPRAVENO
|
||||
op.save()
|
||||
elif (action == u'ready'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.status = op.STATUS_K_ZANESENI
|
||||
op.save()
|
||||
elif (action == u'wontfix'):
|
||||
elif (action == 'ready'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.status = op.STATUS_K_ZANESENI
|
||||
op.save()
|
||||
elif (action == 'wontfix'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.status = op.STATUS_NENI_CHYBA
|
||||
op.save()
|
||||
elif (action == u'comment'):
|
||||
elif (action == 'comment'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.get(id=id)
|
||||
text = q.get('txt')
|
||||
kom = Komentar(oprava=op,autor=autor,text=text)
|
||||
kom.save()
|
||||
self.send_email_notification_komentar(op, autor, text)
|
||||
elif (action == u'update-comment'):
|
||||
elif (action == 'update-comment'):
|
||||
id = int(q.get('id'))
|
||||
kom = Komentar.objects.get(id=id)
|
||||
text = q.get('txt')
|
||||
kom.text = text
|
||||
kom.autor = autor
|
||||
kom.save()
|
||||
elif (action == u'del-comment'):
|
||||
elif (action == 'del-comment'):
|
||||
id = int(q.get('id'))
|
||||
kom = Komentar.objects.get(id=id)
|
||||
kom.delete()
|
||||
elif (action == u'set-state'):
|
||||
elif (action == 'set-state'):
|
||||
pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
|
||||
if (q.get('state') == u'adding'):
|
||||
if (q.get('state') == 'adding'):
|
||||
pdf.status = pdf.STATUS_PRIDAVANI
|
||||
elif (q.get('state') == u'comitting'):
|
||||
elif (q.get('state') == 'comitting'):
|
||||
pdf.status = pdf.STATUS_ZANASENI
|
||||
elif (q.get('state') == u'deprecated'):
|
||||
elif (q.get('state') == 'deprecated'):
|
||||
pdf.status = pdf.STATUS_ZASTARALE
|
||||
pdf.save()
|
||||
context = self.get_context_data()
|
||||
|
@ -124,7 +124,7 @@ class KorekturyView(generic.TemplateView):
|
|||
# parametry e-mailu
|
||||
odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk)
|
||||
from_email = 'korekturovatko@mam.mff.cuni.cz'
|
||||
subject = u'Nová korektura od {} v {}'.format(autor,
|
||||
subject = 'Nová korektura od {} v {}'.format(autor,
|
||||
oprava.pdf.nazev)
|
||||
text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\
|
||||
\nodkaz do korekturovátka: {}\n\
|
||||
|
@ -155,7 +155,7 @@ class KorekturyView(generic.TemplateView):
|
|||
emails.discard(email)
|
||||
|
||||
if not settings.SEND_EMAIL_NOTIFICATIONS:
|
||||
print "Poslal bych upozornění na tyto adresy: ", " ".join(emails)
|
||||
print("Poslal bych upozornění na tyto adresy: ", " ".join(emails))
|
||||
return
|
||||
|
||||
send_mail(subject, text, from_email, list(emails))
|
||||
|
|
|
@ -5,7 +5,7 @@ from reversion.admin import VersionAdmin
|
|||
from django.utils.safestring import mark_safe
|
||||
from django.utils.html import escape
|
||||
|
||||
from models import Prednaska, Seznam, STAV_NAVRH
|
||||
from .models import Prednaska, Seznam, STAV_NAVRH
|
||||
from seminar.models import Soustredeni
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ def newPrednaska(request):
|
|||
# hlasovani se vztahuje k nejnovejsimu soustredeni
|
||||
sous = Soustredeni.objects.first()
|
||||
seznam = Seznam.objects.filter(soustredeni = sous, stav = STAV_NAVRH).first()
|
||||
print seznam
|
||||
print(seznam)
|
||||
# obsluha formulare
|
||||
if request.method == 'POST':
|
||||
form = NewPrednaskyForm(request.POST, request.FILES)
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.core.urlresolvers import reverse
|
|||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Prispevek, Pohadka, Konfera
|
||||
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Novinky, Organizator, Pohadka, Konfera, Uloha
|
||||
from autocomplete_light import shortcuts as autocomplete_light
|
||||
|
||||
|
||||
|
@ -124,9 +124,9 @@ class ProblemInline(admin.TabularInline):
|
|||
|
||||
|
||||
class ReseniKProblemuInline(admin.TabularInline):
|
||||
form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['resitel'], fields=['resitel'])
|
||||
form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['resitele'], fields=['resitele'])
|
||||
model = Reseni
|
||||
fields = ['resitel', 'forma', 'body', 'cislo_body', 'timestamp', 'poznamka']
|
||||
fields = ['resitele', 'forma', 'body', 'cislo_body', 'timestamp', 'poznamka']
|
||||
readonly_fields = ['timestamp']
|
||||
extra = 0
|
||||
formfield_overrides = {
|
||||
|
@ -136,7 +136,7 @@ class ReseniKProblemuInline(admin.TabularInline):
|
|||
|
||||
def get_queryset(self, request):
|
||||
qs = super(ReseniKProblemuInline, self).get_queryset(request)
|
||||
return qs.select_related('problem', 'cislo_body', 'resitel')
|
||||
return qs.select_related('problem', 'cislo_body', 'resitele')
|
||||
|
||||
# Potenciální DB HOG (cislo_body se dotazovalo na cisla pri kazdem zobrazeni jejich selectu ...)
|
||||
def formfield_for_dbfield(self, db_field, **kwargs):
|
||||
|
@ -323,13 +323,13 @@ admin.site.register(Rocnik, RocnikAdmin)
|
|||
### Reseni
|
||||
|
||||
class ReseniAdmin(VersionAdmin):
|
||||
form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['problem', 'resitel'], fields=['problem', 'resitel'])
|
||||
#form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['problem', 'resitele'], fields=['problem', 'resitele'])
|
||||
fieldsets = [
|
||||
(None, {'fields': ['problem', 'resitel', 'forma', 'body', 'cislo_body', 'timestamp']}),
|
||||
(None, {'fields': ['problem', 'resitele', 'forma', 'body', 'cislo_body', 'timestamp']}),
|
||||
(u'Poznámky', {'fields': ['poznamka']}),
|
||||
]
|
||||
readonly_fields = ['timestamp']
|
||||
list_display = ['problem', 'resitel', 'forma', 'body', 'timestamp', 'cislo_body']
|
||||
list_display = ['problem', 'resitele', 'forma', 'body', 'timestamp', 'cislo_body']
|
||||
list_filter = ['body', 'timestamp', 'forma']
|
||||
search_fields = []
|
||||
inlines = [PrilohaReseniInline]
|
||||
|
@ -337,7 +337,7 @@ class ReseniAdmin(VersionAdmin):
|
|||
|
||||
def get_queryset(self, request):
|
||||
qs = super(ReseniAdmin, self).get_queryset(request)
|
||||
return qs.select_related('resitel', 'problem', 'cislo_body')
|
||||
return qs.select_related('resitele', 'problem', 'cislo_body')
|
||||
|
||||
admin.site.register(Reseni, ReseniAdmin)
|
||||
|
||||
|
@ -350,7 +350,7 @@ class PohadkaAdminForm(forms.ModelForm):
|
|||
exclude = []
|
||||
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
||||
uloha = forms.ModelChoiceField(
|
||||
Problem.objects.filter(typ=Problem.TYP_ULOHA)
|
||||
Uloha.objects.all()
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -402,15 +402,15 @@ from autocomplete_light.contrib.taggit_field import TaggitField, TaggitWidget
|
|||
|
||||
|
||||
class ProblemAdminForm(forms.ModelForm):
|
||||
text_zadani = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_zadani'))
|
||||
text_reseni = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_reseni'))
|
||||
text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_org'))
|
||||
#text_zadani = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_zadani'))
|
||||
#text_reseni = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_reseni'))
|
||||
#text_org = forms.CharField(widget=CKEditorUploadingWidget(), 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 = []
|
||||
exclude = ['nadproblem']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ProblemAdminForm, self).__init__(*args, **kwargs)
|
||||
|
@ -476,7 +476,8 @@ class ProblemNavrhAdmin(ProblemAdmin):
|
|||
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)')
|
||||
#FIXME
|
||||
#create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Problém (návrh)', verbose_name_plural=u'Problémy (návrhy)')
|
||||
|
||||
|
||||
class ProblemZadanyAdmin(ProblemAdmin):
|
||||
|
@ -529,27 +530,28 @@ class ProblemZadanyAdmin(ProblemAdmin):
|
|||
|
||||
get_form = get_form_predvypln_autora
|
||||
|
||||
create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'Problém (zadaný)', verbose_name_plural=u'Problémy (zadané)')
|
||||
#FIXME
|
||||
#create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'Problém (zadaný)', verbose_name_plural=u'Problémy (zadané)')
|
||||
|
||||
#admin.site.register(Problem, ProblemAdmin)
|
||||
|
||||
### Prispevek (k tematkum)
|
||||
|
||||
class PrispevekAdminForm(forms.ModelForm):
|
||||
text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
||||
**field_labels(Prispevek, 'text_org'))
|
||||
text_resitel = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
||||
**field_labels(Prispevek, 'text_resitel'))
|
||||
|
||||
class Meta:
|
||||
model = Prispevek
|
||||
exclude = []
|
||||
|
||||
class PrispevekAdmin(VersionAdmin):
|
||||
form = PrispevekAdminForm
|
||||
list_display = ['nazev', 'problem', 'reseni', 'zverejnit']
|
||||
|
||||
admin.site.register(Prispevek, PrispevekAdmin)
|
||||
#class PrispevekAdminForm(forms.ModelForm):
|
||||
# text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
||||
# **field_labels(Prispevek, 'text_org'))
|
||||
# text_resitel = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
||||
# **field_labels(Prispevek, 'text_resitel'))
|
||||
#
|
||||
# class Meta:
|
||||
# model = Prispevek
|
||||
# exclude = []
|
||||
#
|
||||
#class PrispevekAdmin(VersionAdmin):
|
||||
# form = PrispevekAdminForm
|
||||
# list_display = ['nazev', 'problem', 'reseni', 'zverejnit']
|
||||
#
|
||||
#admin.site.register(Prispevek, PrispevekAdmin)
|
||||
|
||||
### Soustredeni
|
||||
|
||||
|
@ -664,7 +666,7 @@ deaktivovat_organizatory.short_description = 'Deaktivovat organizátory'
|
|||
|
||||
@admin.register(Organizator)
|
||||
class OrganizatorAdmin(VersionAdmin):
|
||||
list_filter = ['organizuje_do_roku']
|
||||
list_filter = ['organizuje_do']
|
||||
list_display = [jmeno_organizatora, je_organizator_aktivni,]
|
||||
actions = [zaktivovat_organizatory, deaktivovat_organizatory,]
|
||||
|
||||
|
|
|
@ -1019,6 +1019,27 @@ class Konfera(models.Model):
|
|||
return force_unicode(u"%s: (%s)".format(self.nazev, self.soustredeni))
|
||||
|
||||
|
||||
# Vazebna tabulka. Mozna se generuje automaticky.
|
||||
@reversion.register(ignore_duplicates=True)
|
||||
@python_2_unicode_compatible
|
||||
class Reseni_Resitele(models.Model):
|
||||
|
||||
class Meta:
|
||||
db_table = 'seminar_reseni_resitele'
|
||||
verbose_name = 'Řešení řešitelů'
|
||||
verbose_name_plural = 'Řešení řešitelů'
|
||||
ordering = ['reseni', 'resitele']
|
||||
|
||||
# Interní ID
|
||||
id = models.AutoField(primary_key = True)
|
||||
|
||||
resitele = models.ForeignKey(Resitel, verbose_name='řešitel')
|
||||
|
||||
reseni = models.ForeignKey(Reseni, verbose_name='řešení')
|
||||
|
||||
def __str__(self):
|
||||
return force_unicode('%s od %s'.format(self.reseni, self.resitel))
|
||||
# NOTE: Poteciální DB HOG bez select_related
|
||||
|
||||
@reversion.register(ignore_duplicates=True)
|
||||
@python_2_unicode_compatible
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import csv, codecs, cStringIO
|
||||
import csv, codecs
|
||||
from io import StringIO
|
||||
|
||||
class UTF8Recoder:
|
||||
"""
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.conf.urls import * # NOQA
|
|||
from django.conf.urls import url, include
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from . import views, export
|
||||
from utils import staff_member_required
|
||||
from .utils import staff_member_required
|
||||
from django.views.generic.base import RedirectView
|
||||
|
||||
staff_member_required = user_passes_test(lambda u: u.is_staff)
|
||||
|
@ -20,9 +20,9 @@ urlpatterns = [
|
|||
url(r'^archiv/temata/$', views.ArchivTemataView.as_view()),
|
||||
|
||||
url(r'^rocnik/(?P<rocnik>\d+)/$', views.RocnikView.as_view(), name='seminar_rocnik'),
|
||||
url(r'^cislo/(?P<rocnik>\d+)\.(?P<cislo>[0-9-]+)/$', views.CisloView.as_view(), name='seminar_cislo'),
|
||||
#url(r'^cislo/(?P<rocnik>\d+)\.(?P<cislo>[0-9-]+)/$', views.CisloView.as_view(), name='seminar_cislo'),
|
||||
url(r'^problem/(?P<pk>\d+)/$', views.ProblemView.as_view(), name='seminar_problem'),
|
||||
url(r'^problem/(?P<pk>\d+)/(?P<prispevek>\d+)/$', views.PrispevekView.as_view(), name='seminar_problem_prispevek'),
|
||||
#url(r'^problem/(?P<pk>\d+)/(?P<prispevek>\d+)/$', views.PrispevekView.as_view(), name='seminar_problem_prispevek'),
|
||||
|
||||
# Soustredeni
|
||||
url(
|
||||
|
@ -63,13 +63,13 @@ urlpatterns = [
|
|||
# Zadani
|
||||
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'^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'),
|
||||
|
||||
# Clanky
|
||||
url(r'^clanky/resitel/$', views.ClankyResitelView.as_view(), name='clanky_resitel'),
|
||||
url(r'^clanky/org/$', views.ClankyOrganizatorView.as_view(), name='clanky_organizator'),
|
||||
#url(r'^clanky/org/$', views.ClankyOrganizatorView.as_view(), name='clanky_organizator'),
|
||||
|
||||
# Aesop
|
||||
url(r'^aesop-export/mam-rocnik-(?P<prvni_rok>\d+)\.csv$', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'),
|
||||
|
@ -77,18 +77,18 @@ urlpatterns = [
|
|||
url(r'^aesop-export/index.csv$', export.ExportIndexView.as_view(), name='seminar_export_index'),
|
||||
|
||||
# Stranky viditelne pouze pro orgy:
|
||||
url(
|
||||
r'^rocnik/(?P<rocnik>\d+)/vysledkovka.tex$',
|
||||
staff_member_required(views.RocnikVysledkovkaView.as_view()),
|
||||
name='seminar_cislo_vysledkovka'
|
||||
),
|
||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/vysledkovka.tex$',
|
||||
staff_member_required(views.CisloVysledkovkaView.as_view()), name='seminar_cislo_vysledkovka'),
|
||||
#url(
|
||||
# r'^rocnik/(?P<rocnik>\d+)/vysledkovka.tex$',
|
||||
# staff_member_required(views.RocnikVysledkovkaView.as_view()),
|
||||
# name='seminar_cislo_vysledkovka'
|
||||
#),
|
||||
#url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/vysledkovka.tex$',
|
||||
# staff_member_required(views.CisloVysledkovkaView.as_view()), name='seminar_cislo_vysledkovka'),
|
||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/obalky.pdf$',
|
||||
staff_member_required(views.cisloObalkyView), name='seminar_cislo_obalky'),
|
||||
|
||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/tituly.tex$',
|
||||
staff_member_required(views.TitulyView), name='seminar_cislo_titul'),
|
||||
#url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/tituly.tex$',
|
||||
# staff_member_required(views.TitulyView), name='seminar_cislo_titul'),
|
||||
url(r'^stav$',
|
||||
staff_member_required(views.StavDatabazeView), name='stav_databaze'),
|
||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/obalkovani$',
|
||||
|
|
498
seminar/views.py
498
seminar/views.py
|
@ -11,8 +11,8 @@ from django.db.models import Q
|
|||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.contrib.auth import authenticate, login
|
||||
|
||||
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Prispevek
|
||||
from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek
|
||||
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from . import utils
|
||||
from .unicodecsv import UnicodeWriter
|
||||
from .forms import NameForm
|
||||
|
@ -68,29 +68,29 @@ def ZadaniTemataView(request):
|
|||
)
|
||||
|
||||
|
||||
def ZadaniAktualniVysledkovkaView(request):
|
||||
nastaveni = get_object_or_404(Nastaveni)
|
||||
# Aktualni verejna vysledkovka
|
||||
vysledkovka = vysledkovka_rocniku(nastaveni.aktualni_rocnik)
|
||||
# kdyz neni verejna vysledkovka, tak zobraz starou
|
||||
if not vysledkovka:
|
||||
try:
|
||||
minuly_rocnik = Rocnik.objects.get(
|
||||
prvni_rok=(nastaveni.aktualni_rocnik.prvni_rok-1))
|
||||
vysledkovka = vysledkovka_rocniku(minuly_rocnik)
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
# vysledkovka s neverejnyma vysledkama
|
||||
vysledkovka_s_neverejnymi = vysledkovka_rocniku(nastaveni.aktualni_rocnik, jen_verejne=False)
|
||||
return render(
|
||||
request,
|
||||
'seminar/zadani/AktualniVysledkovka.html',
|
||||
{
|
||||
'nastaveni': nastaveni,
|
||||
'vysledkovka': vysledkovka,
|
||||
'vysledkovka_s_neverejnymi': vysledkovka_s_neverejnymi,
|
||||
}
|
||||
)
|
||||
#def ZadaniAktualniVysledkovkaView(request):
|
||||
# nastaveni = get_object_or_404(Nastaveni)
|
||||
# # Aktualni verejna vysledkovka
|
||||
# vysledkovka = vysledkovka_rocniku(nastaveni.aktualni_rocnik)
|
||||
# # kdyz neni verejna vysledkovka, tak zobraz starou
|
||||
# if not vysledkovka:
|
||||
# try:
|
||||
# minuly_rocnik = Rocnik.objects.get(
|
||||
# prvni_rok=(nastaveni.aktualni_rocnik.prvni_rok-1))
|
||||
# vysledkovka = vysledkovka_rocniku(minuly_rocnik)
|
||||
# except ObjectDoesNotExist:
|
||||
# pass
|
||||
# # vysledkovka s neverejnyma vysledkama
|
||||
# vysledkovka_s_neverejnymi = vysledkovka_rocniku(nastaveni.aktualni_rocnik, jen_verejne=False)
|
||||
# return render(
|
||||
# request,
|
||||
# 'seminar/zadani/AktualniVysledkovka.html',
|
||||
# {
|
||||
# 'nastaveni': nastaveni,
|
||||
# 'vysledkovka': vysledkovka,
|
||||
# 'vysledkovka_s_neverejnymi': vysledkovka_s_neverejnymi,
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
### Titulni strana
|
||||
|
@ -143,10 +143,10 @@ class StareNovinkyView(generic.ListView):
|
|||
|
||||
|
||||
# Organizatori
|
||||
def aktivniOrganizatori(rok=date.today().year):
|
||||
def aktivniOrganizatori(datum=date.today()):
|
||||
return Organizator.objects.exclude(
|
||||
organizuje_do_roku__isnull=False,
|
||||
organizuje_do_roku__lt=rok
|
||||
organizuje_do__isnull=False,
|
||||
organizuje_do__lt=datum
|
||||
).order_by('user__first_name')
|
||||
|
||||
|
||||
|
@ -165,7 +165,7 @@ class CojemamOrganizatoriStariView(generic.ListView):
|
|||
model = Organizator
|
||||
template_name = 'seminar/cojemam/organizatori.html'
|
||||
queryset = Organizator.objects.exclude(
|
||||
id__in=aktivniOrganizatori()).order_by('-organizuje_do_roku')
|
||||
id__in=aktivniOrganizatori()).order_by('-organizuje_do')
|
||||
|
||||
### Archiv
|
||||
|
||||
|
@ -273,62 +273,62 @@ def sloupec_s_poradim(vysledky):
|
|||
return poradi_l
|
||||
|
||||
|
||||
def vysledkovka_rocniku(rocnik, jen_verejne=True):
|
||||
"""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 vysledky z rocniku
|
||||
cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__rocnik=rocnik).order_by('cislo')
|
||||
if jen_verejne:
|
||||
cisla_v_rocniku = cisla_v_rocniku.filter(cislo__verejna_vysledkovka=True)
|
||||
|
||||
#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'))
|
||||
|
||||
class Vysledkovka:
|
||||
def __init__(self):
|
||||
self.rocnik = rocnik.rocnik
|
||||
self.radky = []
|
||||
self.cisla = []
|
||||
|
||||
vysledkovka = Vysledkovka()
|
||||
vysledkovka.cisla = (rocnik.verejne_vysledkovky_cisla() if jen_verejne else rocnik.cisla.all().order_by('cislo'))
|
||||
|
||||
# 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__rocnik=rocnik, cislo=cisla_v_rocniku[0].cislo)
|
||||
if jen_verejne:
|
||||
verejne_vysl_odjakziva = verejne_vysl_odjakziva.filter(cislo__verejna_vysledkovka=True)
|
||||
|
||||
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 vysledkovka.cisla:
|
||||
if not jen_verejne or 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.radky.append(v)
|
||||
|
||||
return vysledkovka
|
||||
#def vysledkovka_rocniku(rocnik, jen_verejne=True):
|
||||
# """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 vysledky z rocniku
|
||||
# cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__rocnik=rocnik).order_by('cislo')
|
||||
# if jen_verejne:
|
||||
# cisla_v_rocniku = cisla_v_rocniku.filter(cislo__verejna_vysledkovka=True)
|
||||
#
|
||||
# #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'))
|
||||
#
|
||||
# class Vysledkovka:
|
||||
# def __init__(self):
|
||||
# self.rocnik = rocnik.rocnik
|
||||
# self.radky = []
|
||||
# self.cisla = []
|
||||
#
|
||||
# vysledkovka = Vysledkovka()
|
||||
# vysledkovka.cisla = (rocnik.verejne_vysledkovky_cisla() if jen_verejne else rocnik.cisla.all().order_by('cislo'))
|
||||
#
|
||||
# # 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__rocnik=rocnik, cislo=cisla_v_rocniku[0].cislo)
|
||||
# if jen_verejne:
|
||||
# verejne_vysl_odjakziva = verejne_vysl_odjakziva.filter(cislo__verejna_vysledkovka=True)
|
||||
#
|
||||
# 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 vysledkovka.cisla:
|
||||
# if not jen_verejne or 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.radky.append(v)
|
||||
#
|
||||
# return vysledkovka
|
||||
|
||||
|
||||
class RocnikView(generic.DetailView):
|
||||
|
@ -352,8 +352,8 @@ class RocnikView(generic.DetailView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(RocnikView, self).get_context_data(**kwargs)
|
||||
|
||||
context['vysledkovka'] = vysledkovka_rocniku(context["rocnik"])
|
||||
context['vysledkovka_s_neverejnymi'] = vysledkovka_rocniku(context["rocnik"], jen_verejne=False)
|
||||
#context['vysledkovka'] = vysledkovka_rocniku(context["rocnik"])
|
||||
#context['vysledkovka_s_neverejnymi'] = vysledkovka_rocniku(context["rocnik"], jen_verejne=False)
|
||||
context['temata_v_rocniku'] = verejna_temata(context["rocnik"])
|
||||
|
||||
return context
|
||||
|
@ -377,151 +377,152 @@ class ProblemView(generic.DetailView):
|
|||
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
|
||||
return context
|
||||
|
||||
class PrispevekView(generic.DetailView):
|
||||
model = Prispevek
|
||||
template_name = 'seminar/archiv/prispevek.html'
|
||||
|
||||
# Vlastni ziskavani objektu z databaze podle prispevku
|
||||
# pokud je prispevek neverejny zobrazi se jenom orgum
|
||||
def get_object(self, queryset=None):
|
||||
if queryset is None:
|
||||
queryset = self.get_queryset()
|
||||
problem_arg = self.kwargs.get('pk')
|
||||
prispevek_arg = self.kwargs.get('prispevek')
|
||||
queryset = queryset.filter(pk=prispevek_arg)
|
||||
|
||||
try:
|
||||
obj = queryset.get()
|
||||
except queryset.model.DoesNotExist:
|
||||
raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||
{'verbose_name': queryset.model._meta.verbose_name})
|
||||
|
||||
if self.request.user.is_staff or obj.zverejnit:
|
||||
return obj
|
||||
else:
|
||||
raise Http404()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(PrispevekView, self).get_context_data(**kwargs)
|
||||
# snaho o ziskani titulu
|
||||
titul = ''
|
||||
try:
|
||||
resitel = context['prispevek'].reseni.resitel
|
||||
cislo = context['prispevek'].reseni.cislo_body
|
||||
body = VysledkyKCisluOdjakziva.objects.get(resitel=resitel,
|
||||
cislo=cislo).body
|
||||
titul = resitel.get_titul(body)
|
||||
except:
|
||||
pass
|
||||
context['titul'] = titul
|
||||
return context
|
||||
## Prispevek byl zrusen, mozna ale bude podobny nahled na neco jineho.
|
||||
#class PrispevekView(generic.DetailView):
|
||||
# model = Prispevek
|
||||
# template_name = 'seminar/archiv/prispevek.html'
|
||||
#
|
||||
# # Vlastni ziskavani objektu z databaze podle prispevku
|
||||
# # pokud je prispevek neverejny zobrazi se jenom orgum
|
||||
# def get_object(self, queryset=None):
|
||||
# if queryset is None:
|
||||
# queryset = self.get_queryset()
|
||||
# problem_arg = self.kwargs.get('pk')
|
||||
# prispevek_arg = self.kwargs.get('prispevek')
|
||||
# queryset = queryset.filter(pk=prispevek_arg)
|
||||
#
|
||||
# try:
|
||||
# obj = queryset.get()
|
||||
# except queryset.model.DoesNotExist:
|
||||
# raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||
# {'verbose_name': queryset.model._meta.verbose_name})
|
||||
#
|
||||
# if self.request.user.is_staff or obj.zverejnit:
|
||||
# return obj
|
||||
# else:
|
||||
# raise Http404()
|
||||
#
|
||||
# def get_context_data(self, **kwargs):
|
||||
# context = super(PrispevekView, self).get_context_data(**kwargs)
|
||||
# # snaho o ziskani titulu
|
||||
# titul = ''
|
||||
# try:
|
||||
# resitel = context['prispevek'].reseni.resitel
|
||||
# cislo = context['prispevek'].reseni.cislo_body
|
||||
# body = VysledkyKCisluOdjakziva.objects.get(resitel=resitel,
|
||||
# cislo=cislo).body
|
||||
# titul = resitel.get_titul(body)
|
||||
# except:
|
||||
# pass
|
||||
# context['titul'] = titul
|
||||
# return context
|
||||
|
||||
|
||||
|
||||
class RadekVysledkovky(object):
|
||||
pass
|
||||
|
||||
class CisloView(generic.DetailView):
|
||||
model = Cislo
|
||||
template_name = 'seminar/archiv/cislo.html'
|
||||
|
||||
# Vlastni ziskavani objektu z databaze podle (Rocnik.rocnik)
|
||||
def get_object(self, queryset=None):
|
||||
if queryset is None:
|
||||
queryset = self.get_queryset()
|
||||
rocnik_arg = self.kwargs.get('rocnik')
|
||||
cislo_arg = self.kwargs.get('cislo')
|
||||
queryset = queryset.filter(rocnik__rocnik=rocnik_arg, cislo=cislo_arg)
|
||||
|
||||
try:
|
||||
obj = queryset.get()
|
||||
except queryset.model.DoesNotExist:
|
||||
raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||
{'verbose_name': queryset.model._meta.verbose_name})
|
||||
return obj
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CisloView, self).get_context_data(**kwargs)
|
||||
|
||||
vysledky = VysledkyKCisluZaRocnik.objects.filter(cislo = context['cislo']).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno')
|
||||
reseni = Reseni.objects.filter(cislo_body = context['cislo']).select_related("resitel")
|
||||
|
||||
# typy úloh, které se mají zobrazovat u čísla, tj. těch, které byly v čísle skutečně zadány
|
||||
typy_skutecne_zadanych = [Problem.TYP_ULOHA, Problem.TYP_SERIAL, Problem.TYP_ORG_CLANEK]
|
||||
v_cisle_zadane = Problem.objects.filter(cislo_zadani=context['cislo']).filter(typ__in=typy_skutecne_zadanych).order_by('kod')
|
||||
|
||||
resene_problemy = Problem.objects.filter(cislo_reseni=context['cislo']).filter(typ__in=typy_skutecne_zadanych).order_by('cislo_zadani__cislo', 'kod')
|
||||
|
||||
poradi_typu = {
|
||||
Problem.TYP_ULOHA: 1,
|
||||
Problem.TYP_SERIAL: 2,
|
||||
Problem.TYP_ORG_CLANEK: 3,
|
||||
Problem.TYP_TEMA: 4,
|
||||
Problem.TYP_RES_CLANEK: 5
|
||||
}
|
||||
problemy = sorted(set(r.problem for r in reseni), key=lambda x:(poradi_typu[x.typ], x.kod_v_rocniku()))
|
||||
#setridi problemy podle typu a poradi zadani
|
||||
problem_index = {}
|
||||
for i in range(len(problemy)):
|
||||
problem_index[problemy[i].id] = i
|
||||
#umoznuje zjistit index podle id problemu
|
||||
|
||||
vysledky_resitele = {}
|
||||
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.body_celkem_rocnik = v.body
|
||||
v.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
|
||||
v.resitel.rocnik = v.resitel.rocnik(v.cislo.rocnik)
|
||||
|
||||
# je tady '', aby se nezobrazovala 0, pokud se řešitel o řešení úlohy ani nepokusil
|
||||
v.body_ulohy = [''] * len(problemy)
|
||||
|
||||
v.titul = v.resitel.get_titul(v.body_celkem_odjakziva)
|
||||
|
||||
body_cislo_q = VysledkyZaCislo.objects.filter(resitel=v.resitel, cislo=context['cislo'])
|
||||
v.body_cislo = body_cislo_q[0].body if body_cislo_q else 0
|
||||
|
||||
vysledkovka.append(v)
|
||||
|
||||
# připravíme si odkaz na řádek, abychom do něj mohli doplnit body za jednotlivé úlohy
|
||||
vysledky_resitele[v.resitel.id] = v
|
||||
|
||||
# za každé řešení doplníme k příslušnému řešiteli a úloze body
|
||||
for r in reseni:
|
||||
vysledky_resitele[r.resitel.id].body_ulohy[problem_index[r.problem.id]] = r.body
|
||||
|
||||
context['vysledkovka'] = vysledkovka
|
||||
context['problemy'] = problemy
|
||||
context['v_cisle_zadane'] = v_cisle_zadane
|
||||
context['resene_problemy'] = resene_problemy
|
||||
return context
|
||||
#class CisloView(generic.DetailView):
|
||||
# model = Cislo
|
||||
# template_name = 'seminar/archiv/cislo.html'
|
||||
#
|
||||
# # Vlastni ziskavani objektu z databaze podle (Rocnik.rocnik)
|
||||
# def get_object(self, queryset=None):
|
||||
# if queryset is None:
|
||||
# queryset = self.get_queryset()
|
||||
# rocnik_arg = self.kwargs.get('rocnik')
|
||||
# cislo_arg = self.kwargs.get('cislo')
|
||||
# queryset = queryset.filter(rocnik__rocnik=rocnik_arg, cislo=cislo_arg)
|
||||
#
|
||||
# try:
|
||||
# obj = queryset.get()
|
||||
# except queryset.model.DoesNotExist:
|
||||
# raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||
# {'verbose_name': queryset.model._meta.verbose_name})
|
||||
# return obj
|
||||
#
|
||||
#
|
||||
# def get_context_data(self, **kwargs):
|
||||
# context = super(CisloView, self).get_context_data(**kwargs)
|
||||
#
|
||||
# vysledky = VysledkyKCisluZaRocnik.objects.filter(cislo = context['cislo']).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno')
|
||||
# reseni = Reseni.objects.filter(cislo_body = context['cislo']).select_related("resitel")
|
||||
#
|
||||
# # typy úloh, které se mají zobrazovat u čísla, tj. těch, které byly v čísle skutečně zadány
|
||||
# typy_skutecne_zadanych = [Problem.TYP_ULOHA, Problem.TYP_SERIAL, Problem.TYP_ORG_CLANEK]
|
||||
# v_cisle_zadane = Problem.objects.filter(cislo_zadani=context['cislo']).filter(typ__in=typy_skutecne_zadanych).order_by('kod')
|
||||
#
|
||||
# resene_problemy = Problem.objects.filter(cislo_reseni=context['cislo']).filter(typ__in=typy_skutecne_zadanych).order_by('cislo_zadani__cislo', 'kod')
|
||||
#
|
||||
# poradi_typu = {
|
||||
# Problem.TYP_ULOHA: 1,
|
||||
# Problem.TYP_SERIAL: 2,
|
||||
# Problem.TYP_ORG_CLANEK: 3,
|
||||
# Problem.TYP_TEMA: 4,
|
||||
# Problem.TYP_RES_CLANEK: 5
|
||||
# }
|
||||
# problemy = sorted(set(r.problem for r in reseni), key=lambda x:(poradi_typu[x.typ], x.kod_v_rocniku()))
|
||||
# #setridi problemy podle typu a poradi zadani
|
||||
# problem_index = {}
|
||||
# for i in range(len(problemy)):
|
||||
# problem_index[problemy[i].id] = i
|
||||
# #umoznuje zjistit index podle id problemu
|
||||
#
|
||||
# vysledky_resitele = {}
|
||||
# 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.body_celkem_rocnik = v.body
|
||||
# v.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
|
||||
# v.resitel.rocnik = v.resitel.rocnik(v.cislo.rocnik)
|
||||
#
|
||||
# # je tady '', aby se nezobrazovala 0, pokud se řešitel o řešení úlohy ani nepokusil
|
||||
# v.body_ulohy = [''] * len(problemy)
|
||||
#
|
||||
# v.titul = v.resitel.get_titul(v.body_celkem_odjakziva)
|
||||
#
|
||||
# body_cislo_q = VysledkyZaCislo.objects.filter(resitel=v.resitel, cislo=context['cislo'])
|
||||
# v.body_cislo = body_cislo_q[0].body if body_cislo_q else 0
|
||||
#
|
||||
# vysledkovka.append(v)
|
||||
#
|
||||
# # připravíme si odkaz na řádek, abychom do něj mohli doplnit body za jednotlivé úlohy
|
||||
# vysledky_resitele[v.resitel.id] = v
|
||||
#
|
||||
# # za každé řešení doplníme k příslušnému řešiteli a úloze body
|
||||
# for r in reseni:
|
||||
# vysledky_resitele[r.resitel.id].body_ulohy[problem_index[r.problem.id]] = r.body
|
||||
#
|
||||
# context['vysledkovka'] = vysledkovka
|
||||
# context['problemy'] = problemy
|
||||
# context['v_cisle_zadane'] = v_cisle_zadane
|
||||
# context['resene_problemy'] = resene_problemy
|
||||
# return context
|
||||
|
||||
class ArchivTemataView(generic.ListView):
|
||||
model = Problem
|
||||
template_name = 'seminar/archiv/temata.html'
|
||||
queryset = Problem.objects.filter(typ=Problem.TYP_TEMA, stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
queryset = Tema.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
|
||||
### Generovani vysledkovky
|
||||
|
||||
class CisloVysledkovkaView(CisloView):
|
||||
model = Cislo
|
||||
template_name = 'seminar/archiv/cislo_vysledkovka.tex'
|
||||
#content_type = 'application/x-tex; charset=UTF8'
|
||||
#umozni rovnou stahnout TeXovsky dokument
|
||||
content_type = 'text/plain; charset=UTF8'
|
||||
#vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
||||
|
||||
class RocnikVysledkovkaView(RocnikView):
|
||||
model = Rocnik
|
||||
template_name = 'seminar/archiv/rocnik_vysledkovka.tex'
|
||||
#content_type = 'application/x-tex; charset=UTF8'
|
||||
#umozni rovnou stahnout TeXovsky dokument
|
||||
content_type = 'text/plain; charset=UTF8'
|
||||
#vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
||||
#class CisloVysledkovkaView(CisloView):
|
||||
# model = Cislo
|
||||
# template_name = 'seminar/archiv/cislo_vysledkovka.tex'
|
||||
# #content_type = 'application/x-tex; charset=UTF8'
|
||||
# #umozni rovnou stahnout TeXovsky dokument
|
||||
# content_type = 'text/plain; charset=UTF8'
|
||||
# #vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
||||
#
|
||||
#class RocnikVysledkovkaView(RocnikView):
|
||||
# model = Rocnik
|
||||
# template_name = 'seminar/archiv/rocnik_vysledkovka.tex'
|
||||
# #content_type = 'application/x-tex; charset=UTF8'
|
||||
# #umozni rovnou stahnout TeXovsky dokument
|
||||
# content_type = 'text/plain; charset=UTF8'
|
||||
# #vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
||||
|
||||
### Generovani obalek
|
||||
class CisloObalkyStruct:
|
||||
|
@ -601,28 +602,29 @@ def obalkovaniView(request, rocnik, cislo):
|
|||
### Tituly
|
||||
|
||||
# TODO udelat neco jako get_objects_or_404
|
||||
def TitulyView(request, rocnik, cislo):
|
||||
rocnik_obj = Rocnik.objects.get(rocnik = rocnik)
|
||||
resitele = Resitel.objects.filter(rok_maturity__gte = rocnik_obj.prvni_rok)
|
||||
cislo_obj = Cislo.objects.get(rocnik = rocnik_obj, cislo = cislo)
|
||||
|
||||
asciijmena = []
|
||||
broken = False
|
||||
|
||||
for resitel in resitele:
|
||||
try:
|
||||
vys = VysledkyKCisluOdjakziva.objects.get(resitel = resitel, cislo = cislo_obj)
|
||||
body = vys.body
|
||||
except ObjectDoesNotExist:
|
||||
body = 0
|
||||
resitel.titul = resitel.get_titul(body)
|
||||
resitel.ascii = unicodedata.normalize('NFKD',resitel.jmeno+resitel.prijmeni).encode("ascii","ignore").replace(" ","")
|
||||
if resitel.ascii not in asciijmena:
|
||||
asciijmena.append(resitel.ascii)
|
||||
else:
|
||||
broken = True
|
||||
|
||||
return render(request, 'seminar/archiv/tituly.tex',{'resitele': resitele,'broken':broken},content_type="text/plain")
|
||||
# FIXME: prepsat, aby nepouzivalo VysledkyK...
|
||||
#def TitulyView(request, rocnik, cislo):
|
||||
# rocnik_obj = Rocnik.objects.get(rocnik = rocnik)
|
||||
# resitele = Resitel.objects.filter(rok_maturity__gte = rocnik_obj.prvni_rok)
|
||||
# cislo_obj = Cislo.objects.get(rocnik = rocnik_obj, cislo = cislo)
|
||||
#
|
||||
# asciijmena = []
|
||||
# broken = False
|
||||
#
|
||||
# for resitel in resitele:
|
||||
# try:
|
||||
# vys = VysledkyKCisluOdjakziva.objects.get(resitel = resitel, cislo = cislo_obj)
|
||||
# body = vys.body
|
||||
# except ObjectDoesNotExist:
|
||||
# body = 0
|
||||
# resitel.titul = resitel.get_titul(body)
|
||||
# resitel.ascii = unicodedata.normalize('NFKD',resitel.jmeno+resitel.prijmeni).encode("ascii","ignore").replace(" ","")
|
||||
# if resitel.ascii not in asciijmena:
|
||||
# asciijmena.append(resitel.ascii)
|
||||
# else:
|
||||
# broken = True
|
||||
#
|
||||
# return render(request, 'seminar/archiv/tituly.tex',{'resitele': resitele,'broken':broken},content_type="text/plain")
|
||||
|
||||
|
||||
### Soustredeni
|
||||
|
@ -702,15 +704,17 @@ def soustredeniUcastniciExportView(request,soustredeni):
|
|||
|
||||
### Články
|
||||
|
||||
# FIXME: clanky jsou vsechny, pokud budou i neresitelske, tak se take zobrazi
|
||||
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').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
queryset = Clanek.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__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').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
# FIXME: pokud chceme orgoclanky, tak nejak zavest do modelu a podle toho odkomentovat a upravit
|
||||
#class ClankyOrganizatorView(generic.ListView)<F12>:
|
||||
# model = Problem
|
||||
# template_name = 'seminar/clanky/organizatorske_clanky.html'
|
||||
# queryset = Problem.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
|
||||
|
||||
### Status
|
||||
|
@ -876,7 +880,7 @@ def texUploadView(request):
|
|||
|
||||
return JsonResponse({"db_id": pohadka.id})
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# Pošleme zpátky traceback, ať uživatel ví, v čem je problém
|
||||
tb = "".join(traceback.format_exception(type(e), e, sys.exc_info()[2]))
|
||||
return JsonResponse({"error": tb})
|
||||
|
|
Loading…
Reference in a new issue