|
@ -516,7 +516,7 @@ def LoginView(request): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ensure_csrf_cookie |
|
|
@ensure_csrf_cookie |
|
|
def TexUploadView(request): |
|
|
def texUploadView(request): |
|
|
|
|
|
|
|
|
def uloz_soubory(files, rocnik, cislo): |
|
|
def uloz_soubory(files, rocnik, cislo): |
|
|
for filename, f in files: |
|
|
for filename, f in files: |
|
@ -597,8 +597,7 @@ def TexUploadView(request): |
|
|
else: |
|
|
else: |
|
|
problem.text_zadani = html |
|
|
problem.text_zadani = html |
|
|
problem.nazev = meta["nazev"] |
|
|
problem.nazev = meta["nazev"] |
|
|
if "body" in meta: |
|
|
problem.body = meta["body"] |
|
|
problem.body = meta["body"] |
|
|
|
|
|
|
|
|
|
|
|
problem.save() |
|
|
problem.save() |
|
|
|
|
|
|
|
@ -624,3 +623,46 @@ def TexUploadView(request): |
|
|
# 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}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def texDownloadView(request, rocnik, cislo): |
|
|
|
|
|
"""View posílající JSON se zadanými a řešenými problémy pro založení čísla |
|
|
|
|
|
""" |
|
|
|
|
|
cislo = Cislo.objects.get(rocnik__rocnik=rocnik, cislo=cislo) |
|
|
|
|
|
zadane = Problem.objects.filter( |
|
|
|
|
|
cislo_zadani=cislo, |
|
|
|
|
|
stav=Problem.STAV_ZADANY |
|
|
|
|
|
) |
|
|
|
|
|
resene = Problem.objects.filter( |
|
|
|
|
|
cislo_reseni=cislo, |
|
|
|
|
|
stav=Problem.STAV_ZADANY, |
|
|
|
|
|
typ=Problem.TYP_ULOHA |
|
|
|
|
|
) |
|
|
|
|
|
pred_pohadky = Pohadka.objects.filter(uloha__cislo_zadani=cislo, pred=True) |
|
|
|
|
|
po_pohadky = Pohadka.objects.filter(uloha__cislo_zadani=cislo, pred=False) |
|
|
|
|
|
|
|
|
|
|
|
response = { |
|
|
|
|
|
"zadane": [ |
|
|
|
|
|
{ |
|
|
|
|
|
"nazev": p.nazev, |
|
|
|
|
|
"typ": p.typ, |
|
|
|
|
|
"kod": p.kod, |
|
|
|
|
|
"body": p.body, |
|
|
|
|
|
"zadani": p.text_zadani, |
|
|
|
|
|
"pred_pohadky": [x.text for x in pred_pohadky.filter(uloha=p)], |
|
|
|
|
|
"po_pohadky": [x.text for x in po_pohadky.filter(uloha=p)], |
|
|
|
|
|
} for p in zadane |
|
|
|
|
|
], |
|
|
|
|
|
"resene": [ |
|
|
|
|
|
{ |
|
|
|
|
|
"nazev": p.nazev, |
|
|
|
|
|
"typ": p.typ, |
|
|
|
|
|
"kod": p.kod, |
|
|
|
|
|
"body": p.body, |
|
|
|
|
|
"zadani": p.text_zadani, |
|
|
|
|
|
"reseni": p.text_reseni, |
|
|
|
|
|
"cislo_zadani": p.cislo_zadani.cislo, |
|
|
|
|
|
} for p in resene |
|
|
|
|
|
], |
|
|
|
|
|
} |
|
|
|
|
|
return JsonResponse(response) |
|
|