diff --git a/composer/schema/browser/form.py b/composer/schema/browser/form.py index 42eed92..b915e8c 100644 --- a/composer/schema/browser/form.py +++ b/composer/schema/browser/form.py @@ -71,7 +71,7 @@ class Form(object): @Lazy def fields(self): - return self.schema.fields + return [f for f in self.schema.fields if not f.readonly] @Lazy def data(self): diff --git a/composer/schema/browser/schema_macros.pt b/composer/schema/browser/schema_macros.pt index f0e0c52..71ea3c4 100755 --- a/composer/schema/browser/schema_macros.pt +++ b/composer/schema/browser/schema_macros.pt @@ -83,7 +83,17 @@ tal:attributes="name name; style python: 'width: %s' % (width and str(width)+'px' or '450px'); - value data/?name" /> + value data/?name|string:" /> + + + + + @@ -93,7 +103,7 @@ tal:attributes="name name; style python: 'width: %s' % (width and str(width)+'px' or '450px'); - value data/?name" /> + value data/?name|string:" /> @@ -105,7 +115,7 @@ rows python: height or 3; style python: 'width: %s' % (width and str(width)+'px' or '450px');" - tal:content="data/?name"> + tal:content="data/?name|string:"> @@ -126,7 +136,7 @@ tal:content="item/title" tal:attributes="value item/token; selected python: - item['token'] == data[name]">Mrs + item['token'] == data.get(name)">Mrs diff --git a/composer/schema/factory.py b/composer/schema/factory.py index 86ddd8b..f7791a7 100644 --- a/composer/schema/factory.py +++ b/composer/schema/factory.py @@ -68,6 +68,8 @@ class SchemaFactory(object): #default_method=getattr(field, 'default_method', None), vocabulary=voc, title=field.title, - description=field.description) + description=field.description, + readonly=field.readonly, + nostore=getattr(field, 'nostore', False),) fields.append(f) return Schema(name=interface.__name__, *fields, **kw) diff --git a/composer/schema/field.py b/composer/schema/field.py index 0d2b1b2..7457dc3 100644 --- a/composer/schema/field.py +++ b/composer/schema/field.py @@ -38,6 +38,8 @@ class Field(Component): implements(IField) required = False + readonly = False + nostore = False standardFieldName = None vocabulary = None renderFactory = None @@ -73,7 +75,7 @@ class Field(Component): @property def storeData(self): - return self.getFieldTypeInfo().storeData + return not self.nostore and self.getFieldTypeInfo().storeData def getTitleValue(self): return self.title or self.name diff --git a/composer/schema/instance.py b/composer/schema/instance.py index fca6772..71b3405 100644 --- a/composer/schema/instance.py +++ b/composer/schema/instance.py @@ -78,7 +78,7 @@ class Editor(BaseInstance): # don't do anything if there is an error return formState for f in template.components: - if not f.storeData: + if not f.storeData or f.readonly: # a dummy field, e.g. a spacer continue name = f.name @@ -99,7 +99,9 @@ class Editor(BaseInstance): formState = FormState() if self.template is None: return formState - for f in self.template.fields: + for f in self.template.components: + if f.readonly: + continue fi = f.getFieldInstance() value = data.get(f.name) fi.validate(value, data) diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index a2858b2..80174a9 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -86,7 +86,7 @@ fieldTypes = SimpleVocabulary(( FieldType('textarea', 'textarea', u'Textarea'), FieldType('number', 'number', u'Number', inputRenderer='input_textline', instanceName='number'), - #FieldType('date', 'date', u'Date'), + FieldType('date', 'date', u'Date'), FieldType('fileupload', 'fileupload', u'File upload', instanceName='fileupload'), #FieldType('checkbox', 'checkbox', u'Checkbox'),