Add redirects for the new pick view
authorSverre Rabbelier <srabbelier@gmail.com>
Fri, 23 Jan 2009 21:15:16 +0000
changeset 932 2b72d0315254
parent 931 1131884c3c56
child 933 7331232d6356
Add redirects for the new pick view Patch by: Sverre Rabbelier
app/soc/views/helper/redirects.py
--- a/app/soc/views/helper/redirects.py	Fri Jan 23 21:04:45 2009 +0000
+++ b/app/soc/views/helper/redirects.py	Fri Jan 23 21:15:16 2009 +0000
@@ -94,7 +94,36 @@
   return result
 
 
-def getInviteAcceptedRedirect(entity, _):
+def getSelectRedirect(entity, params):
+  """Returns the pick redirect for the specified entity
+  """
+
+  if entity:
+    result = '/%s/pick?scope_path=%s&field=%s&continue=%s' % (
+        params['url_name'], entity.key().name(),
+        params['field_name'], params['return_url'])
+  else:
+    result = '/%s/pick?field=%s&continue=%s' % (
+        params['url_name'], params['field_name'], params['return_url'])
+
+  return result
+
+
+def getReturnRedirect(return_url, field):
+  """Returns a function that has return_url and field embedded
+  """
+
+  def wrapped(entity, params):
+    """Returns the return redirect for the specified entity
+    """
+
+    result = '%s?field=%s&value=%s' % (
+        return_url, field, entity.link_id)
+    return result
+
+  return wrapped
+
+def inviteAcceptedRedirect(entity, _):
   """Returns the redirect for accepting an invite.
   """