Пример #1
0
 def handle_edit_action(self, action, data):
     """ handle edit """
     changed = applyChanges(self.context, self.form_fields, data,
                            self.adapters)
     if changed:
         attrs = Attributes(interfaces.IPublication, *changed)
         event.notify(ObjectModifiedEvent(self.context, attrs))
         # TODO: Needs locale support. See also Five.form.EditView.
         self.status = _("Successfully updated")
     else:
         self.status = _('No changes')
     statusmessages_ifaces.IStatusMessage(self.request).addStatusMessage(
         self.status, 'info')
     redirect = self.request.response.redirect
     return redirect(self.context.absolute_url() + '/view')
Пример #2
0
 def handle_edit_action(self, action, data):
     """ handle edit """
     changed = applyChanges(
         self.context, self.form_fields, data, self.adapters)
     if changed:
         attrs = Attributes(interfaces.IPublication, *changed)
         event.notify(
             ObjectModifiedEvent(self.context, attrs)
             )
         # TODO: Needs locale support. See also Five.form.EditView.
         self.status = _("Successfully updated")
     else:
         self.status = _('No changes')
     statusmessages_ifaces.IStatusMessage(
         self.request).addStatusMessage(self.status, 'info')
     redirect = self.request.response.redirect
     return redirect(self.context.absolute_url() + '/view')
Пример #3
0
class PublicationEditForm(formbase.EditForm):
    """Form for editing publication fields.
    """

    template = pagetemplatefile.ViewPageTemplateFile(
        'templates/publication-edit.pt')
    form_fields = form.FormFields(interfaces.IPublication)
    #form_fields['chapters'].customq_widget = CollectionInputWidget

    label = u'Edit Publication Data'
    priority_fields = ['title']

    def update(self):
        """ update the form """
        self.adapters = {}
        form_fields = self.form_fields
        # here we can fiddle...
        self.form_fields = form_fields
        super(PublicationEditForm, self).update()

    def setUpWidgets(self, ignore_request=False):
        """ setup edit widgets """
        self.widgets = form.setUpEditWidgets(self.form_fields,
                                             self.prefix,
                                             self.context,
                                             self.request,
                                             adapters=self.adapters,
                                             ignore_request=ignore_request)

    @form.action(_("Apply"), condition=form.haveInputWidgets)
    def handle_edit_action(self, action, data):
        """ handle edit """
        changed = applyChanges(self.context, self.form_fields, data,
                               self.adapters)
        if changed:
            attrs = Attributes(interfaces.IPublication, *changed)
            event.notify(ObjectModifiedEvent(self.context, attrs))
            # TODO: Needs locale support. See also Five.form.EditView.
            self.status = _("Successfully updated")
        else:
            self.status = _('No changes')
        statusmessages_ifaces.IStatusMessage(self.request).addStatusMessage(
            self.status, 'info')
        redirect = self.request.response.redirect
        return redirect(self.context.absolute_url() + '/view')
Пример #4
0
 def getTranslatedString(self, value, preflang, default=u''):
     if not isinstance(value, unicode):
         value = value.decode(getSiteEncoding(self))
     msg = _(value, default)
     return translate(msg, target_language=preflang)
Пример #5
0
 def getTranslatedString(self, value, preflang, default=u''):
     if not isinstance(value, unicode):
         value = value.decode(getSiteEncoding(self))
     msg = _(value, default)
     return translate(msg, target_language=preflang)
# Add i18n msgids here which do not exist in filesystem code so that
# the translation-extract script can find them

from slc.publications import SLCPublicationsMessageFactory as _

# browser/templates/publication.pt and estimate_template.pt use a
# method: getTranslatedString to handle the translation because of a
# bug. This may no longer be necessary, but I haven't verified it so
# I'm adding the labels here for extraction.\
_('label_download_full_publication',
  default='Download the full publication as PDF')
_('label_order_copy',
  default='Order a printed copy of this document!')
_('label_available_in', default='Available in')
_('heading_chapterlisting',
  default='Chapters in this Publication')
_('heading_related_resources', default='Related Resources')
_('box_show_more_publications',
  default='Show more publications on')
_('label_estimated_download_time',
  default='Estimated Download Time')