Exemplo n.º 1
0
 def checkAccess(self, required):
     if 'level' in required:
         script = self.daemon_device.current_script()
         rlevel = required['level']
         if isinstance(rlevel, str):
             for k, v in ACCESS_LEVELS.items():
                 if v == rlevel:
                     rlevel = k
                     break
             else:
                 raise AccessError('invalid access level name: %r' % rlevel)
         if script and rlevel > script.user.level:
             raise AccessError('%s access is not sufficient, %s access '
                               'is required' %
                               (ACCESS_LEVELS.get(script.user.level,
                                                  str(script.user.level)),
                                ACCESS_LEVELS.get(rlevel, str(rlevel))))
     return NoninteractiveSession.checkAccess(self, required)
Exemplo n.º 2
0
 def checkAccess(self, required):
     if 'level' in required:
         rlevel = self._string_to_level(required['level'])
         if rlevel > self._user_level:
             raise AccessError('%s access is not sufficient, %s access '
                               'is required' %
                               (ACCESS_LEVELS.get(self._user_level,
                                                  str(self._user_level)),
                                ACCESS_LEVELS.get(rlevel, str(rlevel))))
     return Session.checkAccess(self, required)
Exemplo n.º 3
0
 def doWriteCopies(self, value):
     if self.private and not session.checkAccess(ADMIN):
         raise AccessError(
             self, 'Only admins can change the receiver list '
             'for this notifier')
     return value