Browse Source

Exporty podle flagu 'exportovat' a oprava AESOP id akce

remotes/origin/vysl
Tomas Gavenciak 9 years ago
parent
commit
7bd2945dc3
  1. 27
      seminar/export.py
  2. 9
      seminar/models.py

27
seminar/export.py

@ -12,14 +12,12 @@ class ExportIndexView(generic.View):
def get(self, request): def get(self, request):
ls = [] ls = []
for r in Rocnik.objects.all(): for r in Rocnik.objects.filter(exportovat = True):
if r.verejna_cisla(): url = reverse('seminar_export_rocnik', kwargs={'prvni_rok': r.prvni_rok})
url = reverse('seminar_export_rocnik', kwargs={'prvni_rok': r.prvni_rok}) ls.append(url.split('/')[-1])
ls.append(url.split('/')[-1]) for s in Soustredeni.objects.filter(exportovat = True):
for s in Soustredeni.objects.all(): url = reverse('seminar_export_sous', kwargs={'datum_zacatku': s.datum_zacatku.isoformat()})
if s.ucastnici.count() >= 1 and s.verejne: ls.append(url.split('/')[-1])
url = reverse('seminar_export_sous', kwargs={'datum_zacatku': s.datum_zacatku.isoformat()})
ls.append(url.split('/')[-1])
return HttpResponse('\n'.join(ls) + '\n', content_type='text/plain; charset=utf-8') return HttpResponse('\n'.join(ls) + '\n', content_type='text/plain; charset=utf-8')
@ -45,9 +43,14 @@ class ExportSousView(generic.View):
if dz is None: if dz is None:
raise django.http.Http404() raise django.http.Http404()
s = get_object_or_404(Soustredeni, datum_zacatku=dz) s = get_object_or_404(Soustredeni, datum_zacatku=dz, exportovat=True)
of = default_ovvpfile('MaM.sous', s.rocnik) akce = {Soustredeni.TYP_JARNI: 'MaM.sous.jaro',
Soustredeni.TYP_PODZIMNI: 'MaM.sous.podzim',
Soustredeni.TYP_VIKEND: 'MaM.vikend',
}[s.typ]
of = default_ovvpfile(akce, s.rocnik)
of.headers['x-event-begin'] = s.datum_zacatku.isoformat() of.headers['x-event-begin'] = s.datum_zacatku.isoformat()
of.headers['x-event-end'] = s.datum_konce.isoformat() of.headers['x-event-end'] = s.datum_konce.isoformat()
of.headers['x-event-location'] = s.misto of.headers['x-event-location'] = s.misto
@ -70,8 +73,8 @@ class ExportRocnikView(generic.View):
if pr is None: if pr is None:
raise django.http.Http404() raise django.http.Http404()
rocnik = get_object_or_404(Rocnik, prvni_rok=pr) rocnik = get_object_or_404(Rocnik, prvni_rok=pr, exportovat=True)
cislo = rocnik.posledni_verejne_cislo() cislo = rocnik.posledni_zverejnena_vysledkovka_cislo()
vysledky = VysledkyKCislu.objects.filter(cislo = cislo).select_related("resitel").order_by('-body_celkem').all() vysledky = VysledkyKCislu.objects.filter(cislo = cislo).select_related("resitel").order_by('-body_celkem').all()
of = default_ovvpfile('MaM.rocnik', rocnik) of = default_ovvpfile('MaM.rocnik', rocnik)

9
seminar/models.py

@ -276,6 +276,15 @@ class Rocnik(SeminarModelBase):
vc = self.verejna_cisla() vc = self.verejna_cisla()
return vc[-1] if vc else None return vc[-1] if vc else None
def verejne_vysledkovky_cisla(self):
vc = list(self.cisla.filter(verejna_vysledkovka=True))
vc.sort(key=lambda c: c.cislo)
return vc
def posledni_zverejnena_vysledkovka_cislo(self):
vc = self.verejne_vysledkovky_cisla()
return vc[-1] if vc else None
def druhy_rok(self): def druhy_rok(self):
return self.prvni_rok + 1 return self.prvni_rok + 1

Loading…
Cancel
Save