diff --git a/organize/browser/service.py b/organize/browser/service.py index d9ed5bf..21dffd8 100644 --- a/organize/browser/service.py +++ b/organize/browser/service.py @@ -161,7 +161,7 @@ class ServiceManagerView(BaseView): self.request.response.redirect(self.registrationUrl()) return 'redirect' # let template skip rendering - def overview(self, includeCategories=None): + def overview(self, includeCategories=None, skipInactive=False): result = [] classific = [] category = None @@ -170,6 +170,8 @@ class ServiceManagerView(BaseView): for cat, idx, svc in svcs: if includeCategories and cat not in includeCategories: continue + if skipInactive and not svc.isActive(): + continue level = 0 if cat != category: term = serviceCategories.getTermByToken(cat) @@ -442,6 +444,8 @@ class ServiceView(BaseView): def allowRegistration(self): context = self.context + if not context.isActive(): + return False if not context.allowDirectRegistration: return False return (self.capacityAvailable() or self.context.waitingList @@ -580,6 +584,8 @@ class RegistrationTemplateView(BaseView): return (svc.category, svc.getClassification(), svc.start) def allowRegistration(self, service): + if not service.isActive(): + return False return (self.capacityAvailable(service) or service.waitingList or service in self.getRegisteredServices()) diff --git a/organize/interfaces.py b/organize/interfaces.py index 89d567d..d5e83f5 100644 --- a/organize/interfaces.py +++ b/organize/interfaces.py @@ -174,6 +174,11 @@ class IServiceManager(Interface): 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): """ 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.') + def isActive(): + """ Return True if object is active, e.g. based on effective/expiration + dates or workflow state. + """ serviceCategories = SimpleVocabulary(( SimpleTerm('event', 'event', u'Event'), @@ -292,6 +301,11 @@ class IService(Interface): resources = Attribute('A collection of one or more resources.') 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): """ Register a client with this service. Return an IRegistration object if the registration is successful, otherwise diff --git a/organize/service.py b/organize/service.py index 4a868fc..b06c17f 100644 --- a/organize/service.py +++ b/organize/service.py @@ -71,6 +71,9 @@ class ServiceManager(object): if self.clientSchemasFactory is not None: self.clientSchemas = self.clientSchemasFactory() + def isActive(self): + return True + def getServices(self, categories=[]): return self.services @@ -161,6 +164,9 @@ class Service(object): def getToken(self): return self.name + def isActive(self): + return True + def getAvailableCapacity(self, ignoreWaiting=False): if not ignoreWaiting and self.getNumberWaiting() > 0: return 0