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())
|
||||
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())
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue