Make it possible to display a message when there are no lists
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 22 Feb 2009 11:17:46 +0000
changeset 1458 ec06d3ee73e4
parent 1457 9fd31955cc49
child 1459 2584724403ff
Make it possible to display a message when there are no lists Patch by: Sverre Rabbelier
app/soc/logic/lists.py
app/soc/templates/soc/models/list.html
app/soc/views/helper/params.py
app/soc/views/models/base.py
--- a/app/soc/logic/lists.py	Sun Feb 22 10:55:24 2009 +0000
+++ b/app/soc/logic/lists.py	Sun Feb 22 11:17:46 2009 +0000
@@ -108,6 +108,12 @@
 
     return self.get('row')
 
+  def empty(self):
+    """Returns true iff there are no lists
+    """
+
+    return not self._lists
+
   def lists(self):
     """Returns a list of numbers the size of the amount of lists.
 
--- a/app/soc/templates/soc/models/list.html	Sun Feb 22 10:55:24 2009 +0000
+++ b/app/soc/templates/soc/models/list.html	Sun Feb 22 11:17:46 2009 +0000
@@ -14,10 +14,12 @@
 {% endcomment %}
 {% load forms_helpers %}
 {% block body %}
+{% if list.empty %}
+{{ no_lists_msg }}
+{% endif %}
 {% for _ in list.lists %}
 <p>
 {% include list.nextList %}
 </p>
 {% endfor %}
-
 {% endblock %}
--- a/app/soc/views/helper/params.py	Sun Feb 22 10:55:24 2009 +0000
+++ b/app/soc/views/helper/params.py	Sun Feb 22 11:17:46 2009 +0000
@@ -235,6 +235,7 @@
       }
 
   new_params['list_description'] = DEF_LIST_DESCRIPTION_FMT % params
+  new_params['no_lists_msg'] = ""
   new_params['save_message'] = [ugettext('%(name)s saved.' % params)]
   new_params['submit_msg_param_name'] = DEF_SUBMIT_MSG_PARAM_NAME
   new_params['edit_params'] = {
--- a/app/soc/views/models/base.py	Sun Feb 22 10:55:24 2009 +0000
+++ b/app/soc/views/models/base.py	Sun Feb 22 11:17:46 2009 +0000
@@ -507,6 +507,7 @@
 
     context['entity_type'] = params['name']
     context['entity_type_plural'] = params['name_plural']
+    context['no_lists_msg'] = params['no_lists_msg']
 
     template = params['list_template']