Added checkCanProcessRequest in access.py.
authorLennard de Rijk <ljvderijk@gmail.com>
Sat, 24 Jan 2009 14:14:11 +0000
changeset 960 129efa976d6d
parent 959 b6e8750c9407
child 961 36a90d0e9211
Added checkCanProcessRequest in access.py. This is used in the upcoming Request patch. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/views/helper/access.py
--- a/app/soc/views/helper/access.py	Sat Jan 24 12:54:59 2009 +0000
+++ b/app/soc/views/helper/access.py	Sat Jan 24 14:14:11 2009 +0000
@@ -271,6 +271,26 @@
   return wrapper
 
 
+def checkCanProcessRequest(role_name):
+  """Raises an alternate HTTP response if the specified request does not exist
+     or if it's state is completed or denied. 
+  """
+  def wrapper(request, args, kwargs):
+
+    fields = {'link_id': kwargs['link_id'],
+        'scope_path': kwargs['scope_path'],
+        'role': role_name}
+
+    request_entity = request_logic.getFromFieldsOr404(**fields)
+
+    if request_entity.state in ['completed', 'denied']:
+      # TODO tell the user that this request has been processed
+      deny(request, args, kwargs)
+
+    return
+  return wrapper
+
+
 def checkIsMyGroupAcceptedRequest(request, args, kwargs):
   """Raises an alternate HTTP response if the specified request does not exist
      or if it's state is not group_accepted.