Changed checkCanMakeRequestToGroup to use Logic instance instead of module.
authorLennard de Rijk <ljvderijk@gmail.com>
Fri, 23 Oct 2009 13:25:28 -0700
changeset 3032 f3886d1b00a5
parent 3031 7678f72140e6
child 3033 8a18ac7ca909
Changed checkCanMakeRequestToGroup to use Logic instance instead of module. This method now also directly queries for the keyname of the group. Also some whitespace fixes in the access module.
app/soc/modules/ghop/views/models/mentor.py
app/soc/views/helper/access.py
app/soc/views/models/club_member.py
app/soc/views/models/mentor.py
--- a/app/soc/modules/ghop/views/models/mentor.py	Fri Oct 23 13:54:11 2009 -0500
+++ b/app/soc/modules/ghop/views/models/mentor.py	Fri Oct 23 13:25:28 2009 -0700
@@ -62,7 +62,7 @@
     rights['request'] = [
         ('checkIsNotStudentForProgramOfOrg',
          [ghop_org_logic.logic, ghop_student_logic.logic]),
-        ('checkCanMakeRequestToGroup', ghop_org_logic)]
+        ('checkCanMakeRequestToGroup', ghop_org_logic.logic)]
     rights['process_request'] = [
         ('checkHasActiveRoleForScope', ghop_org_admin_logic.logic),
         ('checkCanProcessRequest', 'ghop/mentor')]
--- a/app/soc/views/helper/access.py	Fri Oct 23 13:54:11 2009 -0500
+++ b/app/soc/views/helper/access.py	Fri Oct 23 13:25:28 2009 -0700
@@ -822,12 +822,12 @@
 
   def checkHasDocumentAccess(self, django_args, logic, target_scope):
     """Checks that the user has access to the specified document scope.
-    
+
     Args:
       django_args: a dictionary with django's arguments
       logic: the logic that should be used to look up the entity
     """
-    
+
     prefix = django_args['prefix']
     if self.SCOPE_DEPTH.get(prefix):
       scope_logic, depths = self.SCOPE_DEPTH[prefix]
@@ -870,13 +870,12 @@
 
     Args:
       django_args: a dictionary with django's arguments
-      group_logic: Logic module for the type of group which the request is for
+      group_logic: Logic instance for the group which the request is for
     """
 
     self.checkIsUser(django_args)
 
-    group_entity = role_logic.getGroupEntityFromScopePath(
-        group_logic.logic, django_args['scope_path'])
+    group_entity = group_logic.getFromKeyName(django_args['scope_path'])
 
     if not group_entity:
       raise out_of_band.Error(DEF_GROUP_NOT_FOUND_MSG, status=404)
@@ -891,7 +890,7 @@
     """Raises an alternate HTTP response if the specified request does not exist
        or if it's status is not group_accepted. Also when the group this request
        is from is in an inactive or invalid status access will be denied.
-    
+
     Args:
       django_args: a dictionary with django's arguments
       role_name: name of the role
--- a/app/soc/views/models/club_member.py	Fri Oct 23 13:54:11 2009 -0500
+++ b/app/soc/views/models/club_member.py	Fri Oct 23 13:25:28 2009 -0700
@@ -58,7 +58,7 @@
     rights['invite'] = [('checkHasActiveRoleForScope', club_admin_logic.logic)]
     rights['accept_invite'] = [('checkCanCreateFromRequest','club_member')]
     rights['request'] = ['checkIsUser',
-                         ('checkCanMakeRequestToGroup', club_logic)]
+                         ('checkCanMakeRequestToGroup', club_logic.logic)]
     rights['process_request'] = [('checkHasActiveRoleForScope', 
                                   club_admin_logic.logic),
                                   ('checkCanProcessRequest','club_member')]
--- a/app/soc/views/models/mentor.py	Fri Oct 23 13:54:11 2009 -0500
+++ b/app/soc/views/models/mentor.py	Fri Oct 23 13:25:28 2009 -0700
@@ -66,7 +66,7 @@
     rights['request'] = [
         ('checkIsNotStudentForProgramOfOrg',
             [org_logic.logic, student_logic.logic]),
-        ('checkCanMakeRequestToGroup', org_logic)]
+        ('checkCanMakeRequestToGroup', org_logic.logic)]
     rights['process_request'] = [
         ('checkHasActiveRoleForScope', soc.logic.models.org_admin.logic),
         ('checkCanProcessRequest', 'mentor')]