Compare commits
No commits in common. "upravy_exportu" and "master" have entirely different histories.
upravy_exp
...
master
3 changed files with 10 additions and 62 deletions
|
@ -5,27 +5,12 @@
|
||||||
|
|
||||||
<h2><strong>Export lidí</strong></h2>
|
<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">
|
<select name="select-one" id="select-one">
|
||||||
<option value="0">---</option>
|
<option value="0">---</option>
|
||||||
<option value="1">Řešitelé čísla</option>
|
<option value="1">Řešitelé čísla</option>
|
||||||
<option value="2">Řešitelé ročníku</option>
|
<option value="2">Řešitelé ročníku</option>
|
||||||
<option value="3">Všichni řešitelé, kteří ještě neodmaturovali</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="4">Organizátoři soustředění</option>
|
||||||
<option value="5">Účastníci soustředění</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select name="select-two" id="select-two">
|
<select name="select-two" id="select-two">
|
||||||
|
@ -91,22 +76,12 @@ a zabalit tak vice parametru do jednoho checkboxu -->
|
||||||
})
|
})
|
||||||
|
|
||||||
download_button.addEventListener('click', (e) => {
|
download_button.addEventListener('click', (e) => {
|
||||||
// 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 == '') {
|
if (select_two.innerHTML == '') {
|
||||||
window.location.href = "/profil/exporty_lidi/get_csv_only_one_step/" + select_one.value + "?fields=" + params
|
window.location.href = "/profil/exporty_lidi/get_csv_only_one_step/" + select_one.value
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "/profil/exporty_lidi/get_csv/" + select_one.value + "/" + select_two.value + "?fields=" + params
|
window.location.href = "/profil/exporty_lidi/get_csv/" + select_one.value + "/" + select_two.value
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -147,9 +147,7 @@ class OrgoRozcestnikView(TemplateView):
|
||||||
class PrvniTypExportu(Enum):
|
class PrvniTypExportu(Enum):
|
||||||
CISLA = 1
|
CISLA = 1
|
||||||
ROCNIKU = 2
|
ROCNIKU = 2
|
||||||
SOUSTREDENI_ORG = 4
|
SOUSTREDENI = 4
|
||||||
SOUSTREDENI_UCASTNICI = 5
|
|
||||||
|
|
||||||
|
|
||||||
class ExportLidiView(TemplateView):
|
class ExportLidiView(TemplateView):
|
||||||
template_name = 'personalni/profil/export_lidi.html'
|
template_name = 'personalni/profil/export_lidi.html'
|
||||||
|
@ -165,59 +163,35 @@ def get_export_options(request, type):
|
||||||
data = [{"id": c.id, "display": str(c)} for c in Cislo.objects.all()]
|
data = [{"id": c.id, "display": str(c)} for c in Cislo.objects.all()]
|
||||||
if type == PrvniTypExportu.ROCNIKU.value:
|
if type == PrvniTypExportu.ROCNIKU.value:
|
||||||
data = [{"id": r.id, "display": str(r)} for r in Rocnik.objects.all()]
|
data = [{"id": r.id, "display": str(r)} for r in Rocnik.objects.all()]
|
||||||
if type == PrvniTypExportu.SOUSTREDENI_ORG.value:
|
if type == PrvniTypExportu.SOUSTREDENI.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()]
|
data = [{"id": s.id, "display": str(s)} for s in Soustredeni.objects.all()]
|
||||||
return HttpResponse(json.dumps(data), content_type='application/json')
|
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):
|
def download_export_csv_only_first_step(request, type):
|
||||||
fields = getFieldsForExport(request)
|
|
||||||
if type == 3:
|
if type == 3:
|
||||||
resitele = tvorba_utils.resitele_co_neodmaturovali()
|
response = dataResiteluCsvResponse(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"'
|
response['Content-Disposition'] = 'attachment; filename="resitele_co_neodmaturovali.csv"'
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def download_export_csv(request, type, id):
|
def download_export_csv(request, type, id):
|
||||||
fields = getFieldsForExport(request)
|
|
||||||
if type == PrvniTypExportu.CISLA.value:
|
if type == PrvniTypExportu.CISLA.value:
|
||||||
resitele = tvorba_utils.resi_cislo(Cislo.objects.get(id=id))
|
response = dataResiteluCsvResponse(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"
|
name = str(Cislo.objects.get(id=id)).replace(" ", "_") + "_resitele_cisla.csv"
|
||||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||||
return response
|
return response
|
||||||
if type == PrvniTypExportu.ROCNIKU.value:
|
if type == PrvniTypExportu.ROCNIKU.value:
|
||||||
resitele = tvorba_utils.resi_v_rocniku(Rocnik.objects.get(id=id))
|
response = dataResiteluCsvResponse(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"
|
name = str(Rocnik.objects.get(id=id)).replace(" ", "_") + "_resitele_rocniku.csv"
|
||||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||||
return response
|
return response
|
||||||
if type == PrvniTypExportu.SOUSTREDENI_ORG.value:
|
if type == PrvniTypExportu.SOUSTREDENI.value:
|
||||||
soustredeni = Soustredeni.objects.get(id=id)
|
soustredeni = Soustredeni.objects.get(id=id)
|
||||||
organizatori = soustredeni.organizatori.all()
|
organizatori = soustredeni.organizatori.all()
|
||||||
organizatoriOsoby = Osoba.objects.filter(org__in=organizatori)
|
organizatoriOsoby = Osoba.objects.filter(org__in=organizatori)
|
||||||
response = dataOsobCsvResponse(organizatoriOsoby, columns=fields)
|
response = dataOsobCsvResponse(organizatoriOsoby, columns=("jmeno", "prijmeni", "email", "telefon",))
|
||||||
name = str(soustredeni).replace(" ", "_") + "_organizatori_soustredeni.csv"
|
name = str(soustredeni).replace(" ", "_") + "_organizatori_soustredeni.csv"
|
||||||
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
response['Content-Disposition'] = 'attachment; filename="' + name + '"'
|
||||||
return response
|
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):
|
class ResitelView(LoginRequiredMixin,generic.DetailView):
|
||||||
model = m.Resitel
|
model = m.Resitel
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
<a href="../{{soustredeni.pk}}/seznam_ucastniku">HTML tabulka pro tisk</a>,
|
<a href="../{{soustredeni.pk}}/seznam_ucastniku">HTML tabulka pro tisk</a>,
|
||||||
<a href="../{{soustredeni.pk}}/export_ucastniku">CSV</a>,
|
<a href="../{{soustredeni.pk}}/export_ucastniku">CSV</a>,
|
||||||
<a href="../{{soustredeni.pk}}/maily_ucastniku">E-maily</a><br>
|
<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>
|
<a href="../{{soustredeni.pk}}/stvrzenky.pdf">Stvrzenky</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue