diff --git a/organize/browser/service.py b/organize/browser/service.py index 991b968..be2f03e 100644 --- a/organize/browser/service.py +++ b/organize/browser/service.py @@ -68,7 +68,7 @@ class BaseView(SchemaBaseView): if service.start and service.end: typeEnd = 'time' separator = '-' - if time.localtime(service.start)[2] != time.localtime(service.end)[2]: + if self.isMultiDay(service): typeEnd = 'dateTime' separator = ' - ' return ('%s%s%s' % @@ -79,6 +79,33 @@ class BaseView(SchemaBaseView): else: 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): @@ -213,10 +240,15 @@ class CheckoutView(ServiceManagerView): result.append(dict(service=service.title or '???', waitingList=service.waitingList, fromTo=self.getFromTo(service), + fromToDate=self.getFromToDate(service), + fromToTime=self.getFromToTime(service), + isMultiDay=self.isMultiDay(service), location=service.location or '', locationUrl=service.locationUrl or '', number=reg.number, numberWaiting=reg.numberWaiting, + externalId=service.externalId or '', + cost=service.cost or '', serviceObject=service)) return result @@ -231,6 +263,20 @@ class CheckoutView(ServiceManagerView): return True 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): location, locationUrl = info['location'], info['locationUrl'] if locationUrl and locationUrl.startswith('/'): @@ -251,17 +297,27 @@ class CheckoutView(ServiceManagerView): def listRegistrationsText(self): result = [] for info in self.registrationsInfo: + lineData = [] if not info['number'] and not info['numberWaiting']: continue 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']: - line += '\nTeilnehmer: %s' % info['number'] + lineData.append('Teilnehmer: %s' % info['number']) if info['numberWaiting']: - line += '\nTeilnehmer auf Warteliste' + waitingInfo = 'Teilnehmer auf Warteliste' if info['serviceObject'].allowRegWithNumber: - line += ': %s' % info['numberWaiting'] - line += '\n' + waitingInfo += ': %s' % info['numberWaiting'] + lineData.append(waitingInfo) + lineData.append('') + line = '\n'.join(lineData) result.append(line) return '\n'.join(result) @@ -284,6 +340,7 @@ class CheckoutView(ServiceManagerView):