equal
deleted
inserted
replaced
50 |
50 |
51 @implementer(IIllustration) |
51 @implementer(IIllustration) |
52 class Illustration(Persistent, Contained, RenderedContentMixin): |
52 class Illustration(Persistent, Contained, RenderedContentMixin): |
53 """Illustration persistent class""" |
53 """Illustration persistent class""" |
54 |
54 |
|
55 _data = I18nFileProperty(IIllustration['data']) |
55 title = FieldProperty(IIllustration['title']) |
56 title = FieldProperty(IIllustration['title']) |
56 alt_title = FieldProperty(IIllustration['alt_title']) |
57 alt_title = FieldProperty(IIllustration['alt_title']) |
57 description = FieldProperty(IIllustration['description']) |
58 description = FieldProperty(IIllustration['description']) |
58 author = FieldProperty(IIllustration['author']) |
59 author = FieldProperty(IIllustration['author']) |
59 _data = I18nFileProperty(IIllustration['data']) |
|
60 filename = FieldProperty(IIllustration['filename']) |
|
61 language = FieldProperty(IIllustration['language']) |
|
62 renderer = FieldProperty(IIllustration['renderer']) |
60 renderer = FieldProperty(IIllustration['renderer']) |
63 |
61 |
64 @property |
62 @property |
65 def data(self): |
63 def data(self): |
66 return self._data |
64 return self._data |
96 data = II18n(illustration).get_attribute('data', lang, request) |
94 data = II18n(illustration).get_attribute('data', lang, request) |
97 if data: |
95 if data: |
98 info = IFileInfo(data) |
96 info = IFileInfo(data) |
99 info.title = II18n(illustration).get_attribute('title', lang, request) |
97 info.title = II18n(illustration).get_attribute('title', lang, request) |
100 info.description = II18n(illustration).get_attribute('alt_title', lang, request) |
98 info.description = II18n(illustration).get_attribute('alt_title', lang, request) |
101 if not illustration.filename: |
|
102 illustration.filename = info.filename |
|
103 else: |
|
104 info.filename = illustration.filename |
|
105 info.language = illustration.language |
|
106 |
99 |
107 |
100 |
108 @subscriber(IObjectAddedEvent, context_selector=IIllustration) |
101 @subscriber(IObjectAddedEvent, context_selector=IIllustration) |
109 def handle_added_illustration(event): |
102 def handle_added_illustration(event): |
110 """Handle added illustration""" |
103 """Handle added illustration""" |
167 output.append(missing_value.format(field=translate(IIllustration[attr].title))) |
160 output.append(missing_value.format(field=translate(IIllustration[attr].title))) |
168 else: |
161 else: |
169 output.append(missing_lang_value.format(field=translate(IIllustration[attr].title), |
162 output.append(missing_lang_value.format(field=translate(IIllustration[attr].title), |
170 lang=lang)) |
163 lang=lang)) |
171 if has_data: |
164 if has_data: |
172 for attr in ('author', 'filename'): |
165 for attr in ('author', ): |
173 value = getattr(self.context, attr) |
166 value = getattr(self.context, attr) |
174 if not value: |
167 if not value: |
175 output.append(missing_value.format(field=translate(IIllustration[attr].title))) |
168 output.append(missing_value.format(field=translate(IIllustration[attr].title))) |
176 return output |
169 return output |
177 |
170 |