From 039763b921095ebc982e0f9700b920d90c05d6e8 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 13 Dec 2012 18:10:45 +0100 Subject: [PATCH] Working with forms --- youmap/settings/base.py | 1 + youmap/static/youmap/youmap.css | 28 ++++++++++++++++++++ youmap/templates/chickpea/category_form.html | 25 +++++++++++++++++ youmap/templates/youmap/field.html | 10 +++++++ youmap/templatetags/__init__.py | 0 youmap/templatetags/youmap_tags.py | 10 +++++++ 6 files changed, 74 insertions(+) create mode 100644 youmap/templates/chickpea/category_form.html create mode 100644 youmap/templates/youmap/field.html create mode 100644 youmap/templatetags/__init__.py create mode 100644 youmap/templatetags/youmap_tags.py diff --git a/youmap/settings/base.py b/youmap/settings/base.py index c4c4c8df..7e0098a9 100644 --- a/youmap/settings/base.py +++ b/youmap/settings/base.py @@ -28,6 +28,7 @@ INSTALLED_APPS = ( 'chickpea', 'foundation', 'endless_pagination', + 'youmap', #'south', diff --git a/youmap/static/youmap/youmap.css b/youmap/static/youmap/youmap.css index a3b3a9a1..522e081e 100644 --- a/youmap/static/youmap/youmap.css +++ b/youmap/static/youmap/youmap.css @@ -38,4 +38,32 @@ input::-webkit-input-placeholder, ::-webkit-input-placeholder { input:-moz-placeholder, :-moz-placeholder { color: #a5a5a5; +} + +/* Forms */ + +.help-text small, small.help-text { + display: block; + padding: 6px 4px; + margin-top: -13px; + margin-bottom: 12px; + background: #a5a5a5; + color: #fff; + font-size: 12px; + font-weight: bold; + -moz-border-radius-bottomleft: 2px; + -webkit-border-bottom-left-radius: 2px; + border-bottom-left-radius: 2px; + -moz-border-radius-bottomright: 2px; + -webkit-border-bottom-right-radius: 2px; + border-bottom-right-radius: 2px; +} +.formbox { + border: 1px #a5a5a5 solid; + min-height: 32px; + line-height: 32px; + padding-left: 10px; +} +#reveal-container textarea { + height: 100px; } \ No newline at end of file diff --git a/youmap/templates/chickpea/category_form.html b/youmap/templates/chickpea/category_form.html new file mode 100644 index 00000000..a7fcb22e --- /dev/null +++ b/youmap/templates/chickpea/category_form.html @@ -0,0 +1,25 @@ +{% load youmap_tags %} +
+ {% csrf_token %} + {% for error in form.errors %} + {{ error }} + {% endfor %} + {% foundation_field form.name %} + {% foundation_field form.description %} + {% foundation_field form.color %} +
+
+ {% foundation_field form.icon_class %} +
+
+ {% foundation_field form.pictogram %} +
+
+ {% foundation_field form.rank %} +
+ {{ form.preset.label }}{{ form.preset }} +
+ {{ form.preset.help_text }} + {{ form.map }} + +
\ No newline at end of file diff --git a/youmap/templates/youmap/field.html b/youmap/templates/youmap/field.html new file mode 100644 index 00000000..d4d19da3 --- /dev/null +++ b/youmap/templates/youmap/field.html @@ -0,0 +1,10 @@ +{% if field.label %} + +{% endif %} +{{ field }} +{% for error in field.errors %} + {{ error|escape }} +{% endfor %} +{% if field.help_text %} +{{ field.help_text }} +{% endif %} \ No newline at end of file diff --git a/youmap/templatetags/__init__.py b/youmap/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/youmap/templatetags/youmap_tags.py b/youmap/templatetags/youmap_tags.py new file mode 100644 index 00000000..38fa66cc --- /dev/null +++ b/youmap/templatetags/youmap_tags.py @@ -0,0 +1,10 @@ +from django import template + +register = template.Library() + + +@register.inclusion_tag('youmap/field.html') +def foundation_field(field): + return { + 'field': field, + }