# HG changeset patch # User Sverre Rabbelier # Date 1231449795 0 # Node ID c740d0129cce208d323662c3c2029ff8bf9ce5a0 # Parent 23eaf3aa19b145d95e35c818faa289dc63fc2ebb 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 diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/templates/soc/models/edit.html --- 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 @@

- {% as_table form %} + {% block form_table %} + {% as_table form %} + {% endblock %}
diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/templates/soc/models/twoline_edit.html --- /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 %} diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/templates/soc/templatetags/_as_table.html --- 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 %} diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/templates/soc/templatetags/_as_table_row.html --- 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 @@ {% endif %} +{% block label_row %}{% endblock %} + + {% block label_column %} + {% endblock %} + + +{% endblock %} + +{% block label_column %}{% endblock %} diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/views/helper/templatetags/forms_helpers.py --- 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]
{{ label }} {{ field }} diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/templates/soc/templatetags/_as_twoline_table.html --- /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 %} diff -r 23eaf3aa19b1 -r c740d0129cce app/soc/templates/soc/templatetags/_as_twoline_table_row.html --- /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 %} +
+ {{ label }} +