Back to index

plone3  3.1.7
rule.py
Go to the documentation of this file.
00001 from zope.component import getMultiAdapter
00002 from zope.formlib import form
00003 
00004 from Acquisition import aq_parent, aq_inner
00005 from Products.CMFPlone import PloneMessageFactory as _
00006 
00007 from plone.contentrules.engine.interfaces import IRuleAssignmentManager, IRuleStorage
00008 from plone.contentrules.rule.interfaces import IRuleConfiguration
00009 
00010 from plone.app.contentrules.rule import Rule
00011 from plone.app.contentrules.browser.formhelper import AddForm, EditForm
00012 
00013 class RuleAddForm(AddForm):
00014     """An add form for rules.
00015     """
00016     form_fields = form.FormFields(IRuleConfiguration)
00017     label = _(u"Add Rule")
00018     description = _(u"Add a new rule. Once complete, you can manage the "
00019                      "rule's actions and conditions separately.")
00020     form_name = _(u"Configure rule")
00021     
00022     def nextURL(self):
00023         context = aq_parent(aq_inner(self.context))
00024         url = str(getMultiAdapter((context, self.request), name=u"absolute_url"))
00025         return url + '/@@rules-controlpanel'
00026     
00027     def create(self, data):
00028         rule = Rule()
00029         form.applyChanges(rule, self.form_fields, data)
00030         return rule
00031 
00032 class RuleEditForm(EditForm):
00033     """An edit form for rules.
00034     """
00035     form_fields = form.FormFields(IRuleConfiguration)
00036     label = _(u"Edit Rule")
00037     description = _(u"Edit an existing rule.")
00038     form_name = _(u"Configure rule")
00039     
00040     def nextURL(self):
00041         context = aq_parent(aq_inner(self.context))
00042         url = str(getMultiAdapter((context, self.request), name=u"absolute_url"))
00043         return url + '/@@rules-controlpanel'