Browse Source

formuláře vzhled jako tabulky

middleware_test
Kateřina Čížková 5 years ago
parent
commit
57dae38cf9
  1. 10
      seminar/static/seminar/prihlaska.js
  2. 89
      seminar/templates/seminar/edit.html
  3. 7
      seminar/templates/seminar/login.html
  4. 168
      seminar/templates/seminar/prihlaska.html
  5. 27
      seminar/templates/seminar/prihlaska_field.html

10
seminar/static/seminar/prihlaska.js

@ -3,7 +3,7 @@ function addrCountryChanged(){
var stat_text = document.getElementById('id_li_stat_text');
var stat = stat_select[stat_select.selectedIndex].value;
if (stat === "other"){
stat_text.style.display="block";
stat_text.style.display="revert";
} else {
stat_text.style.display="none";
$('#id_stat_text').val("");
@ -12,18 +12,22 @@ function addrCountryChanged(){
function hideSchoolTextfields(){
var skola_nazev = document.getElementById('id_li_skola_nazev');
var skola_adresa = document.getElementById('id_li_skola_adresa');
var skola_vypln = document.getElementById('id_li_skola_vypln');
skola_nazev.style.display="none";
skola_adresa.style.display="none";
skola_vypln.style.display="none";
}
function schoolNotInList(){
var skola_nazev = document.getElementById('id_li_skola_nazev');
var skola_adresa = document.getElementById('id_li_skola_adresa');
var skola_vypln = document.getElementById('id_li_skola_vypln');
// FIXME nefunguje a nevim proc (TypeError: $(...).select2 is not a function)
//var skola_select = $('#id_skola').select2();
//skola_select.val(null).trigger('change');
skola_nazev.style.display="block";
skola_adresa.style.display="block";
skola_vypln.style.display="revert";
skola_nazev.style.display="revert";
skola_adresa.style.display="revert";
}
document.addEventListener("DOMContentLoaded", function(){

89
seminar/templates/seminar/edit.html

@ -15,59 +15,77 @@
<form action="{% url 'seminar_resitel_edit' %}" method="post">
{% csrf_token %}
{{form.non_field_errors}}
<ul class="form">
<li>
Přihlašovací údaje
</li><li>
<hr>
<h4>
Přihlašovací údaje
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.username %}
</li><li>
</table>
<hr>
<h4>
Osobní údaje
</li><li>
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.jmeno %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.prijmeni %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.pohlavi_muz%}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.email %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.telefon %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.datum_narozeni %}
</li><li>
</table>
<hr>
Bydliště
</li><li>
<h4>
Bydliště
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.ulice %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.mesto %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.psc %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.stat %}
</li>
<li id="id_li_stat_text">
{% include "seminar/prihlaska_field.html" with field=form.stat_text %}
</li><li>
{% include "seminar/prihlaska_field.html" with field=form.stat_text id="id_li_stat_text"%}
</table>
<hr>
<h4>
Škola
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.skola %}
</li><li>
<button id="id_skola_text_button" type="button">Škola není v seznamu</button>
</li>
<li id="id_li_skola_nazev">
Vyplň prosím celý název a adresu školy.<br>
{% include "seminar/prihlaska_field.html" with field=form.skola_nazev %}
</li>
<li id="id_li_skola_adresa">
{% include "seminar/prihlaska_field.html" with field=form.skola_adresa %}
</li><li>
<tr><td colspan="2" ><button id="id_skola_text_button" type="button">Škola není v seznamu</button></td></tr>
<tr><td id="id_li_skola_vypln" colspan="2">Vyplň prosím celý název a adresu školy.</td></tr>
{% include "seminar/prihlaska_field.html" with field=form.skola_nazev id="id_li_skola_nazev" %}
{% include "seminar/prihlaska_field.html" with field=form.skola_adresa id="id_li_skola_adresa" %}
{% include "seminar/prihlaska_field.html" with field=form.rok_maturity %}
</li><li>
</table>
<hr>
<h4>
Pošta
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.zasilat %}
</li><li>
</table>
<hr>
<h4>
Zasílání propagačních materiálů
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.spam %}
</li>
</ul>
</table>
<hr>
<input type="submit" value="Změnit">
</form>
<script>
@ -75,4 +93,3 @@ $("#id_stat").on("change",addrCountryChanged);
$("#id_skola_text_button").on("click",schoolNotInList);
</script>
{% endblock %}

7
seminar/templates/seminar/login.html

