Put the redirects in the views/helper/redirects.py module.
Changed the getCreateRequestRedirect to comply with the new signature. Also changed it's docstring to a more suitable one.
Fixed a useless merge in views/models/role.py in the process.
--- a/app/soc/logic/models/request.py Sat Nov 29 22:48:15 2008 +0000
+++ b/app/soc/logic/models/request.py Sat Nov 29 23:51:24 2008 +0000
@@ -30,6 +30,8 @@
from soc.logic.models import base
from soc.logic.models import user as user_logic
+from soc.views.helper import redirects
+
import os
import soc.models.request
@@ -98,7 +100,7 @@
# create the invitation_url
invitation_url = "%(host)s%(index)s" % {
'host' : os.environ['HTTP_HOST'],
- 'index': self.inviteAcceptedRedirect(entity, None)
+ 'index': redirects.inviteAcceptedRedirect(entity, None)
}
# get the group entity
@@ -122,11 +124,5 @@
mail_dispatcher.sendMailFromTemplate('soc/mail/invitation.html',
messageProperties)
- def inviteAcceptedRedirect(self, entity, _):
- """Returns the redirect for accepting an invite
- """
-
- return '/%s/create/%s/%s' % (
- entity.role, entity.scope_path, entity.link_id)
logic = Logic()
--- a/app/soc/views/helper/redirects.py Sat Nov 29 22:48:15 2008 +0000
+++ b/app/soc/views/helper/redirects.py Sat Nov 29 23:51:24 2008 +0000
@@ -22,10 +22,28 @@
]
+def getCreateRequestRedirect(entity, params):
+ """Returns the create request redirect for the specified entity.
+ """
+
+ result ='/request/create/%s/%s/%s' % (
+ params['url_name'], params['group_scope'], entity.link_id)
+
+ return result
+
+
def getEditRedirect(entity, params):
- """Returns the edit redirect for the specified entity
+ """Returns the edit redirect for the specified entity.
"""
suffix = params['logic'].getKeySuffix(entity)
url_name = params['url_name']
return '/%s/edit/%s' % (url_name, suffix)
+
+
+def inviteAcceptedRedirect(entity, _):
+ """Returns the redirect for accepting an invite.
+ """
+
+ return '/%s/create/%s/%s' % (
+ entity.role, entity.scope_path, entity.link_id)
--- a/app/soc/views/models/request.py Sat Nov 29 22:48:15 2008 +0000
+++ b/app/soc/views/models/request.py Sat Nov 29 23:51:24 2008 +0000
@@ -36,6 +36,7 @@
from soc.views import helper
from soc.views import out_of_band
from soc.views.helper import access
+from soc.views.helper import redirects
from soc.views.helper import widgets
from soc.views.models import base
from soc.views.models import role as role_view
@@ -155,7 +156,7 @@
'group_accepted' : True}
uh_params = params.copy()
- uh_params['list_action'] = (self._logic.inviteAcceptedRedirect, None)
+ uh_params['list_action'] = (redirects.inviteAcceptedRedirect, None)
uh_params['list_description'] = ugettext_lazy(
"An overview of your unhandled requests")
--- a/app/soc/views/models/role.py Sat Nov 29 22:48:15 2008 +0000
+++ b/app/soc/views/models/role.py Sat Nov 29 23:51:24 2008 +0000
@@ -35,6 +35,7 @@
from soc.views import helper
from soc.views import out_of_band
from soc.views.helper import access
+from soc.views.helper import redirects
from soc.views.models import base
from soc.views.models import user as user_view
@@ -90,13 +91,15 @@
if not params:
params = {}
new_params = {}
- link_id = kwargs['link_id']
+ group_scope = kwargs['link_id']
- new_params['list_action'] = (self.getCreateRequestRedirect, link_id)
+ new_params['list_action'] = (redirects.getCreateRequestRedirect,
+ {'group_scope' : group_scope,
+ 'url_name' : self._params['url_name'] })
new_params['instruction_text'] = \
self.DEF_INVITE_INSTRUCTION_MSG_FMT % self._params
- params = dicts.merge(new_params, params)
+ new_params = dicts.merge(new_params, params)
params = dicts.merge(new_params, user_view.view._params)
try:
@@ -109,14 +112,6 @@
return self._list(request, params, contents, page_name)
- def getCreateRequestRedirect(self, entity, group_scope):
- """Returns the edit redirect for the specified entity
- """
-
- result ='/request/create/%s/%s/%s' % (
- self._params['url_name'], group_scope, entity.link_id)
- return result
-
def getDjangoURLPatterns(self):
"""See base.View.getDjangoURLPatterns().
"""