app/soc/views/helper/access.py
changeset 2918 d24b80677879
parent 2850 c935cb48f757
child 2922 6e373954bbf6
equal deleted inserted replaced
2917:b9f600436e89 2918:d24b80677879
  1509       return
  1509       return
  1510 
  1510 
  1511     raise out_of_band.AccessViolation(message_fmt=DEF_NOT_YOUR_ENTITY_MSG)
  1511     raise out_of_band.AccessViolation(message_fmt=DEF_NOT_YOUR_ENTITY_MSG)
  1512 
  1512 
  1513   @allowDeveloper
  1513   @allowDeveloper
       
  1514   def checkIsMyActiveRole(self, django_args, role_logic):
       
  1515     """Checks whether the current user has the active role given by django_args.
       
  1516 
       
  1517     Args:
       
  1518       django_args: a dictionary with django's arguments
       
  1519       logic: the logic that should be used to fetch the role
       
  1520     """
       
  1521 
       
  1522     self.checkIsUser(django_args)
       
  1523 
       
  1524     entity = role_logic.getFromKeyFieldsOr404(django_args)
       
  1525 
       
  1526     if entity.user.key() != self.user.key() or (
       
  1527         entity.link_id != self.user.link_id):
       
  1528       raise out_of_band.AccessViolation(message_fmt=DEF_NOT_YOUR_ENTITY_MSG)
       
  1529 
       
  1530     if entity.status != 'active':
       
  1531       raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_ROLE_MSG)
       
  1532 
       
  1533     # this role belongs to the current user and is active
       
  1534     return
       
  1535 
       
  1536   @allowDeveloper
  1514   @denySidebar
  1537   @denySidebar
  1515   def checkIsAllowedToManageRole(self, django_args, logic_for_role, 
  1538   def checkIsAllowedToManageRole(self, django_args, logic_for_role, 
  1516       manage_role_logic):
  1539       manage_role_logic):
  1517     """Returns an alternate HTTP response if the user is not allowed to manage
  1540     """Returns an alternate HTTP response if the user is not allowed to manage
  1518        the role given in args.
  1541        the role given in args.