Changeset 4358
- Timestamp:
- 09/29/08 12:16:53 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
timingandestimationplugin/branches/trac0.11-Permissions/setup.py
r4260 r4358 8 8 description='Plugin to make Trac support time estimation and tracking with permissions', 9 9 keywords='trac plugin estimation timetracking permissions', 10 version='0.7. 1',10 version='0.7.2', 11 11 url='http://www.trac-hacks.org/wiki/TimingAndEstimationPlugin', 12 12 license='http://www.opensource.org/licenses/mit-license.php', timingandestimationplugin/branches/trac0.11-Permissions/timingandestimationplugin/ticket_policy.py
r4293 r4358 8 8 """Hide internal tickets.""" 9 9 implements(IPermissionPolicy) 10 10 group_providers = ExtensionPoint(IPermissionGroupProvider) 11 11 12 # IPermissionPolicy(Interface) 12 13 def check_permission(self, action, username, resource, perm): … … 20 21 resource = resource.parent 21 22 if resource and resource.realm == 'ticket' and resource.id is not None: 22 rtn = self.check_ticket_access(perm, resource )23 rtn = self.check_ticket_access(perm, resource, username) 23 24 self.log.debug("Internal: RESULTS for %s: %s" % (action,rtn)) 24 25 return rtn 25 26 return None 26 27 28 # Internal methods 29 def _get_groups(self, user): 30 # Get initial subjects 31 groups = set([user]) 32 for provider in self.group_providers: 33 for group in provider.get_permission_groups(user): 34 groups.add(group) 35 36 perms = PermissionSystem(self.env).get_all_permissions() 37 repeat = True 38 while repeat: 39 repeat = False 40 for subject, action in perms: 41 if subject in groups and action.islower() and action not in groups: 42 groups.add(action) 43 repeat = True 44 45 return groups 46 27 47 # Public methods 28 def check_ticket_access(self, perm, res ):48 def check_ticket_access(self, perm, res, user): 29 49 """Return if this req is permitted access to the given ticket ID.""" 30 50 try: … … 32 52 except TracError: 33 53 return None # Ticket doesn't exist 34 private_tkt = tkt .get_value_or_default('internal')== '1'54 private_tkt = tkt['internal'] == '1' 35 55 36 56 if private_tkt: 37 57 # cant just check or we get in an infinite call loop 38 58 perm = PermissionCache(self.env, self.username, None, perm._cache) 39 return perm.has_permission(self.config.get('ticket', 'internalgroup', 'TIME_ADMIN' ).upper()) 59 groups = self._get_groups(user) 60 perm_or_group = self.config.get('ticket', 'internalgroup', 'TIME_ADMIN' ) 61 return perm_or_group in groups or perm.has_permission(perm_or_group) 40 62 return None
