Added a twoline_edit.html page
authorSverre Rabbelier <srabbelier@gmail.com>
Thu, 08 Jan 2009 21:23:15 +0000
changeset 785 c740d0129cce
parent 784 23eaf3aa19b1
child 786 6d802e596a96
Added a twoline_edit.html page An as_twoline_edit template tag was added for this purpose. This tag renders the label field on a seperate line. Patch by: Sverre Rabbelier
app/soc/templates/soc/models/edit.html
app/soc/templates/soc/models/twoline_edit.html
app/soc/templates/soc/templatetags/_as_table.html
app/soc/templates/soc/templatetags/_as_table_row.html
app/soc/templates/soc/templatetags/_as_twoline_table.html
app/soc/templates/soc/templatetags/_as_twoline_table_row.html
app/soc/views/helper/templatetags/forms_helpers.py
--- a/app/soc/templates/soc/models/edit.html	Thu Jan 08 20:27:21 2009 +0000
+++ b/app/soc/templates/soc/models/edit.html	Thu Jan 08 21:23:15 2009 +0000
@@ -35,7 +35,9 @@
 </p>
 <form method="POST">
   <table>
-  {% as_table form %}
+    {% block form_table %}
+      {% as_table form %}
+    {% endblock %}
   </table>
   <table>
   <tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/models/twoline_edit.html	Thu Jan 08 21:23:15 2009 +0000
@@ -0,0 +1,19 @@
+{% extends "soc/models/edit.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% load forms_helpers %}
+
+{% block form_table %}
+  {% as_twoline_table form %}
+{% endblock %}
--- a/app/soc/templates/soc/templatetags/_as_table.html	Thu Jan 08 20:27:21 2009 +0000
+++ b/app/soc/templates/soc/templatetags/_as_table.html	Thu Jan 08 21:23:15 2009 +0000
@@ -17,7 +17,9 @@
 {{ hidden_field_errors }}
 
 {% for field, required, example_text in fields %}
-  {% as_table_row form field required example_text %}
+  {% block fields_loop %}
+    {% as_table_row form field required example_text %}
+  {% endblock %}
 {% endfor %}
 
 {% for field in  hidden_fields %}
--- a/app/soc/templates/soc/templatetags/_as_table_row.html	Thu Jan 08 20:27:21 2009 +0000
+++ b/app/soc/templates/soc/templatetags/_as_table_row.html	Thu Jan 08 21:23:15 2009 +0000
@@ -23,10 +23,14 @@
 </tr>
 {% endif %}
 
+{% block label_row %}{% endblock %}
+
 <tr title="{{ help_text }}">
+  {% block label_column %}
   <td class="{{ field_class_type }}">
     {{ label }}
   </td>
+  {% endblock %}
   <td>
     {{ field }}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/templatetags/_as_twoline_table.html	Thu Jan 08 21:23:15 2009 +0000
@@ -0,0 +1,19 @@
+{% extends "soc/templatetags/_as_table.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% load forms_helpers %}
+
+{% block fields_loop %}
+  {% as_twoline_table_row form field required example_text %}
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/templatetags/_as_twoline_table_row.html	Thu Jan 08 21:23:15 2009 +0000
@@ -0,0 +1,25 @@
+{% extends "soc/templatetags/_as_table_row.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% load forms_helpers %}
+
+{% block label_row %}
+<tr>
+<td class="{{ field_class_type }}">
+    {{ label }}
+  </td>
+</tr>
+{% endblock %}
+
+{% block label_column %}{% endblock %}
--- a/app/soc/views/helper/templatetags/forms_helpers.py	Thu Jan 08 20:27:21 2009 +0000
+++ b/app/soc/views/helper/templatetags/forms_helpers.py	Thu Jan 08 21:23:15 2009 +0000
@@ -112,6 +112,19 @@
     form: the form that should be converted to a table
   """
 
+  return as_table_helper(form)
+
+@register.inclusion_tag('soc/templatetags/_as_twoline_table.html')
+def as_twoline_table(form):
+  """Outputs a form as a properly formatted html table
+
+  Args:
+    form: the form that should be converted to a table
+  """
+
+  return as_table_helper(form)
+
+def as_table_helper(form):
   fields = []
   hidden_fields = []
   hidden_fields_errors = []
@@ -155,6 +168,22 @@
     example_text: the example_text for this row
   """
 
+  return as_table_row_helper(form, field, required, example_text)
+
+@register.inclusion_tag('soc/templatetags/_as_twoline_table_row.html')
+def as_twoline_table_row(form, field, required, example_text):
+  """Outputs a field as a properly formatted html row
+
+  Args:
+    form: the form that the row belongs to
+    field: the field that should be converted to a row
+    required: whether the field is required
+    example_text: the example_text for this row
+  """
+
+  return as_table_row_helper(form, field, required, example_text)
+
+def as_table_row_helper(form, field, required, example_text):
   # Escape and cache in local variable.
   errors = [force_unicode(escape(error)) for error in field.errors]