@ -10,9 +10,9 @@
</h1>
<form action="{% url 'login' %}" method="post">
{% csrf_token %}
<ul class="form">
{{ form.as_ul }}
</ul>
<table class="form">
{{ form.as_table }}
</table>
{# Django si posílá jméno další stránky jako obsah formuláře a výchozí hodnota (mi přišlo, že) nejde změnit... #}
<input type="hidden" name='next' value="{{ next }}">
<input type="submit" value="Přihlásit">
@ -23,4 +23,3 @@
{% endblock %}

168
seminar/templates/seminar/prihlaska.html

@ -14,92 +14,93 @@
{% endblock %}{% endblock %}
</h1>
<form action="{% url 'seminar_prihlaska' %}" method="post">
{% csrf_token %}
{{form.non_field_errors}}
<ul class="form">
<li>
Přihlašovací údaje
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.username %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.password %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.password_check %}
</li>
<li>
Osobní údaje
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.jmeno %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.prijmeni %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.pohlavi_muz%}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.email %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.telefon %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.datum_narozeni %}
</li>
<li>
<hr>
Bydliště
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.ulice %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.mesto %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.psc %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.stat %}
</li>
<li id="id_li_stat_text">
{% include "seminar/prihlaska_field.html" with field=form.stat_text %}
</li>
<li>
<hr>
{% include "seminar/prihlaska_field.html" with field=form.skola %}
</li>
<li>
<button id="id_skola_text_button" type="button">Škola není v seznamu</button>
</li>
<li id="id_li_skola_nazev">
Vyplň prosím celý název a adresu školy.<br>
{% include "seminar/prihlaska_field.html" with field=form.skola_nazev %}
</li>
<li id="id_li_skola_adresa">
{% include "seminar/prihlaska_field.html" with field=form.skola_adresa %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.rok_maturity %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.zasilat %}
</li>
<li>
{% include "seminar/gdpr.html" %}
{% include "seminar/prihlaska_field.html" with field=form.gdpr %}
</li>
<li>
{% include "seminar/prihlaska_field.html" with field=form.spam %}
</li>
</ul>
<hr>
<h4>
Přihlašovací údaje
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.username %}
{% include "seminar/prihlaska_field.html" with field=form.password %}
{% include "seminar/prihlaska_field.html" with field=form.password_check %}
</table>
<hr>
<h4>
Osobní údaje
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.jmeno %}
{% include "seminar/prihlaska_field.html" with field=form.prijmeni %}
{% include "seminar/prihlaska_field.html" with field=form.pohlavi_muz%}
{% include "seminar/prihlaska_field.html" with field=form.email %}
{% include "seminar/prihlaska_field.html" with field=form.telefon %}
{% include "seminar/prihlaska_field.html" with field=form.datum_narozeni %}
</table>
<hr>
<h4>
Bydliště
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.ulice %}
{% include "seminar/prihlaska_field.html" with field=form.mesto %}
{% include "seminar/prihlaska_field.html" with field=form.psc %}
{% include "seminar/prihlaska_field.html" with field=form.stat %}
{% include "seminar/prihlaska_field.html" with field=form.stat_text id="id_li_stat_text"%}
</table>
<hr>
<h4>
Škola
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.skola %}
<tr><td colspan="2" ><button id="id_skola_text_button" type="button">Škola není v seznamu</button></td></tr>
<tr><td id="id_li_skola_vypln" colspan="2">Vyplň prosím celý název a adresu školy.</td></tr>
{% include "seminar/prihlaska_field.html" with field=form.skola_nazev id="id_li_skola_nazev" %}
{% include "seminar/prihlaska_field.html" with field=form.skola_adresa id="id_li_skola_adresa" %}
{% include "seminar/prihlaska_field.html" with field=form.rok_maturity %}
</table>
<hr>
<h4>
Pošta
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.zasilat %}
</table>
<hr>
<h4>
GDPR
</h4>
{% include "seminar/gdpr.html" %}
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.gdpr %}
</table>
<hr>
<h4>
Zasílání propagačních materiálů
</h4>
<table class="form">
{% include "seminar/prihlaska_field.html" with field=form.spam %}
</table>
<hr>
<input type="submit" value="Odeslat">
</form>
<script>
@ -109,4 +110,3 @@ $("#id_skola_text_button").on("click",schoolNotInList);
{% endblock %}

27
seminar/templates/seminar/prihlaska_field.html

@ -1,4 +1,23 @@
<label class="field-label{% if field.field.required %} field-required{% endif %}" for="{{ field.id_for_label }}">{{ field.label }}:</label>
{{field}}
{% if field.help_text %}<span class="field-helptext">{{ field.help_text|safe }}</span>{% endif %}
{% if field.errors %}<span class="field-error">{{ field.errors }}</span>{% endif %}
<tr id="{{ id }}" >
<td>
<label class="field-label{% if field.field.required %} field-required{% endif %}" for="{{ field.id_for_label }}">
{{ field.label }}:
</label>
</td>
<td>
{{ field }}
</td>
</tr>
{% if field.help_text %}
<tr>
<td colspan="2"><span class="field-helptext">{{ field.help_text|safe }}</span></td>
</tr>
{% endif %}
{% if field.errors %}
<tr>
<td colspan="2"><span class="field-error">{{ field.errors }}</span></td>
</tr>
{% endif %}

Loading…
Cancel
Save