Merge branch 'master' into bbmaster
This commit is contained in:
		
						commit
						9989af825a
					
				
					 4 changed files with 17 additions and 14 deletions
				
			
		|  | @ -78,6 +78,8 @@ Check actors | ||||||
|   >>> removeAction.actors = ['master'] |   >>> removeAction.actors = ['master'] | ||||||
| 
 | 
 | ||||||
|   >>> demo.getActors() |   >>> demo.getActors() | ||||||
|  |   >>> demo.checkActors(['master']) | ||||||
|  |   True | ||||||
| 
 | 
 | ||||||
|   >>> demo.empty = True |   >>> demo.empty = True | ||||||
|   >>> removeAction in demo.getAvailableTransitionsForUser() |   >>> removeAction in demo.getAvailableTransitionsForUser() | ||||||
|  |  | ||||||
|  | @ -80,6 +80,17 @@ class Stateful(object): | ||||||
|     def getStatesDefinition(self): |     def getStatesDefinition(self): | ||||||
|         return statesDefinitions.get(self.statesDefinition, None) |         return statesDefinitions.get(self.statesDefinition, None) | ||||||
| 
 | 
 | ||||||
|  |     def checkActors(self, actors): | ||||||
|  |         if not actors: | ||||||
|  |             return True | ||||||
|  |         stfActors = self.getActors() | ||||||
|  |         if stfActors is None: | ||||||
|  |             return True | ||||||
|  |         for actor in actors: | ||||||
|  |             if actor in stfActors: | ||||||
|  |                 return True | ||||||
|  |         return False | ||||||
|  | 
 | ||||||
|     def getActors(self): |     def getActors(self): | ||||||
|         return None |         return None | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -129,7 +129,7 @@ class StatesDefinition(object): | ||||||
|             return False |             return False | ||||||
|         if action.condition and not action.condition(obj): |         if action.condition and not action.condition(obj): | ||||||
|             return False |             return False | ||||||
|         if not self.checkActors(action.actors, obj): |         if not obj.checkActors(action.actors): | ||||||
|             return False |             return False | ||||||
|         if not self.checkRoles(action.roles, obj): |         if not self.checkRoles(action.roles, obj): | ||||||
|             return False |             return False | ||||||
|  | @ -137,15 +137,6 @@ class StatesDefinition(object): | ||||||
|             return False |             return False | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
|     def checkActors(self, actors, obj): |  | ||||||
|         stfActors = obj.getActors() |  | ||||||
|         if stfActors is None: |  | ||||||
|             return True |  | ||||||
|         for actor in actors: |  | ||||||
|             if actor in stfActors: |  | ||||||
|                 return True |  | ||||||
|         return False |  | ||||||
| 
 |  | ||||||
|     def checkRoles(self, roles, obj): |     def checkRoles(self, roles, obj): | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -103,10 +103,9 @@ class IStateful(Interface): | ||||||
|             for the current state. |             for the current state. | ||||||
|         """ |         """ | ||||||
| 
 | 
 | ||||||
|     def getActors(): |     def checkActors(actors): | ||||||
|         """ Return a collection of names of actors or groups that will be |         """ Return True if this stateful object is associated with the  | ||||||
|             used for checking if a certain transition is allowed. May be  |             actors given. | ||||||
|             None in which case not checking should be applied. |  | ||||||
|         """ |         """ | ||||||
| 
 | 
 | ||||||
|     def notify(transition, previousState): |     def notify(transition, previousState): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue