Use role_name where needed for creating/handling requests.
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 23 Jul 2009 14:55:29 +0200
changeset 2668 7fd0951332ef
parent 2667 260aaea36e49
child 2669 c28e2dc4cd51
Use role_name where needed for creating/handling requests. Also added TODO to extend the redirect for further use with the new module system.
app/soc/templates/soc/request/process_request.html
app/soc/views/helper/redirects.py
app/soc/views/models/role.py
--- a/app/soc/templates/soc/request/process_request.html	Thu Jul 23 14:43:20 2009 +0200
+++ b/app/soc/templates/soc/request/process_request.html	Thu Jul 23 14:55:29 2009 +0200
@@ -31,9 +31,9 @@
 <table>
 <tr>
   <td>
-    <input type="button" onclick="location.href='/{{ module_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=group_accepted'" value="Accept"/>
-    <input type="button" onclick="location.href='/{{ module_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=rejected'" value="Reject"/>
-    <input type="button" onclick="location.href='/{{ module_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=ignored'" value="Ignore"/>
+    <input type="button" onclick="location.href='/{{ role_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=group_accepted'" value="Accept"/>
+    <input type="button" onclick="location.href='/{{ role_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=rejected'" value="Reject"/>
+    <input type="button" onclick="location.href='/{{ role_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=ignored'" value="Ignore"/>
   </td>
 </tr>
 </table>
@@ -49,7 +49,7 @@
 <table>
 <tr>
   <td>
-    <input type="button" onclick="location.href='/{{ module_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=rejected'" value="Withdraw"/>
+    <input type="button" onclick="location.href='/{{ role_name }}/process_request/{{ entity.scope_path }}/{{ entity.link_id }}?status=rejected'" value="Withdraw"/>
     <input type="button" value="Back to Previous Page" onClick="javascript: history.go(-1)">
   </td>
 </tr>
--- a/app/soc/views/helper/redirects.py	Thu Jul 23 14:43:20 2009 +0200
+++ b/app/soc/views/helper/redirects.py	Thu Jul 23 14:55:29 2009 +0200
@@ -270,7 +270,7 @@
 def getInviteAcceptedRedirect(entity, _):
   """Returns the redirect for accepting an invite.
   """
-
+  # TODO: redesign this redirect to use ROLE_VIEWS from the Role View
   return '/%s/accept_invite/%s/%s' % (
       entity.role, entity.scope_path, entity.link_id)
 
--- a/app/soc/views/models/role.py	Thu Jul 23 14:43:20 2009 +0200
+++ b/app/soc/views/models/role.py	Thu Jul 23 14:55:29 2009 +0200
@@ -209,7 +209,7 @@
     """
 
     # set the role to the right name
-    fields = {'role': '%(module_name)s' % (params)}
+    fields = {'role': params['logic'].role_name}
 
     # get the request view parameters and initialize the create form
     request_params = request_view.view.getParams()
@@ -253,7 +253,7 @@
     request_fields = {'link_id': form_fields['link_id'].link_id,
         'scope': group,
         'scope_path': request_scope_path,
-        'role': params['module_name'],
+        'role': params['logic'].role_name,
         'role_verbose': params['name'],
         'status': 'group_accepted'}
 
@@ -293,7 +293,6 @@
 
     return request_scope_path
 
-
   @decorators.merge_params
   @decorators.check_access
   def acceptInvite(self, request, access_type,
@@ -380,7 +379,7 @@
     entity = self._logic.updateOrCreateFromKeyName(fields, key_name)
 
     # mark the request as completed
-    request_helper.completeRequestForRole(entity, params['module_name'])
+    request_helper.completeRequestForRole(entity, params['logic'].role_name)
 
     # redirect to the roles overview page
     return http.HttpResponseRedirect('/user/roles')
@@ -397,7 +396,6 @@
     """
     pass
 
-
   @decorators.merge_params
   @decorators.check_access
   def manage(self, request, access_type,
@@ -500,7 +498,7 @@
     user_entity = user_logic.logic.getForCurrentAccount()
     # pylint: disable-msg=E1103
     fields = {'link_id' : user_entity.link_id,
-              'role' : params['module_name'],
+              'role' : params['logic'].role_name,
               'group_id' : kwargs['scope_path']}
 
     # get the request view parameters and initialize the create form
@@ -544,7 +542,7 @@
     request_fields = {'link_id' : user_entity.link_id,
         'scope' : group,
         'scope_path' : request_scope_path,
-        'role' : params['module_name'],
+        'role' : params['logic'].role_name,
         'role_verbose' : params['name'],
         'status' : 'new'}
 
@@ -566,7 +564,6 @@
     # redirect to requests overview
     return http.HttpResponseRedirect('/user/requests')
 
-
   @decorators.merge_params
   @decorators.check_access
   def processRequest(self, request, access_type,
@@ -589,7 +586,7 @@
     # get the request entity using the information from kwargs
     fields = {'link_id': kwargs['link_id'],
         'scope_path': kwargs['scope_path'],
-        'role': params['module_name']}
+        'role': params['logic'].role_name}
     request_entity = request_logic.logic.getForFields(fields, unique=True)
 
     # pylint: disable-msg=E1103
@@ -620,7 +617,7 @@
     context['entity'] = request_entity
     context['user_in_request'] = user_entity
     context['request_status'] = request_entity.status 
-    context['module_name'] = params['module_name']
+    context['role_name'] = params['logic'].role_name
 
     #display the request processing page using the appropriate template
     template = request_view.view.getParams()['request_processing_template']