Cleanups in preparation of general selector view
Renamed LIST... to DEF_LIST since it is a global definition.
Renamed getCreateProgramRedirect to getCreateRedirect since it will
work on all entities as it uses params.
Added a getParams method to base.View
Updated selectSponsor as appropriate.
Patch by: Sverre Rabbelier
--- a/app/soc/views/helper/params.py Tue Dec 02 22:03:46 2008 +0000
+++ b/app/soc/views/helper/params.py Tue Dec 02 22:04:15 2008 +0000
@@ -34,9 +34,12 @@
from soc.views.helper import redirects
-LIST_DESCRIPTION_FMT = ugettext_lazy(
+DEF_LIST_DESCRIPTION_FMT = ugettext_lazy(
'List of %(name_plural)s in Google Open Source Programs.')
+DEF_CREATE_INSTRUCTION_MSG_FMT = ugettext_lazy(
+ 'Please use this form to select a %(name).')
+
DEF_SUBMIT_MSG_PARAM_NAME = 's'
DEF_SUBMIT_MSG_PROFILE_SAVED = 0
@@ -136,7 +139,7 @@
'list_heading': 'heading',
}
- new_params['list_description'] = LIST_DESCRIPTION_FMT % params
+ new_params['list_description'] = DEF_LIST_DESCRIPTION_FMT % params
new_params['save_message'] = [ugettext_lazy('Profile saved.')]
new_params['submit_msg_param_name'] = DEF_SUBMIT_MSG_PARAM_NAME
new_params['edit_params'] = {
--- a/app/soc/views/helper/redirects.py Tue Dec 02 22:03:46 2008 +0000
+++ b/app/soc/views/helper/redirects.py Tue Dec 02 22:04:15 2008 +0000
@@ -31,7 +31,7 @@
return result
-def getCreateProgramRedirect(entity, params):
+def getCreateRedirect(entity, params):
"""Returns the create program redirect for the specified entity.
"""
--- a/app/soc/views/models/base.py Tue Dec 02 22:03:46 2008 +0000
+++ b/app/soc/views/models/base.py Tue Dec 02 22:04:15 2008 +0000
@@ -541,6 +541,12 @@
return helper.responses.respond(request, template, context)
+ def getParams(self):
+ """Returns this view's params attribute
+ """
+
+ return self._params
+
def getSidebarLinks(self, request, params=None):
"""Returns an dictionary with one sidebar entry.
--- a/app/soc/views/models/program.py Tue Dec 02 22:03:46 2008 +0000
+++ b/app/soc/views/models/program.py Tue Dec 02 22:04:15 2008 +0000
@@ -42,9 +42,6 @@
"""View methods for the Sponsor model.
"""
- DEF_CREATE_INSTRUCTION_MSG_FMT = ugettext_lazy(
- 'Please use this form to select a Sponsor for the new Program')
-
def __init__(self, original_params=None):
"""Defines the fields and methods required for the base View class
to provide the user with list, public, create, edit and delete views.
@@ -91,7 +88,6 @@
return super(View, self).create(request, page_name=page_name,
params=params, **kwargs)
- params = dicts.merge(params, self._params)
return self.selectSponsor(request, page_name, params)
def selectSponsor(self, request, page_name, params):
@@ -115,12 +111,15 @@
params: a dict with params for this View
"""
+ view = sponsor_view.view
+ redirect = redirects.getCreateRedirect
+
+ params = dicts.merge(params, self._params)
+
new_params = {}
- new_params['list_action'] = (redirects.getCreateProgramRedirect, params)
- new_params['list_description'] = \
- self.DEF_CREATE_INSTRUCTION_MSG_FMT % self._params
+ new_params['list_action'] = (redirect, params)
- new_params = dicts.merge(new_params, sponsor_view.view._params)
+ new_params = dicts.merge(new_params, view.getParams())
params = dicts.merge(new_params, params)
content = helper.lists.getListContent(request, params)