Пример #1
0
 def title_continued(self):
     if not self.title:
         return None
     text = translate(format_message(_("${title} (continued)"),
                                     mapping={'title': self.title}),
                      context=self.request)
     return text
Пример #2
0
 def toFieldValue(self, value):
     if value is None or value == '':
         return z3c.form.interfaces.NOT_CHANGED
     if value == 'delete':
         # XXX: delete checkbox was marked
         return None
     data = value.read()
     try:
         image = Image.open(StringIO(data))
         if image.format not in ('JPEG', 'PNG'):
             raise IOError()
     except (IOError,):
         raise FormatterValidationError(
             _('The file uploaded is not a JPEG or PNG image'), value)
     size = len(data)
     if size > self.field.max_file_size:
         msg = _('The image uploaded cannot be larger than ${size} MB')
         raise FormatterValidationError(
             format_message(
                 msg,
                 mapping={'size': '%.2f' % (float(size) / (10**6))}),
             value)
     data = self.processImage(image)
     f = ImageFile()
     self.updateFile(f, data)
     return f
Пример #3
0
 def updateDisplayWidgets(self):
     set_server_status_message(self, self.context.__parent__)
     if self.context.status_code is not None:
         status_text = translate(format_message(
             status_messages[self.context.status_code],
             mapping=self.context.status_parameters),
                                 context=self.request)
         self.widgets['status'].value = status_text
         self.widgets['status'].style = u'color: red;'
Пример #4
0
 def title_continued(self):
     if not self.title:
         return None
     text = translate(
         format_message(
             _("${title} (continued)"),
             mapping={'title': self.title}),
         context=self.request)
     return text
Пример #5
0
 def update(self):
     self.task_progress.add('collecting', title=u'', progress=0.0)
     event = zope.contentprovider.interfaces.BeforeUpdateEvent
     total = len(self.viewlets)
     for nv, viewlet in enumerate(self.viewlets):
         title = format_message(self.collecting_title,
                                {'name': viewlet.title or _('files')})
         self.task_progress.force('collecting',
                                  title=title,
                                  progress=normalized_progress(nv, total),
                                  active=True)
         zope.event.notify(event(viewlet, self.request))
         viewlet.update()
     title = format_message(self.collecting_title, {'name': _('files')})
     self.task_progress.force('collecting',
                              title=title,
                              progress=None,
                              active=False)
     self.addArchivers()
Пример #6
0
 def update(self):
     self.task_progress.add('collecting',
         title=u'', progress=0.0)
     event = zope.contentprovider.interfaces.BeforeUpdateEvent
     total = len(self.viewlets)
     for nv, viewlet in enumerate(self.viewlets):
         title = format_message(self.collecting_title,
                                {'name': viewlet.title or _('files')})
         self.task_progress.force(
             'collecting',
             title=title,
             progress=normalized_progress(nv, total),
             active=True)
         zope.event.notify(event(viewlet, self.request))
         viewlet.update()
     title = format_message(self.collecting_title,
                            {'name': _('files')})
     self.task_progress.force('collecting', title=title, progress=None, active=False)
     self.addArchivers()
Пример #7
0
 def updateDisplayWidgets(self):
     set_server_status_message(self, self.context.__parent__)
     if self.context.status_code is not None:
         status_text = translate(
             format_message(
                 status_messages[self.context.status_code],
                 mapping=self.context.status_parameters),
             context=self.request)
         self.widgets['status'].value = status_text
         self.widgets['status'].style = u'color: red;'
Пример #8
0
 def toFieldValue(self, value):
     """See interfaces.IDataConverter"""
     if value == u'':
         return self.field.missing_value
     lines = filter(None, [s.strip() for s in unicode(value).splitlines()])
     if not lines:
         return self.field.missing_value
     field_value = []
     for line in lines:
         if line in field_value:
             raise FormatterValidationError(
                 format_message(_('Duplicate entry "${value}"'),
                                mapping={'value': line}), line)
         if len(line) >= 64:
             raise FormatterValidationError(
                 format_message(_('Value too long "${value}"'),
                                mapping={'value': line}), line)
         field_value.append(line)
     return field_value
Пример #9
0
 def updateDialog(self):
     if self.ajax_settings['dialog'] == 'close':
         return
     target = self.target
     if target is not None:
         target_title = getMultiAdapter((target, self.request), name='title')
         dialog_title = translate(
             format_message(
                 self.dialog_title_template, mapping={'target': target_title()}),
             context=self.request)
         self.ajax_settings['dialog']['title'] = dialog_title
Пример #10
0
 def toFieldValue(self, value):
     """See interfaces.IDataConverter"""
     if value == u'':
         return self.field.missing_value
     lines = filter(None, [s.strip() for s in unicode(value).splitlines()])
     if not lines:
         return self.field.missing_value
     field_value = []
     for line in lines:
         if line in field_value:
             raise FormatterValidationError(
                 format_message(_('Duplicate entry "${value}"'),
                                mapping={'value': line}),
                 line)
         if len(line) >= 64:
             raise FormatterValidationError(
                 format_message(_('Value too long "${value}"'),
                                mapping={'value': line}),
                 line)
         field_value.append(line)
     return field_value
Пример #11
0
 def updateDialog(self):
     if self.ajax_settings['dialog'] == 'close':
         return
     target = self.target
     if target is not None:
         target_title = getMultiAdapter((target, self.request),
                                        name='title')
         dialog_title = translate(
             format_message(self.dialog_title_template,
                            mapping={'target': target_title()}),
             context=self.request)
         self.ajax_settings['dialog']['title'] = dialog_title
Пример #12
0
 def update(self):
     attrs = ['from_address', 'to_addresses', 'time_created',
              'subject', 'body', 'status', 'time_sent']
     self.attrs = []
     datetime_format = self.preferred_datetime_format()
     info_adapter = IEmailDisplayForm(self.context)
     for attr in attrs:
         info = {'label': IEmailDisplayForm[attr].title}
         if attr != 'status':
             value = getattr(info_adapter, attr)
             if attr in ('time_created', 'time_sent'):
                 value = value.strftime(datetime_format)
         else:
             value = None
             if self.context.status_code is not None:
                 value = translate(
                     format_message(
                         status_messages[self.context.status_code],
                         mapping=self.context.status_parameters),
                     context=self.request)
         info['value'] = value
         self.attrs.append(info)
Пример #13
0
 def update(self):
     attrs = [
         'from_address', 'to_addresses', 'time_created', 'subject', 'body',
         'status', 'time_sent'
     ]
     self.attrs = []
     datetime_format = self.preferred_datetime_format()
     info_adapter = IEmailDisplayForm(self.context)
     for attr in attrs:
         info = {'label': IEmailDisplayForm[attr].title}
         if attr != 'status':
             value = getattr(info_adapter, attr)
             if attr in ('time_created', 'time_sent'):
                 value = value.strftime(datetime_format)
         else:
             value = None
             if self.context.status_code is not None:
                 value = translate(format_message(
                     status_messages[self.context.status_code],
                     mapping=self.context.status_parameters),
                                   context=self.request)
         info['value'] = value
         self.attrs.append(info)
Пример #14
0
 def send(self, sender=None, recipients=None):
     self.title = format_message(
         self.title,
         mapping={'ticket': self.task_id})
     Message.send(
         self, sender=sender, recipients=recipients)
Пример #15
0
 def send(self, sender=None, recipients=None):
     self.title = format_message(self.title,
                                 mapping={'ticket': self.task_id})
     Message.send(self, sender=sender, recipients=recipients)