app/soc/views/helper/access.py
changeset 1305 9567bb475d6d
parent 1300 a89d673771eb
child 1307 091a21cf3627
equal deleted inserted replaced
1304:b736aed728c2 1305:9567bb475d6d
   112     'The scope for this request is not active.')
   112     'The scope for this request is not active.')
   113 
   113 
   114 DEF_PAGE_DENIED_MSG = ugettext(
   114 DEF_PAGE_DENIED_MSG = ugettext(
   115     'Access to this page has been restricted')
   115     'Access to this page has been restricted')
   116 
   116 
       
   117 DEF_PREFIX_NOT_IN_ARGS_MSG = ugettext(
       
   118     'A required GET url argument ("prefix") was not specified')
       
   119 
   117 DEF_PAGE_INACTIVE_MSG = ugettext(
   120 DEF_PAGE_INACTIVE_MSG = ugettext(
   118     'This page is inactive at this time')
   121     'This page is inactive at this time')
   119 
   122 
   120 DEF_LOGOUT_MSG_FMT = ugettext(
   123 DEF_LOGOUT_MSG_FMT = ugettext(
   121     'Please <a href="%(sign_out)s">sign out</a> in order to view this page')
   124     'Please <a href="%(sign_out)s">sign out</a> in order to view this page')
   936     document = document_logic.getFromKeyFieldsOr404(django_args)
   939     document = document_logic.getFromKeyFieldsOr404(django_args)
   937 
   940 
   938     self.checkMembership('write', document.prefix,
   941     self.checkMembership('write', document.prefix,
   939                          document.write_access, django_args)
   942                          document.write_access, django_args)
   940 
   943 
       
   944   @allowDeveloper
       
   945   def checkDocumentPick(self, django_args):
       
   946     """Checks whether the user has access to the specified pick url.
       
   947 
       
   948     Will update the 'read_access' field of django_args['GET'].
       
   949     """
       
   950 
       
   951     get_args = django_args['GET']
       
   952 
       
   953     # make mutable in order to inject the proper read_access filter
       
   954     mutable = get_args._mutable
       
   955     get_args._mutable = True
       
   956 
       
   957     if 'prefix' not in get_args:
       
   958       raise out_of_band.AccessViolation(message_fmt=DEF_PREFIX_NOT_IN_ARGS_MSG)
       
   959 
       
   960     prefix = get_args['prefix']
       
   961 
       
   962     checker = rights_logic.Checker(prefix)
       
   963     memberships = checker.getMemberships()
       
   964 
       
   965     roles = []
       
   966     for key, value in memberships.iteritems():
       
   967       if self.hasMembership(value, django_args):
       
   968         roles.append(key)
       
   969 
       
   970     get_args.setlist('read_access', roles)
       
   971     get_args._mutable = mutable
       
   972 
   941   def checkCanEditTimeline(self, django_args):
   973   def checkCanEditTimeline(self, django_args):
   942     """Checks whether this program's timeline may be edited.
   974     """Checks whether this program's timeline may be edited.
   943     """
   975     """
   944 
   976 
   945     time_line_keyname = django_args['scope_path']
   977     time_line_keyname = django_args['scope_path']