new method 'isActive' for additional control of registrations
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3661 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									639cc81422
								
							
						
					
					
						commit
						88b6a81b26
					
				
					 3 changed files with 27 additions and 1 deletions
				
			
		|  | @ -161,7 +161,7 @@ class ServiceManagerView(BaseView): | ||||||
|         self.request.response.redirect(self.registrationUrl()) |         self.request.response.redirect(self.registrationUrl()) | ||||||
|         return 'redirect'  # let template skip rendering |         return 'redirect'  # let template skip rendering | ||||||
| 
 | 
 | ||||||
|     def overview(self, includeCategories=None): |     def overview(self, includeCategories=None, skipInactive=False): | ||||||
|         result = [] |         result = [] | ||||||
|         classific = [] |         classific = [] | ||||||
|         category = None |         category = None | ||||||
|  | @ -170,6 +170,8 @@ class ServiceManagerView(BaseView): | ||||||
|         for cat, idx, svc in svcs: |         for cat, idx, svc in svcs: | ||||||
|             if includeCategories and cat not in includeCategories: |             if includeCategories and cat not in includeCategories: | ||||||
|                 continue |                 continue | ||||||
|  |             if skipInactive and not svc.isActive(): | ||||||
|  |                 continue | ||||||
|             level = 0 |             level = 0 | ||||||
|             if cat != category: |             if cat != category: | ||||||
|                 term = serviceCategories.getTermByToken(cat) |                 term = serviceCategories.getTermByToken(cat) | ||||||
|  | @ -442,6 +444,8 @@ class ServiceView(BaseView): | ||||||
| 
 | 
 | ||||||
|     def allowRegistration(self): |     def allowRegistration(self): | ||||||
|         context = self.context |         context = self.context | ||||||
|  |         if not context.isActive(): | ||||||
|  |             return False | ||||||
|         if not context.allowDirectRegistration: |         if not context.allowDirectRegistration: | ||||||
|             return False |             return False | ||||||
|         return (self.capacityAvailable() or self.context.waitingList |         return (self.capacityAvailable() or self.context.waitingList | ||||||
|  | @ -580,6 +584,8 @@ class RegistrationTemplateView(BaseView): | ||||||
|         return (svc.category, svc.getClassification(), svc.start) |         return (svc.category, svc.getClassification(), svc.start) | ||||||
| 
 | 
 | ||||||
|     def allowRegistration(self, service): |     def allowRegistration(self, service): | ||||||
|  |         if not service.isActive(): | ||||||
|  |             return False | ||||||
|         return (self.capacityAvailable(service) or service.waitingList |         return (self.capacityAvailable(service) or service.waitingList | ||||||
|                 or service in self.getRegisteredServices()) |                 or service in self.getRegisteredServices()) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -174,6 +174,11 @@ class IServiceManager(Interface): | ||||||
| 
 | 
 | ||||||
|     services = Attribute('A collection of services managed by this object.') |     services = Attribute('A collection of services managed by this object.') | ||||||
| 
 | 
 | ||||||
|  |     def isActive(): | ||||||
|  |         """ Return True if object is active, e.g. based on effective/expiration | ||||||
|  |             dates or workflow state. | ||||||
|  |         """ | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class IServiceGroup(Interface): | class IServiceGroup(Interface): | ||||||
|     """ A group of related services or a general service definition, |     """ A group of related services or a general service definition, | ||||||
|  | @ -182,6 +187,10 @@ class IServiceGroup(Interface): | ||||||
| 
 | 
 | ||||||
|     services = Attribute('A collection of services belonging to this object.') |     services = Attribute('A collection of services belonging to this object.') | ||||||
| 
 | 
 | ||||||
|  |     def isActive(): | ||||||
|  |         """ Return True if object is active, e.g. based on effective/expiration | ||||||
|  |             dates or workflow state. | ||||||
|  |         """ | ||||||
| 
 | 
 | ||||||
| serviceCategories = SimpleVocabulary(( | serviceCategories = SimpleVocabulary(( | ||||||
|     SimpleTerm('event', 'event', u'Event'), |     SimpleTerm('event', 'event', u'Event'), | ||||||
|  | @ -292,6 +301,11 @@ class IService(Interface): | ||||||
|     resources = Attribute('A collection of one or more resources.') |     resources = Attribute('A collection of one or more resources.') | ||||||
|     registrations = Attribute('A collection of client registrations.') |     registrations = Attribute('A collection of client registrations.') | ||||||
| 
 | 
 | ||||||
|  |     def isActive(): | ||||||
|  |         """ Return True if object is active, e.g. based on effective/expiration | ||||||
|  |             dates or workflow state. | ||||||
|  |         """ | ||||||
|  | 
 | ||||||
|     def register(client): |     def register(client): | ||||||
|         """ Register a client with this service. Return an IRegistration |         """ Register a client with this service. Return an IRegistration | ||||||
|             object if the registration is successful, otherwise |             object if the registration is successful, otherwise | ||||||
|  |  | ||||||
|  | @ -71,6 +71,9 @@ class ServiceManager(object): | ||||||
|         if self.clientSchemasFactory is not None: |         if self.clientSchemasFactory is not None: | ||||||
|             self.clientSchemas = self.clientSchemasFactory() |             self.clientSchemas = self.clientSchemasFactory() | ||||||
| 
 | 
 | ||||||
|  |     def isActive(self): | ||||||
|  |         return True | ||||||
|  | 
 | ||||||
|     def getServices(self, categories=[]): |     def getServices(self, categories=[]): | ||||||
|         return self.services |         return self.services | ||||||
| 
 | 
 | ||||||
|  | @ -161,6 +164,9 @@ class Service(object): | ||||||
|     def getToken(self): |     def getToken(self): | ||||||
|         return self.name |         return self.name | ||||||
| 
 | 
 | ||||||
|  |     def isActive(self): | ||||||
|  |         return True | ||||||
|  | 
 | ||||||
|     def getAvailableCapacity(self, ignoreWaiting=False): |     def getAvailableCapacity(self, ignoreWaiting=False): | ||||||
|         if not ignoreWaiting and self.getNumberWaiting() > 0: |         if not ignoreWaiting and self.getNumberWaiting() > 0: | ||||||
|             return 0 |             return 0 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm