Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
plone.app.contentrules.browser.elements.ManageElements Class Reference
Inheritance diagram for plone.app.contentrules.browser.elements.ManageElements:
Inheritance graph
[legend]
Collaboration diagram for plone.app.contentrules.browser.elements.ManageElements:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __call__
def base_url
def view_url
def rule_title
def rule_description
def rule_event
def actions
def conditions
def addable_conditions
def addable_actions
def assignments

Static Public Attributes

tuple template = ViewPageTemplateFile('templates/manage-elements.pt')

Private Member Functions

def _populate_info
def _move_up
def _move_down

Detailed Description

Manage elements in a rule

Definition at line 20 of file elements.py.


Member Function Documentation

Definition at line 26 of file elements.py.

00026 
00027     def __call__(self):
00028         redirect = False
00029         form = self.request.form
00030         idx = form.get('element_id', 0)
00031         
00032         rule = aq_inner(self.context)
00033         status = IStatusMessage(self.request)
00034         
00035         if 'form.button.Save' in form:
00036             rule.title = form.get('title', rule.title)
00037             rule.description = form.get('description', rule.description)
00038             status.addStatusMessage(_(u"Changes saved."), type='info')
00039         elif 'form.button.EditCondition' in form:
00040             editview = self.conditions()[idx]['editview']
00041             self.request.response.redirect(editview)
00042             redirect = True
00043         elif 'form.button.DeleteCondition' in form:
00044             del rule.conditions[idx]
00045             status.addStatusMessage(_(u"Condition deleted."), type='info')
00046         elif 'form.button.MoveConditionUp' in form:
00047             self._move_up(rule.conditions, idx)
00048             status.addStatusMessage(_(u"Condition moved up."), type='info')
00049         elif 'form.button.MoveConditionDown' in form:
00050             self._move_down(rule.conditions, idx)
00051             status.addStatusMessage(_(u"Condition moved down."), type='info')
00052             
00053         elif 'form.button.EditAction' in form:
00054             editview = self.actions()[idx]['editview']
00055             self.request.response.redirect(editview)
00056             redirect = True
00057         elif 'form.button.DeleteAction' in form:
00058             del rule.actions[idx]
00059             status.addStatusMessage(_(u"Action deleted."), type='info')
00060         elif 'form.button.MoveActionUp' in form:
00061             self._move_up(rule.actions, idx)
00062             status.addStatusMessage(_(u"Action moved up."), type='info')
00063         elif 'form.button.MoveActionDown' in form:
00064             self._move_down(rule.actions, idx)
00065             status.addStatusMessage(_(u"Action moved down."), type='info')
00066     
00067         if not redirect:
00068             return self.template()
    

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.contentrules.browser.elements.ManageElements._move_down (   self,
  elements,
  idx 
) [private]

Definition at line 199 of file elements.py.

00199 
00200     def _move_down(self, elements, idx):
00201         element = elements[idx]
00202         del elements[idx]
00203         elements.insert(idx + 1, element)

Here is the caller graph for this function:

def plone.app.contentrules.browser.elements.ManageElements._move_up (   self,
  elements,
  idx 
) [private]

Definition at line 194 of file elements.py.

00194 
00195     def _move_up(self, elements, idx):
00196         element = elements[idx]
00197         del elements[idx]
00198         elements.insert(idx - 1, element)
        

Here is the caller graph for this function:

def plone.app.contentrules.browser.elements.ManageElements._populate_info (   self,
  elements,
  meta,
  namespace 
) [private]
Given an actual list of actions/conditions (elements) and a dict
mapping element type names to instances (meta), and a namespace
('action' or 'condition'), return a list of dicts usable by the view
template.

Definition at line 159 of file elements.py.

00159 
00160     def _populate_info(self, elements, meta, namespace):
00161         """Given an actual list of actions/conditions (elements) and a dict
00162         mapping element type names to instances (meta), and a namespace
00163         ('action' or 'condition'), return a list of dicts usable by the view
00164         template.
00165         """
00166         rule = aq_inner(self.context)
00167         context = aq_parent(rule)
00168         
00169         url = str(getMultiAdapter((context, self.request), name=u"absolute_url"))
00170         base_url = self.base_url()
00171         
00172         info = []
00173         
00174         last = len(elements) - 1
00175         for idx in range(len(elements)):
00176             e = elements[idx]
00177             
00178             data = IRuleElementData(e)
00179             descriptor = meta[data.element]
00180             
00181             editview = None
00182             if descriptor.editview:
00183                 editview = '%s/++%s++%d/%s' % (base_url, namespace, idx, descriptor.editview,)
00184             
00185             info.append({'title'       : descriptor.title,
00186                          'description' : descriptor.description,
00187                          'summary'     : data.summary,
00188                          'editview'    : editview,
00189                          'first'       : (idx == 0),
00190                          'last'        : (idx == last),
00191                          'idx'         : idx,
00192                         })
00193         return info
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 92 of file elements.py.

