diff --git a/composer/schema/browser/schema.py b/composer/schema/browser/schema.py index 78121e2..8fd747e 100644 --- a/composer/schema/browser/schema.py +++ b/composer/schema/browser/schema.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# Copyright (c) 2010 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,14 +24,16 @@ $Id$ from zope import component from zope.cachedescriptors.property import Lazy +from zope.traversing.browser import absoluteURL from cybertools.composer.interfaces import IInstance from cybertools.composer.rule.base import Event from cybertools.composer.rule.interfaces import IRuleManager from cybertools.composer.schema.browser.common import BaseView from cybertools.composer.schema.client import eventTypes, getCheckoutRule -from cybertools.composer.schema.interfaces import IClientFactory +from cybertools.composer.schema.interfaces import IClientFactory, ISchema from cybertools.composer.schema.schema import FormState +from cybertools.util.jeep import Jeep class SchemaView(BaseView): @@ -109,21 +111,39 @@ class FormManagerView(BaseView): isManageMode = False - def getCustomView(self): - if self.isManageMode: - return None - viewName = self.context.getViewName() - if viewName: - return component.getMultiAdapter((self.context, self.request), - name=viewName) - return None - @Lazy def manager(self): return self.context + def update(self): + if self.isManageMode: + return True + for tpl in self.context.getClientSchemas(): + self.context.request.response.redirect(absoluteURL(tpl, self.request)) + break + return False + def overview(self): - return [] + result = [] + for c in self.context.getClients().values(): + instance = IInstance(c) + data = instance.applyTemplate() + data['id'] = data['__name__'] + result.append(data) + return result + + def details(self, clientName): + result = [] + client = self.context.getClients().get(clientName) + schemas = [s for s in self.context.getClientSchemas() + if ISchema.providedBy(s)] + instance = IInstance(client) + for s in schemas: + instance.template = s + data = instance.applyTemplate() + for f in s.fields: + result.append(dict(label=f.title, value=data[f.name])) + return result class CheckoutView(BaseView): @@ -147,7 +167,7 @@ class CheckoutView(BaseView): if data.get('errors'): return True form = self.request.form - clientName = self.getClientName() + #clientName = self.getClientName() if not form.get('action'): return True # TODO: error, redirect to overview client = self.getClient() diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index bf6dbc4..4100d6f 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# Copyright (c) 2010 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -319,16 +319,16 @@ class IClientFactory(Interface): """ +clientManagerViews = SimpleVocabulary(( + SimpleTerm('', '', u'Default view'), + SimpleTerm('redirect_registration.html', 'redirect_registration.html', + u'Redirect to registration') +)) + class IClientManager(Interface): """ Cares for a client typically providing schemas. """ - senderEmail = schema.TextLine( - title=_(u'Sender email'), - description=_(u'Email address that will be used as sender ' - 'address of confirmation and feedback messages.'), - required=False,) - clients = Attribute('A collection of client objects (e.g. persons) ' 'associated with this client manager.') clientSchemas = Attribute('A collection of schema objects ' @@ -339,3 +339,14 @@ class IClientManager(Interface): """ Add the client object given to the collection of clients. """ + +class IFormManager(IClientManager): + """ A standalone object that manages client data via one or more + schema objects. + """ + + senderEmail = schema.TextLine( + title=_(u'Sender email'), + description=_(u'Email address that will be used as sender ' + 'address of confirmation and feedback messages.'), + required=False,) diff --git a/organize/browser/report.py b/organize/browser/report.py index 1d04468..ffa4283 100644 --- a/organize/browser/report.py +++ b/organize/browser/report.py @@ -1,5 +1,5 @@ # -# Copyright (c) 20098 Helmut Merz helmutm@cy55.de +# Copyright (c) 2010 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -58,10 +58,10 @@ class RegistrationsExportCsv(BaseView): for service in self.context.getServices(): for clientName, reg in service.registrations.items(): client = reg.client - data = IInstance(client).applyTemplate() state = IStateful(reg).getStateObject() if state.name == 'temporary' and not withTemporary: continue + data = IInstance(client).applyTemplate() yield [self.encode(service.title) or service.name, clientName, self.encode(data.get('standard.organization', '')),