show additional fields on checkout, also separate date and time for start/end
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3475 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
78404c45a8
commit
95f2faacb2
2 changed files with 84 additions and 13 deletions
|
@ -68,7 +68,7 @@ class BaseView(SchemaBaseView):
|
||||||
if service.start and service.end:
|
if service.start and service.end:
|
||||||
typeEnd = 'time'
|
typeEnd = 'time'
|
||||||
separator = '-'
|
separator = '-'
|
||||||
if time.localtime(service.start)[2] != time.localtime(service.end)[2]:
|
if self.isMultiDay(service):
|
||||||
typeEnd = 'dateTime'
|
typeEnd = 'dateTime'
|
||||||
separator = ' - '
|
separator = ' - '
|
||||||
return ('%s%s%s' %
|
return ('%s%s%s' %
|
||||||
|
@ -79,6 +79,33 @@ class BaseView(SchemaBaseView):
|
||||||
else:
|
else:
|
||||||
return '-'
|
return '-'
|
||||||
|
|
||||||
|
def getFromToDate(self, service=None):
|
||||||
|
if service is None:
|
||||||
|
service = self.context
|
||||||
|
end = ''
|
||||||
|
if service.start and service.end:
|
||||||
|
start = self.getFormattedDate(service.start, type='date', variant='short')
|
||||||
|
end = ''
|
||||||
|
if self.isMultiDay(service):
|
||||||
|
end = ' - ' + self.getFormattedDate(service.end, type='date',
|
||||||
|
variant='short')
|
||||||
|
return start + end
|
||||||
|
else:
|
||||||
|
return '-'
|
||||||
|
|
||||||
|
def getFromToTime(self, service=None):
|
||||||
|
if service is None:
|
||||||
|
service = self.context
|
||||||
|
if service.start and service.end:
|
||||||
|
start = self.getFormattedDate(service.start, type='time', variant='short')
|
||||||
|
end = self.getFormattedDate(service.end, type='time', variant='short')
|
||||||
|
return '%s - %s' % (start, end)
|
||||||
|
else:
|
||||||
|
return '-'
|
||||||
|
|
||||||
|
def isMultiDay(self, service):
|
||||||
|
return time.localtime(service.start)[2] != time.localtime(service.end)[2]
|
||||||
|
|
||||||
|
|
||||||
class ServiceManagerView(BaseView):
|
class ServiceManagerView(BaseView):
|
||||||
|
|
||||||
|
@ -213,10 +240,15 @@ class CheckoutView(ServiceManagerView):
|
||||||
result.append(dict(service=service.title or '???',
|
result.append(dict(service=service.title or '???',
|
||||||
waitingList=service.waitingList,
|
waitingList=service.waitingList,
|
||||||
fromTo=self.getFromTo(service),
|
fromTo=self.getFromTo(service),
|
||||||
|
fromToDate=self.getFromToDate(service),
|
||||||
|
fromToTime=self.getFromToTime(service),
|
||||||
|
isMultiDay=self.isMultiDay(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,
|
numberWaiting=reg.numberWaiting,
|
||||||
|
externalId=service.externalId or '',
|
||||||
|
cost=service.cost or '',
|
||||||
serviceObject=service))
|
serviceObject=service))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -231,6 +263,20 @@ class CheckoutView(ServiceManagerView):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def hasCost(self):
|
||||||
|
for reg in self.registrationsInfo:
|
||||||
|
if reg['cost']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def hasExternalId(self):
|
||||||
|
for reg in self.registrationsInfo:
|
||||||
|
if reg['externalId']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def getLocationInfo(self, info):
|
def getLocationInfo(self, info):
|
||||||
location, locationUrl = info['location'], info['locationUrl']
|
location, locationUrl = info['location'], info['locationUrl']
|
||||||
if locationUrl and locationUrl.startswith('/'):
|
if locationUrl and locationUrl.startswith('/'):
|
||||||
|
@ -251,17 +297,27 @@ class CheckoutView(ServiceManagerView):
|
||||||
def listRegistrationsText(self):
|
def listRegistrationsText(self):
|
||||||
result = []
|
result = []
|
||||||
for info in self.registrationsInfo:
|
for info in self.registrationsInfo:
|
||||||
|
lineData = []
|
||||||
if not info['number'] and not info['numberWaiting']:
|
if not info['number'] and not info['numberWaiting']:
|
||||||
continue
|
continue
|
||||||
locationInfo = self.getLocationInfo(info)
|
locationInfo = self.getLocationInfo(info)
|
||||||
line = '\n'.join((info['service'], info['fromTo'], locationInfo))
|
lineData = [info['service'],
|
||||||
|
'Datum: ' + info['fromToDate'],
|
||||||
|
'Uhrzeit: ' + info['fromToTime'],
|
||||||
|
locationInfo]
|
||||||
|
if info['cost']:
|
||||||
|
lineData.append('Kostenbeitrag: %s,00 Euro' % info['cost'])
|
||||||
|
if info['externalId']:
|
||||||
|
lineData.append('Code: %s' % info['externalId'])
|
||||||
if info['serviceObject'].allowRegWithNumber and info['number']:
|
if info['serviceObject'].allowRegWithNumber and info['number']:
|
||||||
line += '\nTeilnehmer: %s' % info['number']
|
lineData.append('Teilnehmer: %s' % info['number'])
|
||||||
if info['numberWaiting']:
|
if info['numberWaiting']:
|
||||||
line += '\nTeilnehmer auf Warteliste'
|
waitingInfo = 'Teilnehmer auf Warteliste'
|
||||||
if info['serviceObject'].allowRegWithNumber:
|
if info['serviceObject'].allowRegWithNumber:
|
||||||
line += ': %s' % info['numberWaiting']
|
waitingInfo += ': %s' % info['numberWaiting']
|
||||||
line += '\n'
|
lineData.append(waitingInfo)
|
||||||
|
lineData.append('')
|
||||||
|
line = '\n'.join(lineData)
|
||||||
result.append(line)
|
result.append(line)
|
||||||
return '\n'.join(result)
|
return '\n'.join(result)
|
||||||
|
|
||||||
|
@ -284,6 +340,7 @@ class CheckoutView(ServiceManagerView):
|
||||||
<th>Angebot</th>
|
<th>Angebot</th>
|
||||||
<th>Datum/Uhrzeit</th>
|
<th>Datum/Uhrzeit</th>
|
||||||
<th>Ort</th>
|
<th>Ort</th>
|
||||||
|
%s %s
|
||||||
</tr>
|
</tr>
|
||||||
%s
|
%s
|
||||||
</table>
|
</table>
|
||||||
|
@ -294,27 +351,40 @@ class CheckoutView(ServiceManagerView):
|
||||||
<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>
|
||||||
|
%s %s
|
||||||
</tr>
|
</tr>
|
||||||
'''
|
'''
|
||||||
def listRegistrationsHtml(self):
|
def listRegistrationsHtml(self):
|
||||||
result = []
|
result = []
|
||||||
waitingHeader = ''
|
waitingHeader = costHeader = externalIdHeader = ''
|
||||||
waitingRow = '<td width="5%%">%i</td>'
|
waitingRow = '<td width="5%%">%i</td>'
|
||||||
|
costRow = '<td>%s,00 Euro</td>'
|
||||||
|
externalIdRow = '<td>%s</td>'
|
||||||
if self.hasWaiting:
|
if self.hasWaiting:
|
||||||
waitingHeader = '<th width="5%%">Warteliste</th>'
|
waitingHeader = '<th width="5%%">Warteliste</th>'
|
||||||
|
if self.hasCost:
|
||||||
|
costHeader = '<th>Kostenbeitrag</th>'
|
||||||
|
if self.hasExternalId:
|
||||||
|
externalIdHeader = '<th style="white-space: nowrap">Code</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'],
|
line = self.row % (info['number'],
|
||||||
self.hasWaiting and
|
self.hasWaiting and
|
||||||
waitingRow % info['numberWaiting'] or '',
|
waitingRow % info['numberWaiting'] or '',
|
||||||
info['service'],
|
info['service'],
|
||||||
info['fromTo'].replace(' ', ' '),
|
info['fromToDate'] + '<br />' + info['fromToTime'],
|
||||||
locationInfo)
|
locationInfo,
|
||||||
|
self.hasCost and
|
||||||
|
costRow % info['cost'] or '',
|
||||||
|
self.hasExternalId and
|
||||||
|
externalIdRow % info['externalId'] or '',
|
||||||
|
)
|
||||||
result.append(line)
|
result.append(line)
|
||||||
return self.html % (waitingHeader, '\n'.join(result))
|
return self.html % (waitingHeader, costHeader, externalIdHeader,
|
||||||
|
'\n'.join(result))
|
||||||
|
|
||||||
|
|
||||||
class ServiceView(BaseView):
|
class ServiceView(BaseView):
|
||||||
|
|
|
@ -126,7 +126,8 @@ class Service(object):
|
||||||
|
|
||||||
manager = None
|
manager = None
|
||||||
category = None
|
category = None
|
||||||
location = u''
|
location = locationUrl = externalId = u''
|
||||||
|
cost = 0.0
|
||||||
allowRegWithNumber = False
|
allowRegWithNumber = False
|
||||||
allowDirectRegistration = True
|
allowDirectRegistration = True
|
||||||
waitingList = False
|
waitingList = False
|
||||||
|
|
Loading…
Add table
Reference in a new issue