app/soc/views/helper/access.py
changeset 1184 bd9c6101d41d
parent 1180 6290c9e49848
child 1189 14357ec13647
equal deleted inserted replaced
1183:03db1f6d222a 1184:bd9c6101d41d
   546     if entity:
   546     if entity:
   547       return
   547       return
   548 
   548 
   549     raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_GROUP_MSG)
   549     raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_GROUP_MSG)
   550 
   550 
   551   def checkHasRole(self, django_args, logic):
   551   def checkHasRole(self, django_args, logic, field_name=None):
   552     """Checks that the user has the specified role.
   552     """Checks that the user has the specified role.
   553     """
   553     """
   554 
   554 
       
   555     if not field_name:
       
   556       field_name = 'scope_path'
       
   557 
   555     django_args['user'] = self.user
   558     django_args['user'] = self.user
   556     self.checkIsActive(django_args, logic, 'scope_path', 'user')
   559     self.checkIsActive(django_args, logic, field_name, 'user')
   557 
   560 
   558   def checkCanMakeRequestToGroup(self, django_args, group_logic):
   561   def checkCanMakeRequestToGroup(self, django_args, group_logic):
   559     """Raises an alternate HTTP response if the specified group is not in an
   562     """Raises an alternate HTTP response if the specified group is not in an
   560     active status.
   563     active status.
   561 
   564 
   724         'link_id': django_args['link_id'],
   727         'link_id': django_args['link_id'],
   725         'scope_path': django_args['scope_path'],
   728         'scope_path': django_args['scope_path'],
   726         'status': 'active',
   729         'status': 'active',
   727         }
   730         }
   728 
   731 
   729     role_entity = role_logic.logic.getForFields(fields)
   732     role_entity = role_logic.getForFields(fields)
   730 
   733 
   731     fields = {
   734     fields = {
   732         'link_id': self.user.link_id,
   735         'link_id': self.user.link_id,
   733         'scope_path': django_args['scope_path'],
   736         'scope_path': django_args['scope_path'],
   734         'status': 'active'
   737         'status': 'active'
   735         }
   738         }
   736 
   739 
   737     manage_entity = manage_role_logic.logic.getForFields(fields, unique=True)
   740     manage_entity = manage_role_logic.getForFields(fields, unique=True)
   738 
   741 
   739     if not manage_entity:
   742     if not manage_entity:
   740       self.deny(django_args)
   743       self.deny(django_args)
   741 
   744 
   742     return
   745     return