Změna na nový model a výsledkovky. Export by měl fungovat, ale je potřeba otestovat.
This commit is contained in:
parent
b0769058b3
commit
56317a5a84
1 changed files with 73 additions and 76 deletions
|
@ -11,7 +11,6 @@ from .ovvpfile import OvvpFile
|
|||
|
||||
class ExportIndexView(generic.View):
|
||||
def get(self, request):
|
||||
|
||||
ls = []
|
||||
for r in Rocnik.objects.filter(exportovat = True):
|
||||
url = reverse('seminar_export_rocnik', kwargs={'prvni_rok': r.prvni_rok})
|
||||
|
@ -63,7 +62,7 @@ class ExportSousView(generic.View):
|
|||
|
||||
return of.to_HttpResponse()
|
||||
|
||||
|
||||
# POZOR! Předělání na nový model neotestováno v reálu (ale zase jen drobné změny)
|
||||
class ExportRocnikView(generic.View):
|
||||
|
||||
def get(self, request, prvni_rok=None):
|
||||
|
@ -76,30 +75,28 @@ class ExportRocnikView(generic.View):
|
|||
|
||||
rocnik = get_object_or_404(Rocnik, prvni_rok=pr, exportovat=True)
|
||||
cislo = rocnik.posledni_zverejnena_vysledkovka_cislo()
|
||||
vysledky = VysledkyKCisluZaRocnik.objects.filter(cislo = cislo).select_related("resitel").order_by('-body').all()
|
||||
resitele = views.aktivniResitele(cislo.rocnik.rocnik, cislo.poradi, True)
|
||||
slovnik_body = secti_body_za_rocnik(cislo, resitele)
|
||||
_, setrizeni_resitele, setrizene_body = setrid_resitele_a_body(slovnik_body)
|
||||
|
||||
of = default_ovvpfile('MaM.rocnik', rocnik)
|
||||
of.headers['comment'] = u'MaM-Web export aktivnich resitelu rocniku {rocnik} do cisla {cislo}'.format(
|
||||
rocnik=rocnik, cislo=cislo)
|
||||
of.headers['comment'] = u'MaM-Web export aktivnich resitelu rocniku {rocnik} do cisla {cislo}'.format(rocnik=rocnik, cislo=cislo)
|
||||
of.columns = ['id', 'name', 'surname', 'gender', 'born', 'email', 'end-year',
|
||||
'street', 'town', 'postcode', 'country', 'spam-flag', 'spam-date',
|
||||
'school', 'school-name', 'points', 'rank',]
|
||||
|
||||
# počítání pořadí řešitelů
|
||||
posledni_body = 100000
|
||||
posledni_poradi = 0
|
||||
for vi in range(len(vysledky)):
|
||||
for i in range(len(setrizeni_resitele)):
|
||||
rd = setrizeni_resitele[i].export_row()
|
||||
|
||||
v = vysledky[vi]
|
||||
rd = v.resitel.export_row()
|
||||
|
||||
if posledni_body > v.body:
|
||||
posledni_body = v.body
|
||||
posledni_poradi = vi + 1
|
||||
if posledni_body > body[i]:
|
||||
posledni_body = body[i]
|
||||
posledni_poradi = i + 1
|
||||
rd['rank'] = posledni_poradi
|
||||
rd['points'] = v.body
|
||||
rd['points'] = body[i]
|
||||
|
||||
of.rows.append(rd)
|
||||
|
||||
return of.to_HttpResponse()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue