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
|
scroll = 0
|
||||||
|
|
||||||
action = q.get('action')
|
action = q.get('action')
|
||||||
if (action == u''): # Přidej
|
if (action == ''): # Přidej
|
||||||
x = int(q.get('x'))
|
x = int(q.get('x'))
|
||||||
y = int(q.get('y'))
|
y = int(q.get('y'))
|
||||||
text = q.get('txt')
|
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 = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
|
||||||
op.save()
|
op.save()
|
||||||
self.send_email_notification_komentar(op, autor, text)
|
self.send_email_notification_komentar(op, autor, text)
|
||||||
elif (action == u'del'):
|
elif (action == 'del'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
op.delete()
|
op.delete()
|
||||||
elif (action == u'update'):
|
elif (action == 'update'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
text = q.get('txt')
|
text = q.get('txt')
|
||||||
op.autor = autor
|
op.autor = autor
|
||||||
op.text = text
|
op.text = text
|
||||||
op.save()
|
op.save()
|
||||||
elif (action == u'undone'):
|
elif (action == 'undone'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
op.status = op.STATUS_K_OPRAVE
|
op.status = op.STATUS_K_OPRAVE
|
||||||
op.save()
|
op.save()
|
||||||
elif (action == u'done'):
|
elif (action == 'done'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
op.status = op.STATUS_OPRAVENO
|
op.status = op.STATUS_OPRAVENO
|
||||||
op.save()
|
op.save()
|
||||||
elif (action == u'ready'):
|
elif (action == 'ready'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
op.status = op.STATUS_K_ZANESENI
|
op.status = op.STATUS_K_ZANESENI
|
||||||
op.save()
|
op.save()
|
||||||
elif (action == u'wontfix'):
|
elif (action == 'wontfix'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
op.status = op.STATUS_NENI_CHYBA
|
op.status = op.STATUS_NENI_CHYBA
|
||||||
op.save()
|
op.save()
|
||||||
elif (action == u'comment'):
|
elif (action == 'comment'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
op = Oprava.objects.get(id=id)
|
op = Oprava.objects.get(id=id)
|
||||||
text = q.get('txt')
|
text = q.get('txt')
|
||||||
kom = Komentar(oprava=op,autor=autor,text=text)
|
kom = Komentar(oprava=op,autor=autor,text=text)
|
||||||
kom.save()
|
kom.save()
|
||||||
self.send_email_notification_komentar(op, autor, text)
|
self.send_email_notification_komentar(op, autor, text)
|
||||||
elif (action == u'update-comment'):
|
elif (action == 'update-comment'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
kom = Komentar.objects.get(id=id)
|
kom = Komentar.objects.get(id=id)
|
||||||
text = q.get('txt')
|
text = q.get('txt')
|
||||||
kom.text = text
|
kom.text = text
|
||||||
kom.autor = autor
|
kom.autor = autor
|
||||||
kom.save()
|
kom.save()
|
||||||
elif (action == u'del-comment'):
|
elif (action == 'del-comment'):
|
||||||
id = int(q.get('id'))
|
id = int(q.get('id'))
|
||||||
kom = Komentar.objects.get(id=id)
|
kom = Komentar.objects.get(id=id)
|
||||||
kom.delete()
|
kom.delete()
|
||||||
elif (action == u'set-state'):
|
elif (action == 'set-state'):
|
||||||
pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
|
pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
|
||||||
if (q.get('state') == u'adding'):
|
if (q.get('state') == 'adding'):
|
||||||
pdf.status = pdf.STATUS_PRIDAVANI
|
pdf.status = pdf.STATUS_PRIDAVANI
|
||||||
elif (q.get('state') == u'comitting'):
|
elif (q.get('state') == 'comitting'):
|
||||||
pdf.status = pdf.STATUS_ZANASENI
|
pdf.status = pdf.STATUS_ZANASENI
|
||||||
elif (q.get('state') == u'deprecated'):
|
elif (q.get('state') == 'deprecated'):
|
||||||
pdf.status = pdf.STATUS_ZASTARALE
|
pdf.status = pdf.STATUS_ZASTARALE
|
||||||
pdf.save()
|
pdf.save()
|
||||||
context = self.get_context_data()
|
context = self.get_context_data()
|
||||||
|
@ -124,7 +124,7 @@ class KorekturyView(generic.TemplateView):
|
||||||
# parametry e-mailu
|
# parametry e-mailu
|
||||||
odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk)
|
odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk)
|
||||||
from_email = 'korekturovatko@mam.mff.cuni.cz'
|
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)
|
oprava.pdf.nazev)
|
||||||
text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\
|
text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\
|
||||||
\nodkaz do korekturovátka: {}\n\
|
\nodkaz do korekturovátka: {}\n\
|
||||||
|
@ -155,7 +155,7 @@ class KorekturyView(generic.TemplateView):
|
||||||
emails.discard(email)
|
emails.discard(email)
|
||||||
|
|
||||||
if not settings.SEND_EMAIL_NOTIFICATIONS:
|
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
|
return
|
||||||
|
|
||||||
send_mail(subject, text, from_email, list(emails))
|
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.safestring import mark_safe
|
||||||
from django.utils.html import escape
|
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
|
from seminar.models import Soustredeni
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ def newPrednaska(request):
|
||||||
# hlasovani se vztahuje k nejnovejsimu soustredeni
|
# hlasovani se vztahuje k nejnovejsimu soustredeni
|
||||||
sous = Soustredeni.objects.first()
|
sous = Soustredeni.objects.first()
|
||||||
seznam = Seznam.objects.filter(soustredeni = sous, stav = STAV_NAVRH).first()
|
seznam = Seznam.objects.filter(soustredeni = sous, stav = STAV_NAVRH).first()
|
||||||
print seznam
|
print(seznam)
|
||||||
# obsluha formulare
|
# obsluha formulare
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = NewPrednaskyForm(request.POST, request.FILES)
|
form = NewPrednaskyForm(request.POST, request.FILES)
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
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
|
from autocomplete_light import shortcuts as autocomplete_light
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ class ProblemInline(admin.TabularInline):
|
||||||
|
|
||||||
|
|
||||||
class ReseniKProblemuInline(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
|
model = Reseni
|
||||||
fields = ['resitel', 'forma', 'body', 'cislo_body', 'timestamp', 'poznamka']
|
fields = ['resitele', 'forma', 'body', 'cislo_body', 'timestamp', 'poznamka']
|
||||||
readonly_fields = ['timestamp']
|
readonly_fields = ['timestamp']
|
||||||
extra = 0
|
extra = 0
|
||||||
formfield_overrides = {
|
formfield_overrides = {
|
||||||
|
@ -136,7 +136,7 @@ class ReseniKProblemuInline(admin.TabularInline):
|
||||||
|
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
qs = super(ReseniKProblemuInline, self).get_queryset(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 ...)
|
# Potenciální DB HOG (cislo_body se dotazovalo na cisla pri kazdem zobrazeni jejich selectu ...)
|
||||||
def formfield_for_dbfield(self, db_field, **kwargs):
|
def formfield_for_dbfield(self, db_field, **kwargs):
|
||||||
|
@ -323,13 +323,13 @@ admin.site.register(Rocnik, RocnikAdmin)
|
||||||
### Reseni
|
### Reseni
|
||||||
|
|
||||||
class ReseniAdmin(VersionAdmin):
|
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 = [
|
fieldsets = [
|
||||||
(None, {'fields': ['problem', 'resitel', 'forma', 'body', 'cislo_body', 'timestamp']}),
|
(None, {'fields': ['problem', 'resitele', 'forma', 'body', 'cislo_body', 'timestamp']}),
|
||||||
(u'Poznámky', {'fields': ['poznamka']}),
|
(u'Poznámky', {'fields': ['poznamka']}),
|
||||||
]
|
]
|
||||||
readonly_fields = ['timestamp']
|
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']
|
list_filter = ['body', 'timestamp', 'forma']
|
||||||
search_fields = []
|
search_fields = []
|
||||||
inlines = [PrilohaReseniInline]
|
inlines = [PrilohaReseniInline]
|
||||||
|
@ -337,7 +337,7 @@ class ReseniAdmin(VersionAdmin):
|
||||||
|
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
qs = super(ReseniAdmin, self).get_queryset(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)
|
admin.site.register(Reseni, ReseniAdmin)
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ class PohadkaAdminForm(forms.ModelForm):
|
||||||
exclude = []
|
exclude = []
|
||||||
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
||||||
uloha = forms.ModelChoiceField(
|
uloha = forms.ModelChoiceField(
|
||||||
Problem.objects.filter(typ=Problem.TYP_ULOHA)
|
Uloha.objects.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -402,15 +402,15 @@ from autocomplete_light.contrib.taggit_field import TaggitField, TaggitWidget
|
||||||
|
|
||||||
|
|
||||||
class ProblemAdminForm(forms.ModelForm):
|
class ProblemAdminForm(forms.ModelForm):
|
||||||
text_zadani = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_zadani'))
|
#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_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_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False, **field_labels(Problem, 'text_org'))
|
||||||
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False)
|
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False)
|
||||||
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
|
||||||
opravovatel = UserModelChoiceField(User.objects.filter(is_staff=True), required=False)
|
opravovatel = UserModelChoiceField(User.objects.filter(is_staff=True), required=False)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Problem
|
model = Problem
|
||||||
exclude = []
|
exclude = ['nadproblem']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ProblemAdminForm, self).__init__(*args, **kwargs)
|
super(ProblemAdminForm, self).__init__(*args, **kwargs)
|
||||||
|
@ -476,7 +476,8 @@ class ProblemNavrhAdmin(ProblemAdmin):
|
||||||
get_form = get_form_predvypln_autora
|
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):
|
class ProblemZadanyAdmin(ProblemAdmin):
|
||||||
|
@ -529,27 +530,28 @@ class ProblemZadanyAdmin(ProblemAdmin):
|
||||||
|
|
||||||
get_form = get_form_predvypln_autora
|
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)
|
#admin.site.register(Problem, ProblemAdmin)
|
||||||
|
|
||||||
### Prispevek (k tematkum)
|
### Prispevek (k tematkum)
|
||||||
|
|
||||||
class PrispevekAdminForm(forms.ModelForm):
|
#class PrispevekAdminForm(forms.ModelForm):
|
||||||
text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
# text_org = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
||||||
**field_labels(Prispevek, 'text_org'))
|
# **field_labels(Prispevek, 'text_org'))
|
||||||
text_resitel = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
# text_resitel = forms.CharField(widget=CKEditorUploadingWidget(), required=False,
|
||||||
**field_labels(Prispevek, 'text_resitel'))
|
# **field_labels(Prispevek, 'text_resitel'))
|
||||||
|
#
|
||||||
class Meta:
|
# class Meta:
|
||||||
model = Prispevek
|
# model = Prispevek
|
||||||
exclude = []
|
# exclude = []
|
||||||
|
#
|
||||||
class PrispevekAdmin(VersionAdmin):
|
#class PrispevekAdmin(VersionAdmin):
|
||||||
form = PrispevekAdminForm
|
# form = PrispevekAdminForm
|
||||||
list_display = ['nazev', 'problem', 'reseni', 'zverejnit']
|
# list_display = ['nazev', 'problem', 'reseni', 'zverejnit']
|
||||||
|
#
|
||||||
admin.site.register(Prispevek, PrispevekAdmin)
|
#admin.site.register(Prispevek, PrispevekAdmin)
|
||||||
|
|
||||||
### Soustredeni
|
### Soustredeni
|
||||||
|
|
||||||
|
@ -664,7 +666,7 @@ deaktivovat_organizatory.short_description = 'Deaktivovat organizátory'
|
||||||
|
|
||||||
@admin.register(Organizator)
|
@admin.register(Organizator)
|
||||||
class OrganizatorAdmin(VersionAdmin):
|
class OrganizatorAdmin(VersionAdmin):
|
||||||
list_filter = ['organizuje_do_roku']
|
list_filter = ['organizuje_do']
|
||||||
list_display = [jmeno_organizatora, je_organizator_aktivni,]
|
list_display = [jmeno_organizatora, je_organizator_aktivni,]
|
||||||
actions = [zaktivovat_organizatory, deaktivovat_organizatory,]
|
actions = [zaktivovat_organizatory, deaktivovat_organizatory,]
|
||||||
|
|
||||||
|
|
|
@ -1019,6 +1019,27 @@ class Konfera(models.Model):
|
||||||
return force_unicode(u"%s: (%s)".format(self.nazev, self.soustredeni))
|
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)
|
@reversion.register(ignore_duplicates=True)
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import csv, codecs, cStringIO
|
import csv, codecs
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
class UTF8Recoder:
|
class UTF8Recoder:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,7 +2,7 @@ from django.conf.urls import * # NOQA
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.contrib.auth.decorators import user_passes_test
|
from django.contrib.auth.decorators import user_passes_test
|
||||||
from . import views, export
|
from . import views, export
|
||||||
from utils import staff_member_required
|
from .utils import staff_member_required
|
||||||
from django.views.generic.base import RedirectView
|
from django.views.generic.base import RedirectView
|
||||||
|
|
||||||
staff_member_required = user_passes_test(lambda u: u.is_staff)
|
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'^archiv/temata/$', views.ArchivTemataView.as_view()),
|
||||||
|
|
||||||
url(r'^rocnik/(?P<rocnik>\d+)/$', views.RocnikView.as_view(), name='seminar_rocnik'),
|
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+)/$', 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
|
# Soustredeni
|
||||||
url(
|
url(
|
||||||
|
@ -63,13 +63,13 @@ urlpatterns = [
|
||||||
# Zadani
|
# Zadani
|
||||||
url(r'^zadani/aktualni/$', views.AktualniZadaniView, name='seminar_aktualni_zadani'),
|
url(r'^zadani/aktualni/$', views.AktualniZadaniView, name='seminar_aktualni_zadani'),
|
||||||
url(r'^zadani/temata/$', views.ZadaniTemataView, name='seminar_temata'),
|
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'^$', views.TitulniStranaView.as_view(), name='titulni_strana'),
|
||||||
url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'),
|
url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'),
|
||||||
|
|
||||||
# Clanky
|
# Clanky
|
||||||
url(r'^clanky/resitel/$', views.ClankyResitelView.as_view(), name='clanky_resitel'),
|
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
|
# Aesop
|
||||||
url(r'^aesop-export/mam-rocnik-(?P<prvni_rok>\d+)\.csv$', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'),
|
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'),
|
url(r'^aesop-export/index.csv$', export.ExportIndexView.as_view(), name='seminar_export_index'),
|
||||||
|
|
||||||
# Stranky viditelne pouze pro orgy:
|
# Stranky viditelne pouze pro orgy:
|
||||||
url(
|
#url(
|
||||||
r'^rocnik/(?P<rocnik>\d+)/vysledkovka.tex$',
|
# r'^rocnik/(?P<rocnik>\d+)/vysledkovka.tex$',
|
||||||
staff_member_required(views.RocnikVysledkovkaView.as_view()),
|
# staff_member_required(views.RocnikVysledkovkaView.as_view()),
|
||||||
name='seminar_cislo_vysledkovka'
|
# name='seminar_cislo_vysledkovka'
|
||||||
),
|
#),
|
||||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/vysledkovka.tex$',
|
#url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/vysledkovka.tex$',
|
||||||
staff_member_required(views.CisloVysledkovkaView.as_view()), name='seminar_cislo_vysledkovka'),
|
# staff_member_required(views.CisloVysledkovkaView.as_view()), name='seminar_cislo_vysledkovka'),
|
||||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/obalky.pdf$',
|
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/obalky.pdf$',
|
||||||
staff_member_required(views.cisloObalkyView), name='seminar_cislo_obalky'),
|
staff_member_required(views.cisloObalkyView), name='seminar_cislo_obalky'),
|
||||||
|
|
||||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/tituly.tex$',
|
#url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/tituly.tex$',
|
||||||
staff_member_required(views.TitulyView), name='seminar_cislo_titul'),
|
# staff_member_required(views.TitulyView), name='seminar_cislo_titul'),
|
||||||
url(r'^stav$',
|
url(r'^stav$',
|
||||||
staff_member_required(views.StavDatabazeView), name='stav_databaze'),
|
staff_member_required(views.StavDatabazeView), name='stav_databaze'),
|
||||||
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/obalkovani$',
|
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.views.decorators.csrf import ensure_csrf_cookie
|
||||||
from django.contrib.auth import authenticate, login
|
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 Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek
|
||||||
from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||||
from . import utils
|
from . import utils
|
||||||
from .unicodecsv import UnicodeWriter
|
from .unicodecsv import UnicodeWriter
|
||||||
from .forms import NameForm
|
from .forms import NameForm
|
||||||
|
@ -68,29 +68,29 @@ def ZadaniTemataView(request):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def ZadaniAktualniVysledkovkaView(request):
|
#def ZadaniAktualniVysledkovkaView(request):
|
||||||
nastaveni = get_object_or_404(Nastaveni)
|
# nastaveni = get_object_or_404(Nastaveni)
|
||||||
# Aktualni verejna vysledkovka
|
# # Aktualni verejna vysledkovka
|
||||||
vysledkovka = vysledkovka_rocniku(nastaveni.aktualni_rocnik)
|
# vysledkovka = vysledkovka_rocniku(nastaveni.aktualni_rocnik)
|
||||||
# kdyz neni verejna vysledkovka, tak zobraz starou
|
# # kdyz neni verejna vysledkovka, tak zobraz starou
|
||||||
if not vysledkovka:
|
# if not vysledkovka:
|
||||||
try:
|
# try:
|
||||||
minuly_rocnik = Rocnik.objects.get(
|
# minuly_rocnik = Rocnik.objects.get(
|
||||||
prvni_rok=(nastaveni.aktualni_rocnik.prvni_rok-1))
|
# prvni_rok=(nastaveni.aktualni_rocnik.prvni_rok-1))
|
||||||
vysledkovka = vysledkovka_rocniku(minuly_rocnik)
|
# vysledkovka = vysledkovka_rocniku(minuly_rocnik)
|
||||||
except ObjectDoesNotExist:
|
# except ObjectDoesNotExist:
|
||||||
pass
|
# pass
|
||||||
# vysledkovka s neverejnyma vysledkama
|
# # vysledkovka s neverejnyma vysledkama
|
||||||
vysledkovka_s_neverejnymi = vysledkovka_rocniku(nastaveni.aktualni_rocnik, jen_verejne=False)
|
# vysledkovka_s_neverejnymi = vysledkovka_rocniku(nastaveni.aktualni_rocnik, jen_verejne=False)
|
||||||
return render(
|
# return render(
|
||||||
request,
|
# request,
|
||||||
'seminar/zadani/AktualniVysledkovka.html',
|
# 'seminar/zadani/AktualniVysledkovka.html',
|
||||||
{
|
# {
|
||||||
'nastaveni': nastaveni,
|
# 'nastaveni': nastaveni,
|
||||||
'vysledkovka': vysledkovka,
|
# 'vysledkovka': vysledkovka,
|
||||||
'vysledkovka_s_neverejnymi': vysledkovka_s_neverejnymi,
|
# 'vysledkovka_s_neverejnymi': vysledkovka_s_neverejnymi,
|
||||||
}
|
# }
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
### Titulni strana
|
### Titulni strana
|
||||||
|
@ -143,10 +143,10 @@ class StareNovinkyView(generic.ListView):
|
||||||
|
|
||||||
|
|
||||||
# Organizatori
|
# Organizatori
|
||||||
def aktivniOrganizatori(rok=date.today().year):
|
def aktivniOrganizatori(datum=date.today()):
|
||||||
return Organizator.objects.exclude(
|
return Organizator.objects.exclude(
|
||||||
organizuje_do_roku__isnull=False,
|
organizuje_do__isnull=False,
|
||||||
organizuje_do_roku__lt=rok
|
organizuje_do__lt=datum
|
||||||
).order_by('user__first_name')
|
).order_by('user__first_name')
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ class CojemamOrganizatoriStariView(generic.ListView):
|
||||||
model = Organizator
|
model = Organizator
|
||||||
template_name = 'seminar/cojemam/organizatori.html'
|
template_name = 'seminar/cojemam/organizatori.html'
|
||||||
queryset = Organizator.objects.exclude(
|
queryset = Organizator.objects.exclude(
|
||||||
id__in=aktivniOrganizatori()).order_by('-organizuje_do_roku')
|
id__in=aktivniOrganizatori()).order_by('-organizuje_do')
|
||||||
|
|
||||||
### Archiv
|
### Archiv
|
||||||
|
|
||||||
|
@ -273,62 +273,62 @@ def sloupec_s_poradim(vysledky):
|
||||||
return poradi_l
|
return poradi_l
|
||||||
|
|
||||||
|
|
||||||
def vysledkovka_rocniku(rocnik, jen_verejne=True):
|
#def vysledkovka_rocniku(rocnik, jen_verejne=True):
|
||||||
"""Přebírá ročník (např. context["rocnik"]) a vrací výsledkovou listinu ve
|
# """Přebírá ročník (např. context["rocnik"]) a vrací výsledkovou listinu ve
|
||||||
formě vhodné pro šablonu "seminar/vysledkovka_rocniku.html"
|
# formě vhodné pro šablonu "seminar/vysledkovka_rocniku.html"
|
||||||
"""
|
# """
|
||||||
|
#
|
||||||
#vyberu vsechny vysledky z rocniku
|
# #vyberu vsechny vysledky z rocniku
|
||||||
cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__rocnik=rocnik).order_by('cislo')
|
# cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__rocnik=rocnik).order_by('cislo')
|
||||||
if jen_verejne:
|
# if jen_verejne:
|
||||||
cisla_v_rocniku = cisla_v_rocniku.filter(cislo__verejna_vysledkovka=True)
|
# cisla_v_rocniku = cisla_v_rocniku.filter(cislo__verejna_vysledkovka=True)
|
||||||
|
#
|
||||||
#pokud žádné nejsou, výsledkovka se nezobrazí
|
# #pokud žádné nejsou, výsledkovka se nezobrazí
|
||||||
if not cisla_v_rocniku:
|
# if not cisla_v_rocniku:
|
||||||
return None
|
# return None
|
||||||
|
#
|
||||||
#vybere vsechny vysledky z posledniho (verejneho) cisla a setridi sestupne dle bodu
|
# #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'))
|
# vysledky = list(cisla_v_rocniku.filter(cislo = cisla_v_rocniku[0].cislo).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno').select_related('resitel'))
|
||||||
|
#
|
||||||
class Vysledkovka:
|
# class Vysledkovka:
|
||||||
def __init__(self):
|
# def __init__(self):
|
||||||
self.rocnik = rocnik.rocnik
|
# self.rocnik = rocnik.rocnik
|
||||||
self.radky = []
|
# self.radky = []
|
||||||
self.cisla = []
|
# self.cisla = []
|
||||||
|
#
|
||||||
vysledkovka = Vysledkovka()
|
# vysledkovka = Vysledkovka()
|
||||||
vysledkovka.cisla = (rocnik.verejne_vysledkovky_cisla() if jen_verejne else rocnik.cisla.all().order_by('cislo'))
|
# 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ě
|
# # doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
|
||||||
for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
|
# for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
|
||||||
v.poradi = poradi
|
# v.poradi = poradi
|
||||||
v.resitel.rocnik = v.resitel.rocnik(rocnik)
|
# v.resitel.rocnik = v.resitel.rocnik(rocnik)
|
||||||
|
#
|
||||||
verejne_vysl_odjakziva = VysledkyKCisluOdjakziva.objects.filter(cislo__rocnik=rocnik, cislo=cisla_v_rocniku[0].cislo)
|
# verejne_vysl_odjakziva = VysledkyKCisluOdjakziva.objects.filter(cislo__rocnik=rocnik, cislo=cisla_v_rocniku[0].cislo)
|
||||||
if jen_verejne:
|
# if jen_verejne:
|
||||||
verejne_vysl_odjakziva = verejne_vysl_odjakziva.filter(cislo__verejna_vysledkovka=True)
|
# verejne_vysl_odjakziva = verejne_vysl_odjakziva.filter(cislo__verejna_vysledkovka=True)
|
||||||
|
#
|
||||||
v.body_odjakziva = verejne_vysl_odjakziva.filter(resitel = v.resitel)[0].body
|
# v.body_odjakziva = verejne_vysl_odjakziva.filter(resitel = v.resitel)[0].body
|
||||||
v.titul = v.resitel.get_titul(v.body_odjakziva)
|
# v.titul = v.resitel.get_titul(v.body_odjakziva)
|
||||||
v.body_rocnik = v.body
|
# v.body_rocnik = v.body
|
||||||
v.body_cisla = []
|
# v.body_cisla = []
|
||||||
|
#
|
||||||
#pokud pro dany rok a cislo nema resitel vysledky, ma defaultne 0
|
# #pokud pro dany rok a cislo nema resitel vysledky, ma defaultne 0
|
||||||
for cis in vysledkovka.cisla:
|
# for cis in vysledkovka.cisla:
|
||||||
if not jen_verejne or cis.verejna_vysledkovka:
|
# if not jen_verejne or cis.verejna_vysledkovka:
|
||||||
#seznam vysledku se spravnym rocnikem a cislem pro resitele
|
# #seznam vysledku se spravnym rocnikem a cislem pro resitele
|
||||||
#zobrazim jen je-li vysledkovka verejna
|
# #zobrazim jen je-li vysledkovka verejna
|
||||||
body_za_cislo = VysledkyZaCislo.objects.filter(cislo__rocnik=rocnik).filter(cislo = cis).filter(resitel = v.resitel)
|
# body_za_cislo = VysledkyZaCislo.objects.filter(cislo__rocnik=rocnik).filter(cislo = cis).filter(resitel = v.resitel)
|
||||||
if body_za_cislo:
|
# if body_za_cislo:
|
||||||
#neprazdne vysledky by mely obsahovat prave jeden vysledek
|
# #neprazdne vysledky by mely obsahovat prave jeden vysledek
|
||||||
v.body_cisla.append(body_za_cislo[0].body)
|
# v.body_cisla.append(body_za_cislo[0].body)
|
||||||
else:
|
# else:
|
||||||
#resitel nema za cislo body
|
# #resitel nema za cislo body
|
||||||
v.body_cisla.append(0)
|
# v.body_cisla.append(0)
|
||||||
|
#
|
||||||
vysledkovka.radky.append(v)
|
# vysledkovka.radky.append(v)
|
||||||
|
#
|
||||||
return vysledkovka
|
# return vysledkovka
|
||||||
|
|
||||||
|
|
||||||
class RocnikView(generic.DetailView):
|
class RocnikView(generic.DetailView):
|
||||||
|
@ -352,8 +352,8 @@ class RocnikView(generic.DetailView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(RocnikView, self).get_context_data(**kwargs)
|
context = super(RocnikView, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
context['vysledkovka'] = vysledkovka_rocniku(context["rocnik"])
|
#context['vysledkovka'] = vysledkovka_rocniku(context["rocnik"])
|
||||||
context['vysledkovka_s_neverejnymi'] = vysledkovka_rocniku(context["rocnik"], jen_verejne=False)
|
#context['vysledkovka_s_neverejnymi'] = vysledkovka_rocniku(context["rocnik"], jen_verejne=False)
|
||||||
context['temata_v_rocniku'] = verejna_temata(context["rocnik"])
|
context['temata_v_rocniku'] = verejna_temata(context["rocnik"])
|
||||||
|
|
||||||
return context
|
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')
|
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class PrispevekView(generic.DetailView):
|
## Prispevek byl zrusen, mozna ale bude podobny nahled na neco jineho.
|
||||||
model = Prispevek
|
#class PrispevekView(generic.DetailView):
|
||||||
template_name = 'seminar/archiv/prispevek.html'
|
# model = Prispevek
|
||||||
|
# template_name = 'seminar/archiv/prispevek.html'
|
||||||
# Vlastni ziskavani objektu z databaze podle prispevku
|
#
|
||||||
# pokud je prispevek neverejny zobrazi se jenom orgum
|
# # Vlastni ziskavani objektu z databaze podle prispevku
|
||||||
def get_object(self, queryset=None):
|
# # pokud je prispevek neverejny zobrazi se jenom orgum
|
||||||
if queryset is None:
|
# def get_object(self, queryset=None):
|
||||||
queryset = self.get_queryset()
|
# if queryset is None:
|
||||||
problem_arg = self.kwargs.get('pk')
|
# queryset = self.get_queryset()
|
||||||
prispevek_arg = self.kwargs.get('prispevek')
|
# problem_arg = self.kwargs.get('pk')
|
||||||
queryset = queryset.filter(pk=prispevek_arg)
|
# prispevek_arg = self.kwargs.get('prispevek')
|
||||||
|
# queryset = queryset.filter(pk=prispevek_arg)
|
||||||
try:
|
#
|
||||||
obj = queryset.get()
|
# try:
|
||||||
except queryset.model.DoesNotExist:
|
# obj = queryset.get()
|
||||||
raise Http404(_("No %(verbose_name)s found matching the query") %
|
# except queryset.model.DoesNotExist:
|
||||||
{'verbose_name': queryset.model._meta.verbose_name})
|
# 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
|
# if self.request.user.is_staff or obj.zverejnit:
|
||||||
else:
|
# return obj
|
||||||
raise Http404()
|
# else:
|
||||||
|
# raise Http404()
|
||||||
def get_context_data(self, **kwargs):
|
#
|
||||||
context = super(PrispevekView, self).get_context_data(**kwargs)
|
# def get_context_data(self, **kwargs):
|
||||||
# snaho o ziskani titulu
|
# context = super(PrispevekView, self).get_context_data(**kwargs)
|
||||||
titul = ''
|
# # snaho o ziskani titulu
|
||||||
try:
|
# titul = ''
|
||||||
resitel = context['prispevek'].reseni.resitel
|
# try:
|
||||||
cislo = context['prispevek'].reseni.cislo_body
|
# resitel = context['prispevek'].reseni.resitel
|
||||||
body = VysledkyKCisluOdjakziva.objects.get(resitel=resitel,
|
# cislo = context['prispevek'].reseni.cislo_body
|
||||||
cislo=cislo).body
|
# body = VysledkyKCisluOdjakziva.objects.get(resitel=resitel,
|
||||||
titul = resitel.get_titul(body)
|
# cislo=cislo).body
|
||||||
except:
|
# titul = resitel.get_titul(body)
|
||||||
pass
|
# except:
|
||||||
context['titul'] = titul
|
# pass
|
||||||
return context
|
# context['titul'] = titul
|
||||||
|
# return context
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RadekVysledkovky(object):
|
class RadekVysledkovky(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class CisloView(generic.DetailView):
|
#class CisloView(generic.DetailView):
|
||||||
model = Cislo
|
# model = Cislo
|
||||||
template_name = 'seminar/archiv/cislo.html'
|
# template_name = 'seminar/archiv/cislo.html'
|
||||||
|
#
|
||||||
# Vlastni ziskavani objektu z databaze podle (Rocnik.rocnik)
|
# # Vlastni ziskavani objektu z databaze podle (Rocnik.rocnik)
|
||||||
def get_object(self, queryset=None):
|
# def get_object(self, queryset=None):
|
||||||
if queryset is None:
|
# if queryset is None:
|
||||||
queryset = self.get_queryset()
|
# queryset = self.get_queryset()
|
||||||
rocnik_arg = self.kwargs.get('rocnik')
|
# rocnik_arg = self.kwargs.get('rocnik')
|
||||||
cislo_arg = self.kwargs.get('cislo')
|
# cislo_arg = self.kwargs.get('cislo')
|
||||||
queryset = queryset.filter(rocnik__rocnik=rocnik_arg, cislo=cislo_arg)
|
# queryset = queryset.filter(rocnik__rocnik=rocnik_arg, cislo=cislo_arg)
|
||||||
|
#
|
||||||
try:
|
# try:
|
||||||
obj = queryset.get()
|
# obj = queryset.get()
|
||||||
except queryset.model.DoesNotExist:
|
# except queryset.model.DoesNotExist:
|
||||||
raise Http404(_("No %(verbose_name)s found matching the query") %
|
# raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||||
{'verbose_name': queryset.model._meta.verbose_name})
|
# {'verbose_name': queryset.model._meta.verbose_name})
|
||||||
return obj
|
# return obj
|
||||||
|
#
|
||||||
|
#
|
||||||
def get_context_data(self, **kwargs):
|
# def get_context_data(self, **kwargs):
|
||||||
context = super(CisloView, self).get_context_data(**kwargs)
|
# context = super(CisloView, self).get_context_data(**kwargs)
|
||||||
|
#
|
||||||
vysledky = VysledkyKCisluZaRocnik.objects.filter(cislo = context['cislo']).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno')
|
# 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")
|
# 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 ú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]
|
# 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')
|
# 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')
|
# resene_problemy = Problem.objects.filter(cislo_reseni=context['cislo']).filter(typ__in=typy_skutecne_zadanych).order_by('cislo_zadani__cislo', 'kod')
|
||||||
|
#
|
||||||
poradi_typu = {
|
# poradi_typu = {
|
||||||
Problem.TYP_ULOHA: 1,
|
# Problem.TYP_ULOHA: 1,
|
||||||
Problem.TYP_SERIAL: 2,
|
# Problem.TYP_SERIAL: 2,
|
||||||
Problem.TYP_ORG_CLANEK: 3,
|
# Problem.TYP_ORG_CLANEK: 3,
|
||||||
Problem.TYP_TEMA: 4,
|
# Problem.TYP_TEMA: 4,
|
||||||
Problem.TYP_RES_CLANEK: 5
|
# 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()))
|
# 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
|
# #setridi problemy podle typu a poradi zadani
|
||||||
problem_index = {}
|
# problem_index = {}
|
||||||
for i in range(len(problemy)):
|
# for i in range(len(problemy)):
|
||||||
problem_index[problemy[i].id] = i
|
# problem_index[problemy[i].id] = i
|
||||||
#umoznuje zjistit index podle id problemu
|
# #umoznuje zjistit index podle id problemu
|
||||||
|
#
|
||||||
vysledky_resitele = {}
|
# vysledky_resitele = {}
|
||||||
vysledkovka = []
|
# vysledkovka = []
|
||||||
|
#
|
||||||
# doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
|
# # doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
|
||||||
for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
|
# for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
|
||||||
v.poradi = poradi
|
# v.poradi = poradi
|
||||||
v.body_celkem_rocnik = v.body
|
# v.body_celkem_rocnik = v.body
|
||||||
v.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
|
# v.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
|
||||||
v.resitel.rocnik = v.resitel.rocnik(v.cislo.rocnik)
|
# 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
|
# # je tady '', aby se nezobrazovala 0, pokud se řešitel o řešení úlohy ani nepokusil
|
||||||
v.body_ulohy = [''] * len(problemy)
|
# v.body_ulohy = [''] * len(problemy)
|
||||||
|
#
|
||||||
v.titul = v.resitel.get_titul(v.body_celkem_odjakziva)
|
# v.titul = v.resitel.get_titul(v.body_celkem_odjakziva)
|
||||||
|
#
|
||||||
body_cislo_q = VysledkyZaCislo.objects.filter(resitel=v.resitel, cislo=context['cislo'])
|
# 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
|
# v.body_cislo = body_cislo_q[0].body if body_cislo_q else 0
|
||||||
|
#
|
||||||
vysledkovka.append(v)
|
# vysledkovka.append(v)
|
||||||
|
#
|
||||||
# připravíme si odkaz na řádek, abychom do něj mohli doplnit body za jednotlivé úlohy
|
# # připravíme si odkaz na řádek, abychom do něj mohli doplnit body za jednotlivé úlohy
|
||||||
vysledky_resitele[v.resitel.id] = v
|
# vysledky_resitele[v.resitel.id] = v
|
||||||
|
#
|
||||||
# za každé řešení doplníme k příslušnému řešiteli a úloze body
|
# # za každé řešení doplníme k příslušnému řešiteli a úloze body
|
||||||
for r in reseni:
|
# for r in reseni:
|
||||||
vysledky_resitele[r.resitel.id].body_ulohy[problem_index[r.problem.id]] = r.body
|
# vysledky_resitele[r.resitel.id].body_ulohy[problem_index[r.problem.id]] = r.body
|
||||||
|
#
|
||||||
context['vysledkovka'] = vysledkovka
|
# context['vysledkovka'] = vysledkovka
|
||||||
context['problemy'] = problemy
|
# context['problemy'] = problemy
|
||||||
context['v_cisle_zadane'] = v_cisle_zadane
|
# context['v_cisle_zadane'] = v_cisle_zadane
|
||||||
context['resene_problemy'] = resene_problemy
|
# context['resene_problemy'] = resene_problemy
|
||||||
return context
|
# return context
|
||||||
|
|
||||||
class ArchivTemataView(generic.ListView):
|
class ArchivTemataView(generic.ListView):
|
||||||
model = Problem
|
model = Problem
|
||||||
template_name = 'seminar/archiv/temata.html'
|
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
|
### Generovani vysledkovky
|
||||||
|
|
||||||
class CisloVysledkovkaView(CisloView):
|
#class CisloVysledkovkaView(CisloView):
|
||||||
model = Cislo
|
# model = Cislo
|
||||||
template_name = 'seminar/archiv/cislo_vysledkovka.tex'
|
# template_name = 'seminar/archiv/cislo_vysledkovka.tex'
|
||||||
#content_type = 'application/x-tex; charset=UTF8'
|
# #content_type = 'application/x-tex; charset=UTF8'
|
||||||
#umozni rovnou stahnout TeXovsky dokument
|
# #umozni rovnou stahnout TeXovsky dokument
|
||||||
content_type = 'text/plain; charset=UTF8'
|
# content_type = 'text/plain; charset=UTF8'
|
||||||
#vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
# #vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
||||||
|
#
|
||||||
class RocnikVysledkovkaView(RocnikView):
|
#class RocnikVysledkovkaView(RocnikView):
|
||||||
model = Rocnik
|
# model = Rocnik
|
||||||
template_name = 'seminar/archiv/rocnik_vysledkovka.tex'
|
# template_name = 'seminar/archiv/rocnik_vysledkovka.tex'
|
||||||
#content_type = 'application/x-tex; charset=UTF8'
|
# #content_type = 'application/x-tex; charset=UTF8'
|
||||||
#umozni rovnou stahnout TeXovsky dokument
|
# #umozni rovnou stahnout TeXovsky dokument
|
||||||
content_type = 'text/plain; charset=UTF8'
|
# content_type = 'text/plain; charset=UTF8'
|
||||||
#vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
# #vypise na stranku textovy obsah vyTeXane vysledkovky k okopirovani
|
||||||
|
|
||||||
### Generovani obalek
|
### Generovani obalek
|
||||||
class CisloObalkyStruct:
|
class CisloObalkyStruct:
|
||||||
|
@ -601,28 +602,29 @@ def obalkovaniView(request, rocnik, cislo):
|
||||||
### Tituly
|
### Tituly
|
||||||
|
|
||||||
# TODO udelat neco jako get_objects_or_404
|
# TODO udelat neco jako get_objects_or_404
|
||||||
def TitulyView(request, rocnik, cislo):
|
# FIXME: prepsat, aby nepouzivalo VysledkyK...
|
||||||
rocnik_obj = Rocnik.objects.get(rocnik = rocnik)
|
#def TitulyView(request, rocnik, cislo):
|
||||||
resitele = Resitel.objects.filter(rok_maturity__gte = rocnik_obj.prvni_rok)
|
# rocnik_obj = Rocnik.objects.get(rocnik = rocnik)
|
||||||
cislo_obj = Cislo.objects.get(rocnik = rocnik_obj, cislo = cislo)
|
# resitele = Resitel.objects.filter(rok_maturity__gte = rocnik_obj.prvni_rok)
|
||||||
|
# cislo_obj = Cislo.objects.get(rocnik = rocnik_obj, cislo = cislo)
|
||||||
asciijmena = []
|
#
|
||||||
broken = False
|
# asciijmena = []
|
||||||
|
# broken = False
|
||||||
for resitel in resitele:
|
#
|
||||||
try:
|
# for resitel in resitele:
|
||||||
vys = VysledkyKCisluOdjakziva.objects.get(resitel = resitel, cislo = cislo_obj)
|
# try:
|
||||||
body = vys.body
|
# vys = VysledkyKCisluOdjakziva.objects.get(resitel = resitel, cislo = cislo_obj)
|
||||||
except ObjectDoesNotExist:
|
# body = vys.body
|
||||||
body = 0
|
# except ObjectDoesNotExist:
|
||||||
resitel.titul = resitel.get_titul(body)
|
# body = 0
|
||||||
resitel.ascii = unicodedata.normalize('NFKD',resitel.jmeno+resitel.prijmeni).encode("ascii","ignore").replace(" ","")
|
# resitel.titul = resitel.get_titul(body)
|
||||||
if resitel.ascii not in asciijmena:
|
# resitel.ascii = unicodedata.normalize('NFKD',resitel.jmeno+resitel.prijmeni).encode("ascii","ignore").replace(" ","")
|
||||||
asciijmena.append(resitel.ascii)
|
# if resitel.ascii not in asciijmena:
|
||||||
else:
|
# asciijmena.append(resitel.ascii)
|
||||||
broken = True
|
# else:
|
||||||
|
# broken = True
|
||||||
return render(request, 'seminar/archiv/tituly.tex',{'resitele': resitele,'broken':broken},content_type="text/plain")
|
#
|
||||||
|
# return render(request, 'seminar/archiv/tituly.tex',{'resitele': resitele,'broken':broken},content_type="text/plain")
|
||||||
|
|
||||||
|
|
||||||
### Soustredeni
|
### Soustredeni
|
||||||
|
@ -702,15 +704,17 @@ def soustredeniUcastniciExportView(request,soustredeni):
|
||||||
|
|
||||||
### Články
|
### Články
|
||||||
|
|
||||||
|
# FIXME: clanky jsou vsechny, pokud budou i neresitelske, tak se take zobrazi
|
||||||
class ClankyResitelView(generic.ListView):
|
class ClankyResitelView(generic.ListView):
|
||||||
model = Problem
|
model = Problem
|
||||||
template_name = 'seminar/clanky/resitelske_clanky.html'
|
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):
|
# FIXME: pokud chceme orgoclanky, tak nejak zavest do modelu a podle toho odkomentovat a upravit
|
||||||
model = Problem
|
#class ClankyOrganizatorView(generic.ListView)<F12>:
|
||||||
template_name = 'seminar/clanky/organizatorske_clanky.html'
|
# model = Problem
|
||||||
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')
|
# 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
|
### Status
|
||||||
|
@ -876,7 +880,7 @@ def texUploadView(request):
|
||||||
|
|
||||||
return JsonResponse({"db_id": pohadka.id})
|
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
|
# 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]))
|
tb = "".join(traceback.format_exception(type(e), e, sys.exc_info()[2]))
|
||||||
return JsonResponse({"error": tb})
|
return JsonResponse({"error": tb})
|
||||||
|
|
Loading…
Reference in a new issue