upravy_exportu #91
2 changed files with 32 additions and 9 deletions
|
@ -5,6 +5,17 @@
|
|||
|
||||
<h2><strong>Export lidí</strong></h2>
|
||||
|
||||
<p>Vyberte pole, které chcete exportovat</p>
|
||||
|
||||
<p>
|
||||
<label>( Jméno: <input class="field-check" data-value="jmeno" type="checkbox" checked>)</label>
|
||||
<label>( Příjmení: <input class="field-check" data-value="prijmeni" type="checkbox" checked>)</label>
|
||||
<label>( E-mail <input class="field-check" data-value="email" type="checkbox" checked>)</label>
|
||||
<label>( Telefon <input class="field-check" data-value="telefon" type="checkbox" checked>)</label>
|
||||
<label>( Ulice <input class="field-check" data-value="ulice" type="checkbox">)</label>
|
||||
<label>( Město <input class="field-check" data-value="mesto" type="checkbox">)</label>
|
||||
<label>( PSČ <input class="field-check" data-value="psc" type="checkbox">)</label>
|
||||
</p>
|
||||
|
||||
<select name="select-one" id="select-one">
|
||||
<option value="0">---</option>
|
||||
<option value="1">Řešitelé čísla</option>
|
||||
|
@ -77,12 +88,16 @@
|
|||
})
|
||||
|
||||
download_button.addEventListener('click', (e) => {
|
||||
// uzivatele vybrana pole
|
||||
const fields = Array.from(document.getElementsByClassName('field-check'))
|
||||
.filter(e => e.checked)
|
||||
.map(e => e.getAttribute('data-value'))
|
||||
console.log(fields)
|
||||
if (select_two.innerHTML == '') {
|
||||
window.location.href = "/profil/exporty_lidi/get_csv_only_one_step/" + select_one.value
|
||||
window.location.href = "/profil/exporty_lidi/get_csv_only_one_step/" + select_one.value + "?fields=" + fields.join(',')
|
||||
} else {
|
||||
window.location.href = "/profil/exporty_lidi/get_csv/" + select_one.value + "/" + select_two.value
|
||||
window.location.href = "/profil/exporty_lidi/get_csv/" + select_one.value + "/" + select_two.value + "?fields=" + fields.join(',')
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -172,19 +172,27 @@ def get_export_options(request, type):
|
|||
return HttpResponse(json.dumps(data), content_type='application/json')
|
||||
|
||||
def download_export_csv_only_first_step(request, type):
|
||||
zelvuska
commented
Takže když nastala chyba, tak to udělá něco náhodného? Takže když nastala chyba, tak to udělá něco náhodného?
ticvac
commented
Jako... ona nenastala chyba, uživatel si zažádal o prázdné info... dostane to, co je nastaveno defaultně Jako... ona nenastala chyba, uživatel si zažádal o prázdné info... dostane to, co je nastaveno defaultně
zelvuska
commented
To právě není úplně pravda. Někde nastala chyba, takže jsi dostal špatná data, a vracíš něco, co tomu neodpovídá. To právě není úplně pravda. Někde nastala chyba, takže jsi dostal špatná data, a vracíš něco, co tomu neodpovídá.
|
||||
fields = request.GET.get('fields').split(',')
|
||||
if type == 3:
|
||||
response = dataResiteluCsvResponse(tvorba_utils.resitele_co_neodmaturovali())
|
||||
resitele = tvorba_utils.resitele_co_neodmaturovali()
|
||||
resiteleOsoby = Osoba.objects.filter(resitel__in=resitele)
|
||||
response = dataOsobCsvResponse(resiteleOsoby, columns=fields)
|
||||
response['Content-Disposition'] = 'attachment; filename="resitele_co_neodmaturovali.csv"'
|
||||
return response
|
||||
|
||||
ledoian
commented
Uhh, a když Uhh, a když `type != 3`, tak se stane co? A co je vůbec `_only_first_step` sémanticky?
|
||||
def download_export_csv(request, type, id):
|
||||
fields = request.GET.get('fields').split(',')
|
||||
if type == PrvniTypExportu.CISLA.value:
|
||||
response = dataResiteluCsvResponse(tvorba_utils.resi_cislo(Cislo.objects.get(id=id)))
|
||||
resitele = tvorba_utils.resi_cislo(Cislo.objects.get(id=id))
|
||||
resiteleOsoby = Osoba.objects.filter(resitel__in=resitele)
|
||||
response = dataOsobCsvResponse(resiteleOsoby, columns=fields)
|
||||
name = str(Cislo.objects.get(id=id)).replace(" ", "_") + "_resitele_cisla.csv"
|
||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||
return response
|
||||
if type == PrvniTypExportu.ROCNIKU.value:
|
||||
response = dataResiteluCsvResponse(tvorba_utils.resi_v_rocniku(Rocnik.objects.get(id=id)))
|
||||
resitele = tvorba_utils.resi_v_rocniku(Rocnik.objects.get(id=id))
|
||||
resiteleOsoby = Osoba.objects.filter(resitel__in=resitele)
|
||||
response = dataOsobCsvResponse(resiteleOsoby, columns=fields)
|
||||
name = str(Rocnik.objects.get(id=id)).replace(" ", "_") + "_resitele_rocniku.csv"
|
||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||
return response
|
||||
|
@ -192,15 +200,15 @@ def download_export_csv(request, type, id):
|
|||
soustredeni = Soustredeni.objects.get(id=id)
|
||||
organizatori = soustredeni.organizatori.all()
|
||||
organizatoriOsoby = Osoba.objects.filter(org__in=organizatori)
|
||||
response = dataOsobCsvResponse(organizatoriOsoby, columns=("jmeno", "prijmeni", "email", "telefon", "ulice", "mesto", "psc",))
|
||||
response = dataOsobCsvResponse(organizatoriOsoby, columns=fields)
|
||||
name = str(soustredeni).replace(" ", "_") + "_organizatori_soustredeni.csv"
|
||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||
return response
|
||||
if type == PrvniTypExportu.SOUSTREDENI_UCASTNICI.value:
|
||||
soustredeni = Soustredeni.objects.get(id=id)
|
||||
ucastnici = soustredeni.ucastnici.all()
|
||||
usaciOsoby = Osoba.objects.filter(resitel__in=ucastnici)
|
||||
response = dataOsobCsvResponse(usaciOsoby, columns=("jmeno", "prijmeni", "email", "telefon", "ulice", "mesto", "psc",))
|
||||
ucastniciOsoby = Osoba.objects.filter(resitel__in=ucastnici)
|
||||
response = dataOsobCsvResponse(ucastniciOsoby, columns=fields)
|
||||
name = str(soustredeni).replace(" ", "_") + "_ucastnici_soustredeni.csv"
|
||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||
ledoian
commented
Tyhle Tyhle `if`y vypadají dost zběsile. Chápu správně, že se prakticky jen mění, jaký QuerySet předhodíme `dataOsobCsvResponse` a pak možná `filename`?
|
||||
return response
|
||||
|
|
Loading…
Reference in a new issue
Takže pokud přibyde na řešitelovi další věc, tak se bude muset přidávat sem další položka?
Ano