pridani custom checkboxu
This commit is contained in:
		
							parent
							
								
									96b66f4019
								
							
						
					
					
						commit
						eb41008261
					
				
					 2 changed files with 32 additions and 9 deletions
				
			
		|  | @ -5,6 +5,17 @@ | ||||||
| 
 | 
 | ||||||
| <h2><strong>Export lidí</strong></h2> | <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"> | <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> | ||||||
|  | @ -77,12 +88,16 @@ | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   download_button.addEventListener('click', (e) => { |   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 == '') { |     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 { |     } 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> | </script> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -172,19 +172,27 @@ def get_export_options(request, type): | ||||||
| 	return HttpResponse(json.dumps(data), content_type='application/json') | 	return HttpResponse(json.dumps(data), content_type='application/json') | ||||||
| 
 | 
 | ||||||
| def download_export_csv_only_first_step(request, type): | def download_export_csv_only_first_step(request, type): | ||||||
|  | 	fields = request.GET.get('fields').split(',') | ||||||
| 	if type == 3: | 	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"' | 		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 = request.GET.get('fields').split(',') | ||||||
| 	if type == PrvniTypExportu.CISLA.value: | 	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" | 		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: | ||||||
| 		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" | 		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 | ||||||
|  | @ -192,15 +200,15 @@ def download_export_csv(request, type, id): | ||||||
| 		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=("jmeno", "prijmeni", "email", "telefon", "ulice", "mesto", "psc",)) | 		response = dataOsobCsvResponse(organizatoriOsoby, columns=fields) | ||||||
| 		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: | 	if type == PrvniTypExportu.SOUSTREDENI_UCASTNICI.value: | ||||||
| 		soustredeni = Soustredeni.objects.get(id=id) | 		soustredeni = Soustredeni.objects.get(id=id) | ||||||
| 		ucastnici = soustredeni.ucastnici.all() | 		ucastnici = soustredeni.ucastnici.all() | ||||||
| 		usaciOsoby = Osoba.objects.filter(resitel__in=ucastnici) | 		ucastniciOsoby = Osoba.objects.filter(resitel__in=ucastnici) | ||||||
| 		response = dataOsobCsvResponse(usaciOsoby, columns=("jmeno", "prijmeni", "email", "telefon", "ulice", "mesto", "psc",)) | 		response = dataOsobCsvResponse(ucastniciOsoby, columns=fields) | ||||||
| 		name = str(soustredeni).replace(" ", "_") + "_ucastnici_soustredeni.csv" | 		name = str(soustredeni).replace(" ", "_") + "_ucastnici_soustredeni.csv" | ||||||
| 		response['Content-Disposition'] = 'attachment; filename="' + name + '"' | 		response['Content-Disposition'] = 'attachment; filename="' + name + '"' | ||||||
| 		return response | 		return response | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue