waiting list: base functionality OK
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3429 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
f07dd40bd9
commit
cbbb46d02f
2 changed files with 66 additions and 17 deletions
|
@ -211,16 +211,37 @@ class CheckoutView(ServiceManagerView):
|
||||||
for reg in regs:
|
for reg in regs:
|
||||||
service = reg.service
|
service = reg.service
|
||||||
result.append(dict(service=service.title or '???',
|
result.append(dict(service=service.title or '???',
|
||||||
|
waitingList=service.waitingList,
|
||||||
fromTo=self.getFromTo(service),
|
fromTo=self.getFromTo(service),
|
||||||
location=service.location or '',
|
location=service.location or '',
|
||||||
locationUrl=service.locationUrl or '',
|
locationUrl=service.locationUrl or '',
|
||||||
number=reg.number,
|
number=reg.number,
|
||||||
|
numberWaiting=reg.numberWaiting,
|
||||||
serviceObject=service))
|
serviceObject=service))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def registrationsInfo(self):
|
||||||
|
return self.getRegistrationsInfo()
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def hasWaiting(self):
|
||||||
|
for reg in self.registrationsInfo:
|
||||||
|
if reg['numberWaiting'] > 0:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def getLocationInfo(self, info):
|
||||||
|
location, locationUrl = info['location'], info['locationUrl']
|
||||||
|
if locationUrl and locationUrl.startswith('/'):
|
||||||
|
locationUrl = self.request.get('SERVER_URL') + locationUrl
|
||||||
|
locationInfo = (locationUrl and '%s (%s)' % (location, locationUrl)
|
||||||
|
or location)
|
||||||
|
return locationInfo
|
||||||
|
|
||||||
def listRegistrationsTextTable(self):
|
def listRegistrationsTextTable(self):
|
||||||
result = []
|
result = []
|
||||||
for info in self.getRegistrationsInfo():
|
for info in self.registrationsInfo:
|
||||||
line = '%-30s %27s' % (info['service'], info['fromTo'])
|
line = '%-30s %27s' % (info['service'], info['fromTo'])
|
||||||
if info['serviceObject'].allowRegWithNumber:
|
if info['serviceObject'].allowRegWithNumber:
|
||||||
line += ' %4i' % info['number']
|
line += ' %4i' % info['number']
|
||||||
|
@ -229,22 +250,37 @@ class CheckoutView(ServiceManagerView):
|
||||||
|
|
||||||
def listRegistrationsText(self):
|
def listRegistrationsText(self):
|
||||||
result = []
|
result = []
|
||||||
for info in self.getRegistrationsInfo():
|
for info in self.registrationsInfo:
|
||||||
location, locationUrl = info['location'], info['locationUrl']
|
if not info['number'] and not info['numberWaiting']:
|
||||||
if locationUrl and locationUrl.startswith('/'):
|
continue
|
||||||
locationUrl = self.request.get('SERVER_URL') + locationUrl
|
locationInfo = self.getLocationInfo(info)
|
||||||
locationInfo = (locationUrl and '%s (%s)' % (location, locationUrl)
|
line = '\n'.join((info['service'], info['fromTo'], locationInfo))
|
||||||
or location)
|
if info['serviceObject'].allowRegWithNumber and info['number']:
|
||||||
|
line += '\nTeilnehmer: %s\n' % info['number']
|
||||||
|
if info['numberWaiting']:
|
||||||
|
line += 'Teilnehmer auf Warteliste'
|
||||||
|
if info['serviceObject'].allowRegWithNumber:
|
||||||
|
line += ': %s' % info['numberWaiting']
|
||||||
|
line += '\n'
|
||||||
|
result.append(line)
|
||||||
|
return '\n'.join(result)
|
||||||
|
|
||||||
|
def listRegistrationsWaitingText(self):
|
||||||
|
result = []
|
||||||
|
for info in self.registrationsInfo:
|
||||||
|
if not info['numberWaiting']:
|
||||||
|
continue
|
||||||
|
locationInfo = self.getLocationInfo(info)
|
||||||
line = '\n'.join((info['service'], info['fromTo'], locationInfo))
|
line = '\n'.join((info['service'], info['fromTo'], locationInfo))
|
||||||
if info['serviceObject'].allowRegWithNumber:
|
if info['serviceObject'].allowRegWithNumber:
|
||||||
line += '\nTeilnehmer: %s\n' % info['number']
|
line += '\nTeilnehmer: %s\n' % info['numberWaiting']
|
||||||
result.append(line)
|
result.append(line)
|
||||||
return '\n'.join(result)
|
return '\n'.join(result)
|
||||||
|
|
||||||
html = '''
|
html = '''
|
||||||
<table class="listing" style="width: 100%%">
|
<table class="listing" style="width: 100%%">
|
||||||
<tr>
|
<tr>
|
||||||
<th width="5%%">Teilnehmer</th>
|
<th width="5%%">Teilnehmer</th>%s
|
||||||
<th>Angebot</th>
|
<th>Angebot</th>
|
||||||
<th>Datum/Uhrzeit</th>
|
<th>Datum/Uhrzeit</th>
|
||||||
<th>Ort</th>
|
<th>Ort</th>
|
||||||
|
@ -254,7 +290,7 @@ class CheckoutView(ServiceManagerView):
|
||||||
'''
|
'''
|
||||||
row = '''
|
row = '''
|
||||||
<tr>
|
<tr>
|
||||||
<td width="5%%">%i</td>
|
<td width="5%%">%i</td>%s
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td style="white-space: nowrap">%s</td>
|
<td style="white-space: nowrap">%s</td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
|
@ -262,16 +298,23 @@ class CheckoutView(ServiceManagerView):
|
||||||
'''
|
'''
|
||||||
def listRegistrationsHtml(self):
|
def listRegistrationsHtml(self):
|
||||||
result = []
|
result = []
|
||||||
|
waitingHeader = ''
|
||||||
|
waitingRow = '<td width="5%%">%i</td>'
|
||||||
|
if self.hasWaiting:
|
||||||
|
waitingHeader = '<th width="5%%">Warteliste</th>'
|
||||||
for info in self.getRegistrationsInfo():
|
for info in self.getRegistrationsInfo():
|
||||||
location, locationUrl = info['location'], info['locationUrl']
|
location, locationUrl = info['location'], info['locationUrl']
|
||||||
locationInfo = (locationUrl
|
locationInfo = (locationUrl
|
||||||
and ('<a href="%s">%s</a>' % (locationUrl, location))
|
and ('<a href="%s">%s</a>' % (locationUrl, location))
|
||||||
or location)
|
or location)
|
||||||
line = self.row % (info['number'], info['service'],
|
line = self.row % (info['number'],
|
||||||
|
self.hasWaiting and
|
||||||
|
waitingRow % info['numberWaiting'] or '',
|
||||||
|
info['service'],
|
||||||
info['fromTo'].replace(' ', ' '),
|
info['fromTo'].replace(' ', ' '),
|
||||||
locationInfo)
|
locationInfo)
|
||||||
result.append(line)
|
result.append(line)
|
||||||
return self.html % '\n'.join(result)
|
return self.html % (waitingHeader, '\n'.join(result))
|
||||||
|
|
||||||
|
|
||||||
class ServiceView(BaseView):
|
class ServiceView(BaseView):
|
||||||
|
@ -356,6 +399,8 @@ class ServiceView(BaseView):
|
||||||
if state.name != 'temporary':
|
if state.name != 'temporary':
|
||||||
total += reg.number
|
total += reg.number
|
||||||
totalWaiting += reg.numberWaiting
|
totalWaiting += reg.numberWaiting
|
||||||
|
if not self.context.waitingList:
|
||||||
|
totalWaiting = ''
|
||||||
return dict(number=total, numberWaiting=totalWaiting)
|
return dict(number=total, numberWaiting=totalWaiting)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
@ -169,13 +169,17 @@ class Service(object):
|
||||||
|
|
||||||
def register(self, client, number=1):
|
def register(self, client, number=1):
|
||||||
clientName = client.__name__
|
clientName = client.__name__
|
||||||
numberWaiting = 0
|
numberWaiting = current = 0
|
||||||
if (self.waitingList and self.availableCapacity >= 0
|
reg = None
|
||||||
and number > self.availableCapacity):
|
|
||||||
numberWaiting = number - self.availableCapacity
|
|
||||||
number = self.availableCapacity
|
|
||||||
if clientName in self.registrations:
|
if clientName in self.registrations:
|
||||||
reg = self.registrations[clientName]
|
reg = self.registrations[clientName]
|
||||||
|
current = reg.number
|
||||||
|
if (self.waitingList and self.availableCapacity >= 0
|
||||||
|
and number > (self.availableCapacity + current)):
|
||||||
|
numberWaiting = number - current - self.availableCapacity
|
||||||
|
#number = self.availableCapacity + current
|
||||||
|
number = number - numberWaiting
|
||||||
|
if reg is not None:
|
||||||
if number != reg.number:
|
if number != reg.number:
|
||||||
reg.number = number
|
reg.number = number
|
||||||
# TODO: set timeStamp
|
# TODO: set timeStamp
|
||||||
|
|
Loading…
Add table
Reference in a new issue