# HG changeset patch # User Todd Larsen # Date 1223076252 0 # Node ID b97d08ebac0eed3ae164d1d368b0724b4c778a88 # Parent 00cea07656c06e6b0e3bab23193dc357822d49ff Move helpers/templatetags to helper/templatetags. Patch by: Todd Larsen Review by: to-be-reviewed diff -r 00cea07656c0 -r b97d08ebac0e app/settings.py --- a/app/settings.py Fri Oct 03 23:17:49 2008 +0000 +++ b/app/settings.py Fri Oct 03 23:24:12 2008 +0000 @@ -100,7 +100,7 @@ ) INSTALLED_APPS = ( - 'soc.views.helpers', + 'soc.views.helper', # 'django.contrib.auth', # 'django.contrib.contenttypes', # 'django.contrib.sessions', diff -r 00cea07656c0 -r b97d08ebac0e app/soc/views/helper/templatetags/__init__.py diff -r 00cea07656c0 -r b97d08ebac0e app/soc/views/helper/templatetags/forms_helpers.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/views/helper/templatetags/forms_helpers.py Fri Oct 03 23:24:12 2008 +0000 @@ -0,0 +1,90 @@ +#!/usr/bin/python2.5 +# +# Copyright 2008 the Melange authors. +# +# 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. + +"""A Django template tag library containing forms helpers. +""" + +__authors__ = [ + '"Todd Larsen" ', + '"Pawel Solyga" ', + ] + + +from django import template +register = template.Library() + + +@register.inclusion_tag('soc/templatetags/_field_as_table_row.html') +def field_as_table_row(field): + """Prints a newforms field as a table row. + + This function actually does very little, simply passing the supplied + form field instance in a simple context used by the _field_as_table_row.html + template (which is actually doing all of the work). + + See soc/templates/soc/templatetags/_field_as_table_row.html for the CSS + styles used by this template tag. + + Usage: + {% load forms_helpers %} + ... + + {% field_as_table_row form.fieldname %} + ... +
+ + Args: + field: a Django newforms field instance + + Returns: + a simple context containing the supplied newforms field instance: + { 'field': field } + """ + return {'field': field} + + +@register.inclusion_tag('soc/templatetags/_readonly_field_as_table_row.html') +def readonly_field_as_table_row(field_label, field_value): + """Prints a field value and it's verbose name as a table row. + + This function actually does very little, simply passing the + supplied field_label and field_value in a simple context used by the + _readonly_field_as_table_row.html template (which is actually + doing all of the work). + + See soc/templates/soc/templatetags/_readonly_field_as_table_row.html for the CSS + styles used by this template tag. + + Usage: + {% load forms_helpers %} + ... + + {% readonly_field_as_table_row field_label field_value %} + ... +
+ + Args: + field_label: label of the field to render + field_value: value of the field to render + + Returns: + a simple context containing the supplied newforms field instance: + { 'field_label': field_label', + 'field_value': field_value'} + """ + return {'field_label': field_label, + 'field_value': field_value} + diff -r 00cea07656c0 -r b97d08ebac0e app/soc/views/helpers/templatetags/__init__.py diff -r 00cea07656c0 -r b97d08ebac0e app/soc/views/helpers/templatetags/forms_helpers.py --- a/app/soc/views/helpers/templatetags/forms_helpers.py Fri Oct 03 23:17:49 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -#!/usr/bin/python2.5 -# -# Copyright 2008 the Melange authors. -# -# 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. - -"""A Django template tag library containing forms helpers. -""" - -__authors__ = [ - '"Todd Larsen" ', - '"Pawel Solyga" ', - ] - - -from django import template -register = template.Library() - - -@register.inclusion_tag('soc/templatetags/_field_as_table_row.html') -def field_as_table_row(field): - """Prints a newforms field as a table row. - - This function actually does very little, simply passing the supplied - form field instance in a simple context used by the _field_as_table_row.html - template (which is actually doing all of the work). - - See soc/templates/soc/templatetags/_field_as_table_row.html for the CSS - styles used by this template tag. - - Usage: - {% load forms_helpers %} - ... - - {% field_as_table_row form.fieldname %} - ... -
- - Args: - field: a Django newforms field instance - - Returns: - a simple context containing the supplied newforms field instance: - { 'field': field } - """ - return {'field': field} - - -@register.inclusion_tag('soc/templatetags/_readonly_field_as_table_row.html') -def readonly_field_as_table_row(field_label, field_value): - """Prints a field value and it's verbose name as a table row. - - This function actually does very little, simply passing the - supplied field_label and field_value in a simple context used by the - _readonly_field_as_table_row.html template (which is actually - doing all of the work). - - See soc/templates/soc/templatetags/_readonly_field_as_table_row.html for the CSS - styles used by this template tag. - - Usage: - {% load forms_helpers %} - ... - - {% readonly_field_as_table_row field_label field_value %} - ... -
- - Args: - field_label: label of the field to render - field_value: value of the field to render - - Returns: - a simple context containing the supplied newforms field instance: - { 'field_label': field_label', - 'field_value': field_value'} - """ - return {'field_label': field_label, - 'field_value': field_value} -