# HG changeset patch # User Thierry Florac # Date 1426869065 -3600 # Node ID 89e74695091870aa58d1244bdee7982ddd1f56cc # Parent f96107cb3c3518b00a0482968c6ce16a8387b5cc Removed ZCML directives diff -r f96107cb3c35 -r 89e746950918 src/pyams_file/configure.zcml --- a/src/pyams_file/configure.zcml Fri Mar 20 17:30:42 2015 +0100 +++ b/src/pyams_file/configure.zcml Fri Mar 20 17:31:05 2015 +0100 @@ -9,10 +9,6 @@ - - - - diff -r f96107cb3c35 -r 89e746950918 src/pyams_file/widget/__init__.py --- a/src/pyams_file/widget/__init__.py Fri Mar 20 17:30:42 2015 +0100 +++ b/src/pyams_file/widget/__init__.py Fri Mar 20 17:31:05 2015 +0100 @@ -20,9 +20,10 @@ from pyams_file.interfaces import IFileField, IFileWidget, IImageField, IImageWidget, \ IThumnailImageWidget, IThumbnailImageField, DELETED_FILE from pyams_form.interfaces.form import IFormLayer -from z3c.form.interfaces import IFieldWidget, NOT_CHANGED, IDataConverter +from z3c.form.interfaces import NOT_CHANGED, IFieldWidget, IDataConverter # import packages +from pyams_form.widget import widgettemplate_config from pyams_utils.adapter import adapter_config from z3c.form.browser.file import FileWidget as BaseFileWidget from z3c.form.converter import BaseDataConverter @@ -51,26 +52,34 @@ return toBytes(value) +@widgettemplate_config(mode='input', template='templates/file-input.pt', widget=IFileWidget, layer=IFormLayer) +@widgettemplate_config(mode='display', template='templates/file-display.pt', widget=IFileWidget, layer=IFormLayer) @implementer_only(IFileWidget) class FileWidget(BaseFileWidget): """File widget""" - label_css_class = 'input input-file' - @property def current_value(self): if self.form.ignoreContext: return None - return self.field.get(self.context) + lang = getattr(self, 'lang', None) + if lang is None: + return self.field.get(self.context) + else: + value = self.field.get(self.context) + if isinstance(value, dict): + value = value.get(lang) + return value @property def deletable(self): if self.required: return False - elif self.value is NOT_CHANGED: - return self.current_value is not None + if not self.ignoreContext: + value = self.current_value else: - return self.value is not None + value = self.value + return bool(value) @adapter_config(context=(IFileField, IFormLayer), provides=IFieldWidget) @@ -78,6 +87,8 @@ return FieldWidget(field, FileWidget(request)) +@widgettemplate_config(mode='input', template='templates/image-input.pt', widget=IImageWidget, layer=IFormLayer) +@widgettemplate_config(mode='display', template='templates/image-display.pt', widget=IImageWidget, layer=IFormLayer) @implementer_only(IImageWidget) class ImageWidget(FileWidget): """Image widget""" diff -r f96107cb3c35 -r 89e746950918 src/pyams_file/widget/configure.zcml --- a/src/pyams_file/widget/configure.zcml Fri Mar 20 17:30:42 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - diff -r f96107cb3c35 -r 89e746950918 src/pyams_file/widget/templates/file-input.pt --- a/src/pyams_file/widget/templates/file-input.pt Fri Mar 20 17:30:42 2015 +0100 +++ b/src/pyams_file/widget/templates/file-input.pt Fri Mar 20 17:31:05 2015 +0100 @@ -1,4 +1,4 @@ - +
- +
diff -r f96107cb3c35 -r 89e746950918 src/pyams_file/widget/templates/image-input.pt --- a/src/pyams_file/widget/templates/image-input.pt Fri Mar 20 17:30:42 2015 +0100 +++ b/src/pyams_file/widget/templates/image-input.pt Fri Mar 20 17:31:05 2015 +0100 @@ -1,4 +1,4 @@ - +
-