示例#1
0
文件: forms.py 项目: morganjk/zopache
class EditForm(Form):
    """
    """
    subTitle='Edit This Object'
    ignoreContent = False
    ignoreRequest = False
    actions = Actions(formactions.Edit(_("Edit","Save")),
                      formactions.SaveAndView(_("SaveAndView","Save And View")),
                      formactions.Cancel(_("Cancel","Cancel")))
    @CachedProperty
    def fields(self):
        if hasattr(self,'interface'):
            return  Fields(IName,self.interface).omit("__parent__")
        return Fields()

    @property
    def label(self):
        return ''
        label = _(u"Edit this Object", default=u"Edit: $name",
                  mapping={"name": title_or_name(self.context)})
        return translate(label)

    @CachedProperty
    def fields(self):
        edited = self.getContentData().getContent()
        return getAllFields(edited, '__parent__', '__name__')
示例#2
0
class Delete(Action):
    """Delete action for any locatable context.
    """
    successMessage = _(u"The object has been deleted.")
    failureMessage = _(u"This object could not be deleted.")

    def available(self, form):
        content = form.getContentData().getContent()
        if ILocation.providedBy(content):
            container = content.__parent__
            return (hasattr(container, '__delitem__') and
                    hasattr(container, '__contains__'))
        return False

    def __call__(self, form):
        content = form.getContentData().getContent()

        if ILocation.providedBy(content):
            container = content.__parent__
            name = content.__name__
            if name in container:
                try:
                    del container[name]
                    form.status = self.successMessage
                    message(form.status)
                    url = str(IURL(container, form.request))
                    return SuccessMarker('Deleted', True, url=url)
                except ValueError:
                    pass

        form.status = self.failureMessage
        message(form.status)
        return FAILURE
示例#3
0
文件: forms.py 项目: morganjk/zopache
class DeleteForm(Form):
    """A confirmation for to delete an object.
    """
    label =''
    subTitle='Delete This Object'
    description = _(u"Are you really sure ? This will also delete all of its children.")
    actions = Actions(formactions.Delete(_("Delete","Delete")),
                      formactions.Cancel(_("Cancel","Cancel")))

    @property
    def label(self):
        return ''
        label = u"Delete This Object?" 
        return translate(label)
示例#4
0
    def __call__(self, form):
        self.form=form
        data, errors = form.extractData()
        if errors:
            form.submissionError = errors
            return FAILURE

        apply_data_event(form.fields, form.getContentData(), data)
        message(_(u"Content updated"))
        form.postProcess()
        baseURL = str(IURL(form.context, form.request))
        url=self.newURL(baseURL)
        return SuccessMarker('Updated', True, url=url)
示例#5
0
 def __call__(self, form):
     self.form=form
     data, errors = form.extractData()
     if errors:
         form.submissionError = errors
         return FAILURE
     obj= form.factory()
     form.new=obj
     context=form.context
     set_fields_data(form.fields, obj, data)
     notify(ObjectCreatedEvent(obj))
     name=data['__name__']
     newName=uniqueName(context,name,ofType="#")
     context[newName]=obj
     message(_(u"Content created"))
     baseURL = str(IURL(obj, form.request))    
     self.new=form.new=obj
     url=self.newURL(baseURL)
     form.new.postProcess()
     return SuccessMarker('Added', True, url=url,code=307)
示例#6
0
文件: forms.py 项目: morganjk/zopache
 def label(self):
     return ''
     label = _(u"Edit this Object", default=u"Edit: $name",
               mapping={"name": title_or_name(self.context)})
     return translate(label)
示例#7
0
文件: forms.py 项目: morganjk/zopache
 def actions(self):
     return Actions(
           formactions.Add(_("Add","Add"), self.factory),
           formactions.Cancel(_("Cancel","Cancel")))