From aa4ce1bbf585adbcadcae487554811ec5fca2b23 Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 26 Nov 2007 17:19:30 +0000 Subject: [PATCH] prio 1 changes, see notes 2007-11-26 git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2197 fd906abe-77d9-0310-91a1-e0d9ade77398 --- composer/schema/browser/common.py | 15 ++++++++++----- composer/schema/browser/schema.py | 6 ++++-- composer/schema/instance.py | 8 ++++++-- composer/schema/interfaces.py | 1 + organize/browser/service.py | 10 +++++++--- organize/interfaces.py | 9 +++++++-- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/composer/schema/browser/common.py b/composer/schema/browser/common.py index 795f57f..eea8de0 100644 --- a/composer/schema/browser/common.py +++ b/composer/schema/browser/common.py @@ -124,6 +124,13 @@ class BaseView(object): submit=getCheckoutView, ) + def getButtonAction(self): + form = self.request.form + for bn in self.buttonActions: + if bn in form: + return bn + return None + @Lazy def nextUrl(self): return self.getNextUrl() @@ -132,11 +139,9 @@ class BaseView(object): #viewName = 'thankyou.html' viewName = '' url = '' - form = self.request.form - for bn in self.buttonActions: - if bn in form: - url = self.buttonActions[bn](self) - break + bn = self.getButtonAction() + if bn: + url = self.buttonActions[bn](self) return '%s?id=%s' % (url, self.clientName) #return '%s/%s?id=%s' % (self.url, viewName, self.clientName) diff --git a/composer/schema/browser/schema.py b/composer/schema/browser/schema.py index 5495cbf..f0afd7a 100644 --- a/composer/schema/browser/schema.py +++ b/composer/schema/browser/schema.py @@ -89,8 +89,10 @@ class SchemaView(BaseView): newClient = True instance = component.getAdapter(client, IInstance, name='editor') instance.template = self.context - self.formState = formState = instance.applyTemplate(form) - if formState.severity > 0: + ignoreValidation = (self.getButtonAction() == 'submit_previous') + self.formState = formState = instance.applyTemplate(form, + ignoreValidation=ignoreValidation) + if formState.severity > 0 and not ignoreValidation: # show form again; do not add client to manager return True if newClient: diff --git a/composer/schema/instance.py b/composer/schema/instance.py index ec4303b..8926b49 100644 --- a/composer/schema/instance.py +++ b/composer/schema/instance.py @@ -69,12 +69,13 @@ class Editor(BaseInstance): def applyTemplate(self, data={}, *args, **kw): fieldHandlers = kw.get('fieldHandlers', {}) + ignoreValidation = kw.get('ignoreValidation', False) template = self.template context = self.context formState = self.validate(data) if template is None: return formState - if formState.severity > 0: + if formState.severity > 0 and not ignoreValidation: # don't do anything if there is an error return formState for f in template.components: @@ -169,8 +170,9 @@ class ClientInstanceEditor(ClientInstance): template = self.template if template is None: return FormState() + ignoreValidation = kw.get('ignoreValidation', False) formState = self.validate(data) - if formState.severity > 0: + if formState.severity > 0 and not ignoreValidation: # don't do anything if there is an error return formState attrs = getattr(self.context, self.attrsName, None) @@ -185,6 +187,8 @@ class ClientInstanceEditor(ClientInstance): continue if name in data: fi = formState.fieldInstances[name] + if fi.severity > 0: # never store faulty field input + continue value = fi.unmarshall(data.get(name)) oldValue = values.get(name) if value != oldValue: diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index 878a183..7e8ed7a 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -91,6 +91,7 @@ fieldTypes = SimpleVocabulary(( instanceName='fileupload'), #FieldType('checkbox', 'checkbox', u'Checkbox'), FieldType('dropdown', 'dropdown', u'Drop-down selection'), + #FieldType('listbox', 'listbox', u'List box (multiple selection)'), FieldType('calculated', 'display', u'Calculated Value', instanceName='calculated'), FieldType('spacer', 'spacer', u'Spacer', diff --git a/organize/browser/service.py b/organize/browser/service.py index df66260..ab67c4d 100644 --- a/organize/browser/service.py +++ b/organize/browser/service.py @@ -206,6 +206,7 @@ class CheckoutView(ServiceManagerView): service = reg.service result.append(dict(service=service.title, fromTo=self.getFromTo(service), + location=service.location, number=reg.number, serviceObject=service)) return result @@ -222,9 +223,9 @@ class CheckoutView(ServiceManagerView): def listRegistrationsText(self): result = [] for info in self.getRegistrationsInfo(): - line = '%s\n%s\n' % (info['service'], info['fromTo']) + line = '\n'.join((info['service'], info['fromTo'], info['location'])) if info['serviceObject'].allowRegWithNumber: - line += 'Teilnehmer: %s\n' % info['number'] + line += '\nTeilnehmer: %s\n' % info['number'] result.append(line) return '\n'.join(result) @@ -234,6 +235,7 @@ class CheckoutView(ServiceManagerView): Teilnehmer Angebot Datum/Uhrzeit + Ort %s @@ -243,13 +245,15 @@ class CheckoutView(ServiceManagerView): %i %s %s + %s ''' def listRegistrationsHtml(self): result = [] for info in self.getRegistrationsInfo(): line = self.row % (info['number'], info['service'], - info['fromTo'].replace(' ', '  ')) + info['fromTo'].replace(' ', '  '), + info['location']) result.append(line) return self.html % '\n'.join(result) diff --git a/organize/interfaces.py b/organize/interfaces.py index c422c1d..58d1d4c 100644 --- a/organize/interfaces.py +++ b/organize/interfaces.py @@ -237,7 +237,7 @@ class IService(Interface): 'waiting list.'), required=False,) location = schema.TextLine( - title=_(u'Location Information'), + title=_(u'Location information'), description=_(u'Basic location information or ' 'start point for transport services.'), required=False,) @@ -247,7 +247,7 @@ class IService(Interface): 'about the location.'), required=False,) location2 = schema.TextLine( - title=_(u'Location Information (2)'), + title=_(u'Location information (2)'), description=_(u'Additional location information or ' 'end point for transport services.'), required=False,) @@ -261,6 +261,11 @@ class IService(Interface): description=_(u'Web address (URL) for more information ' 'about the service.'), required=False,) + infoUrl = schema.TextLine( + title=_(u'Additional information'), + description=_(u'Web address (URL) of a document that ' + 'offers additional information.'), + required=False,) availableCapacity = Attribute('Available capacity, i.e. number of seats ' 'still available; a negative number means: '