00092 
00093     def actions(self):
00094         actions = {}
00095         for name, utility in getUtilitiesFor(IRuleAction):
00096             actions[name] = utility    
00097         return self._populate_info(self.context.actions, actions, 'action')
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 118 of file elements.py.

00118 
00119     def addable_actions(self):
00120         rule = aq_inner(self.context)
00121         context = aq_parent(rule)
00122         baseUrl = str(getMultiAdapter((context, self.request), name=u"absolute_url"))
00123         
00124         info = []
00125         for element in utils.allAvailableActions(rule.event):
00126             info.append({'title'       : element.title,
00127                          'description' : element.description,
00128                          'addview'     :  element.addview,
00129                         })
00130         return info
                

Here is the call graph for this function:

Definition at line 105 of file elements.py.

00105 
00106     def addable_conditions(self):
00107         rule = aq_inner(self.context)
00108         context = aq_parent(rule)
00109         baseUrl = str(getMultiAdapter((context, self.request), name=u"absolute_url"))
00110         
00111         info = []
00112         for element in utils.allAvailableConditions(rule.event):
00113             info.append({'title'       : element.title,
00114                          'description' : element.description,
00115                          'addview'    :  element.addview,
00116                         })
00117         return info
    

Here is the call graph for this function:

Definition at line 131 of file elements.py.

00131 
00132     def assignments(self):
00133         rule = aq_inner(self.context)
00134         paths = set(get_assignments(rule))
00135         
00136         site = getToolByName(rule, "portal_url").getPortalObject()
00137         site_path = '/'.join(site.getPhysicalPath())
00138         
00139         plone_view = getMultiAdapter((rule, self.request), name="plone")
00140         
00141         info = []
00142         if site_path in paths:
00143             paths.remove(site_path)
00144             info.append({'url'         : site.absolute_url(),
00145                          'title'       : site.Title(),
00146                          'description' : site.Description(),
00147                          'icon'        : plone_view.getIcon(site),
00148                         })
00149             
00150         catalog = getToolByName(rule, "portal_catalog")
00151         for a in catalog(path=dict(query=list(paths), depth=0), sort_on='sortable_title'):
00152             info.append({'url'         : a.getURL(),
00153                          'title'       : a.Title,
00154                          'description' : a.Description,
00155                          'icon'        : plone_view.getIcon(a),
00156                         })
00157         return info
00158         
        

Here is the call graph for this function:

Definition at line 70 of file elements.py.

00070 
00071     def base_url(self):
00072         rule = aq_inner(self.context)
00073         return rule.absolute_url()
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 99 of file elements.py.

00099 
00100     def conditions(self):
00101         conditions = {}
00102         for name, utility in getUtilitiesFor(IRuleCondition):
00103             conditions[name] = utility
00104         return self._populate_info(self.context.conditions, conditions, 'condition')
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 81 of file elements.py.

00081 
00082     def rule_description(self):
00083         return self.context.description
        

Definition at line 84 of file elements.py.

00084 
00085     def rule_event(self):
00086         eventsFactory = getUtility(IVocabularyFactory, name="plone.contentrules.events")
00087         for e in eventsFactory(self.context):
00088             if e.value == self.context.event:
00089                 return e.token
00090         return "Unknown event" # should not happen
    

Here is the call graph for this function:

Definition at line 78 of file elements.py.

00078 
00079     def rule_title(self):
00080         return self.context.title
        

Definition at line 75 of file elements.py.

00075 
00076     def view_url(self):
00077         return self.base_url() + '/@@manage-elements'
    

Here is the call graph for this function:


Member Data Documentation

tuple plone.app.contentrules.browser.elements.ManageElements.template = ViewPageTemplateFile('templates/manage-elements.pt') [static]

Definition at line 24 of file elements.py.


The documentation for this class was generated from the following file: