Exemple #1
0
class UpdateAction(BaseAction):
    """Update action for any locatable object.
    """
    successMessage = _(u"Content updated")
    failureMessage = _(u'Updated failed')

    def __call__(self, form):
        data, errors = form.extractData()
        if errors:
            form.submissionError = errors
            return FAILURE

        apply_data_event(form.fields, form.getContentData(), data)
        message(self.successMessage)
        url = str(IURL(form.context, form.request))
        return SuccessMarker('Updated', True, url=url)
Exemple #2
0
 def label(self):
     name = getattr(self.context.factory, 'name', None)
     if name is not None:
         if isinstance(name, Message):
             name = zope.i18n.translate(name, context=self.request)
         return zope.i18n.translate(
             _(u"add_action", default="Add: $name",
               mapping={'name': name}), context=self.request)
     return 'Add'
Exemple #3
0
    def __call__(self, form):
        data, errors = form.extractData()
        if errors:
            form.submissionError = errors
            return FAILURE

        apply_data_event(form.fields, form.getContentData(), data)
        message(_(u"Content updated"))
        url = get_absolute_url(form.context, form.request)
        return SuccessMarker('Updated', True, url=url)
Exemple #4
0
 def handle_edit(self):
     data, errors = self.extractData()
     if errors:
         self.submissionError = errors
         return FAILURE
     for x in ['adresszusatz', 'ort', 'plz', 'nr', 'email', 'strasse', 'telefon']:
         if data[x] == NO_VALUE:
             data[x] = ""
     apply_data_event(self.fields, self.getContentData(), data)
     self.flash(_(u"Content updated"))
     self.redirect(self.url(self.context))
Exemple #5
0
 def handle_edit(self):
     data, errors = self.extractData()
     if errors:
         self.submissionError = errors
         return FAILURE
     def getUnternehmen(mnr):
         session = Session()
         return session.query(Unternehmen).get(mnr)
     data['unternehmen'] = [getUnternehmen(x) for x in list(data['unternehmen'])]
     teilnehmer = self.getContentData()
     apply_data_event(self.fields, teilnehmer, data)
     teilnehmer = teilnehmer.getContent()
     self.flash(_(u"Content updated"))
     self.redirect(self.application_url() + '?form.field.id=%s&form.action.suchen=Suchen' %teilnehmer.id)
Exemple #6
0
    def __call__(self, form):
        data, errors = form.extractData()
        if errors:
            form.submissionError = errors
            return FAILURE

        obj = self.factory()
        set_fields_data(form.fields, obj, data)
        notify(ObjectCreatedEvent(obj))
        form.context.add(obj)

        message(_(u"Content created"))
        url = get_absolute_url(obj, form.request)
        return SuccessMarker('Added', True, url=url)
Exemple #7
0
class AddAction(BaseAction):
    """Add action for an IAdding context.
    """
    successMessage = _(u"Content created")
    failureMessage = _(u'Adding failed')
    
    def __init__(self, *args, **kwargs):
        self.factory = kwargs.pop('factory')
        super(AddAction, self).__init__(title)
    
    def __call__(self, form):
        data, errors = form.extractData()
        if errors:
            form.submissionError = errors
            return FAILURE

        obj = self.factory()
        set_fields_data(form.fields, obj, data)
        notify(ObjectCreatedEvent(obj))
        form.context.add(obj)

        message(self.successMessage)
        url = str(IURL(obj, form.request))
        return SuccessMarker('Added', True, url=url)
Exemple #8
0
 def label(self):
     label = _(u"edit_action", default=u"Edit: $name",
               mapping={"name": dc_title_or_name(self.context)})
     return zope.i18n.translate(label, context=self.request)
Exemple #9
0
 def actions(self):
     add = formactions.AddAction(_("Add"), self.context.factory)
     return Actions(add, formactions.CancelAction(_("Cancel")))
Exemple #10
0
 def handle_edit(self):
     data, errors = self.extractData()
     apply_data_event(self.fields, self.getContentData(), data)
     self.flash(_(u"Content updated"))
     self.redirect(self.url(self.context))
 def label(self):
     label = _(u"delete_action", default=u"Delete: $name",
               mapping={"name": title_or_name(self.context)})
     return translate(label)