-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
135 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django import forms | ||
from django.utils.html import escape | ||
from ..models import Dating | ||
from ..geo import CZECHOSLOVAK_REGIONS | ||
|
||
|
||
class DatingForm(forms.ModelForm): | ||
area = forms.ChoiceField( | ||
choices=CZECHOSLOVAK_REGIONS, | ||
label="Kraj", | ||
required=True, | ||
) | ||
|
||
class Meta: | ||
model = Dating | ||
fields = [ | ||
"name", | ||
"email", | ||
"group", | ||
"phone", | ||
"mobile", | ||
"age", | ||
"area", | ||
"experience", | ||
"text", | ||
] | ||
|
||
def clean_text(self): | ||
text = self.cleaned_data["text"] | ||
return escape(text) if text else "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CZECHOSLOVAK_REGIONS = [ | ||
("", "-- Vyberte kraj --"), | ||
("Celá ČR", "Celá ČR"), | ||
("Celá SR", "Celá SR"), | ||
# Czech Republic | ||
("Praha", "Praha"), | ||
("Středočeský", "Středočeský"), | ||
("Jihočeský", "Jihočeský"), | ||
("Plzeňský", "Plzeňský"), | ||
("Karlovarský", "Karlovarský"), | ||
("Ústecký", "Ústecký"), | ||
("Liberecký", "Liberecký"), | ||
("Královéhradecký", "Královéhradecký"), | ||
("Pardubický", "Pardubický"), | ||
("Vysočina", "Vysočina"), | ||
("Jihomoravský", "Jihomoravský"), | ||
("Olomoucký", "Olomoucký"), | ||
("Zlínský", "Zlínský"), | ||
("Moravskoslezský", "Moravskoslezský"), | ||
# Slovak Republic | ||
("Bratislavský", "Bratislavský"), | ||
("Trnavský", "Trnavský"), | ||
("Trenčianský", "Trenčianský"), | ||
("Nitrianský", "Nitrianský"), | ||
("Žilinský", "Žilinský"), | ||
("Banskobystrický", "Banskobystrický"), | ||
("Prešovský", "Prešovský"), | ||
("Košický", "Košický"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% extends 'public.html' %} | ||
{% load html %} | ||
|
||
{% block content %} | ||
<div id="page-dating"> | ||
<h1 class="page-heading">Přidat inzerát do seznamky</h1> | ||
<p>Zadejte pouze údaje, které chcete zveřejnit.</p> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
|
||
{% for field in form %} | ||
<div class="form-group"> | ||
{{ field.label_tag }} | ||
{{ field }} | ||
{% if field.errors %} | ||
<div class="field-error"> | ||
{{ field.errors }} | ||
</div> | ||
{% endif %} | ||
{% if field.help_text %} | ||
<div class="field-help"> | ||
{{ field.help_text }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endfor %} | ||
|
||
<button type="submit">Přidat inzerát</button> | ||
</form> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters