Compare commits
5 commits
master
...
upravy_exp
Author | SHA1 | Date | |
---|---|---|---|
5f1e9d07d9 | |||
c1df250a46 | |||
eb41008261 | |||
96b66f4019 | |||
c780e7e35f |
3 changed files with 64 additions and 12 deletions
|
@ -5,12 +5,27 @@
|
|||
|
||||
<h2><strong>Export lidí</strong></h2>
|
||||
|
||||
<p>Vyberte pole, které chcete exportovat</p>
|
||||
<!-- for loop zde neni pouzit proto, aby se mohlo napsat
|
||||
data-value="email telefon mesto"
|
||||
a zabalit tak vice parametru do jednoho checkboxu -->
|
||||
<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>
|
||||
<option value="2">Řešitelé ročníku</option>
|
||||
<option value="3">Všichni řešitelé, kteří ještě neodmaturovali</option>
|
||||
<option value="4">Organizátoři soustředění</option>
|
||||
<option value="5">Účastníci soustředění</option>
|
||||
</select>
|
||||
|
||||
<select name="select-two" id="select-two">
|
||||
|
@ -76,12 +91,22 @@
|
|||
})
|
||||
|
||||
download_button.addEventListener('click', (e) => {
|
||||
if (select_two.innerHTML == '') {
|
||||
window.location.href = "/profil/exporty_lidi/get_csv_only_one_step/" + select_one.value
|
||||
} else {
|
||||
window.location.href = "/profil/exporty_lidi/get_csv/" + select_one.value + "/" + select_two.value
|
||||
// uzivatele vybrana pole
|
||||
fields = Array.from(document.getElementsByClassName('field-check'))
|
||||
.filter(e => e.checked)
|
||||
.map(e => e.getAttribute('data-value'));
|
||||
params = ""
|
||||
for (let val of fields) {
|
||||
for(let s of val.split(' ')) {
|
||||
params += s + ","
|
||||
}
|
||||
}
|
||||
params = params.slice(0, -1)
|
||||
if (select_two.innerHTML == '') {
|
||||
window.location.href = "/profil/exporty_lidi/get_csv_only_one_step/" + select_one.value + "?fields=" + params
|
||||
} else {
|
||||
window.location.href = "/profil/exporty_lidi/get_csv/" + select_one.value + "/" + select_two.value + "?fields=" + params
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -147,7 +147,9 @@ class OrgoRozcestnikView(TemplateView):
|
|||
class PrvniTypExportu(Enum):
|
||||
CISLA = 1
|
||||
ROCNIKU = 2
|
||||
SOUSTREDENI = 4
|
||||
SOUSTREDENI_ORG = 4
|
||||
SOUSTREDENI_UCASTNICI = 5
|
||||
|
||||
|
||||
class ExportLidiView(TemplateView):
|
||||
template_name = 'personalni/profil/export_lidi.html'
|
||||
|
@ -163,35 +165,59 @@ def get_export_options(request, type):
|
|||
data = [{"id": c.id, "display": str(c)} for c in Cislo.objects.all()]
|
||||
if type == PrvniTypExportu.ROCNIKU.value:
|
||||
data = [{"id": r.id, "display": str(r)} for r in Rocnik.objects.all()]
|
||||
if type == PrvniTypExportu.SOUSTREDENI.value:
|
||||
if type == PrvniTypExportu.SOUSTREDENI_ORG.value:
|
||||
data = [{"id": s.id, "display": str(s)} for s in Soustredeni.objects.all()]
|
||||
if type == PrvniTypExportu.SOUSTREDENI_UCASTNICI.value:
|
||||
data = [{"id": s.id, "display": str(s)} for s in Soustredeni.objects.all()]
|
||||
return HttpResponse(json.dumps(data), content_type='application/json')
|
||||
|
||||
def getFieldsForExport(request):
|
||||
if 'fields' not in request.GET or request.GET.get('fields') == '':
|
||||
return ["jmeno", "prijmeni", "email", "telefon"]
|
||||
fields = request.GET.get('fields').split(',')
|
||||
return fields
|
||||
|
||||
def download_export_csv_only_first_step(request, type):
|
||||
fields = getFieldsForExport(request)
|
||||
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
|
||||
|
||||
def download_export_csv(request, type, id):
|
||||
fields = getFieldsForExport(request)
|
||||
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
|
||||
if type == PrvniTypExportu.SOUSTREDENI.value:
|
||||
if type == PrvniTypExportu.SOUSTREDENI_ORG.value:
|
||||
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",))
|
||||
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()
|
||||
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 + '"'
|
||||
return response
|
||||
|
||||
class ResitelView(LoginRequiredMixin,generic.DetailView):
|
||||
model = m.Resitel
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
<a href="../{{soustredeni.pk}}/seznam_ucastniku">HTML tabulka pro tisk</a>,
|
||||
<a href="../{{soustredeni.pk}}/export_ucastniku">CSV</a>,
|
||||
<a href="../{{soustredeni.pk}}/maily_ucastniku">E-maily</a><br>
|
||||
Exporty pro soustředění: <a href="{% url 'exporty_lidi' %}">exporty</a><br>
|
||||
<a href="../{{soustredeni.pk}}/stvrzenky.pdf">Stvrzenky</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue