Always convert newlines to linebreaks
authorSverre Rabbelier <srabbelier@gmail.com>
Thu, 12 Mar 2009 22:30:04 +0000
changeset 1815 7a9b69f36111
parent 1814 0c4fd663704b
child 1816 07743b5295d3
Always convert newlines to linebreaks Patch by: Sverre Rabbelier
app/soc/templates/soc/templatetags/_readonly_field_as_table_row.html
app/soc/templates/soc/templatetags/_readonly_field_as_twoline_table_row.html
app/soc/views/helper/templatetags/forms_helpers.py
--- a/app/soc/templates/soc/templatetags/_readonly_field_as_table_row.html	Thu Mar 12 22:29:14 2009 +0000
+++ b/app/soc/templates/soc/templatetags/_readonly_field_as_table_row.html	Thu Mar 12 22:30:04 2009 +0000
@@ -19,7 +19,7 @@
  </td>
  <td class="formfieldvalue">
   {% block field_value_column %}
-	{{ field_value }}
+	{{ field_value|linebreaksbr }}
 	{% endblock %}
  </td>
 </tr>
--- a/app/soc/templates/soc/templatetags/_readonly_field_as_twoline_table_row.html	Thu Mar 12 22:29:14 2009 +0000
+++ b/app/soc/templates/soc/templatetags/_readonly_field_as_twoline_table_row.html	Thu Mar 12 22:30:04 2009 +0000
@@ -21,7 +21,7 @@
 <tr title="{{ field.help_text }}">
  <td class="formfieldvalue">
   {% block field_value_column %}
-    {{ field_value }}
+    {{ field_value|linebreaksbr }}
   {% endblock %}
  </td>
 </tr>
--- a/app/soc/views/helper/templatetags/forms_helpers.py	Thu Mar 12 22:29:14 2009 +0000
+++ b/app/soc/views/helper/templatetags/forms_helpers.py	Thu Mar 12 22:30:04 2009 +0000
@@ -70,7 +70,7 @@
 
 
 @register.inclusion_tag('soc/templatetags/_readonly_field_as_table_row.html')
-def readonly_field_as_table_row(field_label, field_value):
+def readonly_field_as_table_row(label, value):
   """Prints a field value and it's verbose name as a table row.
 
   This function actually does very little, simply passing the 
@@ -98,17 +98,23 @@
       { 'field_label': field_label',
         'field_value': field_value'}
   """
-  return {'field_label': field_label,
-          'field_value': field_value}
+
+  value = value.strip() if isinstance(value, basestring) else value
+
+  return {'field_label': label,
+          'field_value': value}
 
 
 @register.inclusion_tag(
     'soc/templatetags/_readonly_field_as_twoline_table_row.html')
-def readonly_field_as_twoline_table_row(field_label, field_value):
+def readonly_field_as_twoline_table_row(label, value):
   """See readonly_field_as_table_row().
   """
-  return {'field_label': field_label,
-          'field_value': field_value}
+
+  value = value.strip() if  isinstance(value, basestring) else value
+
+  return {'field_label': label,
+          'field_value': value}
 
 
 @register.inclusion_tag(