Back to index

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

List of all members.

Public Member Functions

def __call__
def globally_enabled
def view_url
def type_name
def acquired_rules
def assigned_rules
def has_rules
def assignable_rules

Static Public Attributes

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

Private Member Functions

def _events
def _rule_url
def _portal_url

Detailed Description

Manage contextual rule assignments

Definition at line 20 of file assignments.py.


Member Function Documentation

Definition at line 26 of file assignments.py.

00026 
00027     def __call__(self):
00028         context = aq_inner(self.context)
00029         request = aq_inner(self.request)
00030         form = request.form
00031         path = '/'.join(context.getPhysicalPath())
00032         status = IStatusMessage(self.request)
00033         assignable = IRuleAssignmentManager(context)
00034         storage = getUtility(IRuleStorage)
00035         
00036         operation = request.get('operation', None)
00037         
00038         if operation == 'move_up':
00039             rule_id = request.get('rule_id')            
00040             keys = list(assignable.keys())
00041             idx = keys.index(rule_id)
00042             del keys[idx]
00043             keys.insert(idx-1, rule_id)
00044             assignable.updateOrder(keys)
00045         elif operation == 'move_down':
00046             rule_id = request.get('rule_id')            
00047             keys = list(assignable.keys())
00048             idx = keys.index(rule_id)
00049             del keys[idx]
00050             keys.insert(idx+1, rule_id)
00051             assignable.updateOrder(keys)            
00052         elif 'form.button.AddAssignment' in form:
00053             rule_id = form.get('rule_id')
00054             assignable[rule_id] = RuleAssignment(rule_id)
00055             get_assignments(storage[rule_id]).insert(path)
00056         elif 'form.button.Delete' in form:
00057             rule_ids = form.get('rule_ids', ())
00058             for r in rule_ids:
00059                 del assignable[r]
00060                 get_assignments(storage[r]).remove(path)
00061             status.addStatusMessage(_(u"Assignments deleted."), type='info')
00062         elif 'form.button.Enable' in form:
00063             rule_ids = form.get('rule_ids', ())
00064             for r in rule_ids:
00065                 assignment = assignable.get(r, None)
00066                 if assignment is not None:
00067                     assignment.enabled = True
00068             status.addStatusMessage(_(u"Assignments enabled."), type='info')
00069         elif 'form.button.Disable' in form:
00070             rule_ids = form.get('rule_ids', ())
00071             for r in rule_ids:
00072                 assignment = assignable.get(r, None)
00073                 if assignment is not None:
00074                     assignment.enabled = False
00075             status.addStatusMessage(_(u"Assignments disabled."), type='info')
00076         elif 'form.button.Bubble' in form:
00077             rule_ids = form.get('rule_ids', ())
00078             for r in rule_ids:
00079                 assignment = assignable.get(r, None)
00080                 if assignment is not None:
00081                     assignment.bubbles = True
00082             status.addStatusMessage(_(u"Changes saved."), type='info')
00083         elif 'form.button.NoBubble' in form:
00084             rule_ids = form.get('rule_ids', ())
00085             for r in rule_ids:
00086                 assignment = assignable.get(r, None)
00087                 if assignment is not None:
00088                     assignment.bubbles = False
00089             status.addStatusMessage(_(u"Changes saved."), type='info')
00090                                 
00091         return self.template()
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 175 of file assignments.py.

00175 
00176     def _events(self):
00177         eventsFactory = getUtility(IVocabularyFactory, name="plone.contentrules.events")
00178         return dict([(e.value, e.token) for e in eventsFactory(self.context)])
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 183 of file assignments.py.

00183 
00184     def _portal_url(self):
00185         portal_state = getMultiAdapter((self.context, self.request), name="plone_portal_state")
00186         return portal_state.portal_url()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 179 of file assignments.py.

00179 
00180     def _rule_url(self, key):
00181         return "%s/++rule++%s/@@manage-elements" % (self._portal_url(), key,)
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 107 of file assignments.py.

00107 
00108     def acquired_rules(self):
00109         
00110         # Short circuit if this is the root of the portal
00111         if ISiteRoot.providedBy(self.context):
00112             return []
00113         
00114         in_use = set([r['id'] for r in self.assigned_rules()])
00115         
00116         storage = getUtility(IRuleStorage)
00117         events = self._events()
00118         
00119         assignments = []
00120         context = aq_parent(aq_inner(self.context))
00121         
00122         while context is not None:
00123             assignable = IRuleAssignmentManager(context, None)
00124             if assignable is not None:
00125                 for key, assignment in assignable.items():
00126                     if key not in in_use and assignment.bubbles:
00127                         rule = storage.get(key, None)
00128                         if rule is not None:
00129                             assignments.append(dict(id = key,
00130                                                     title = rule.title,
00131                                                     description = rule.description,
00132                                                     trigger = events.get(rule.event, "Unknown"),
00133                                                     url = context.absolute_url() + '/@@manage-content-rules',
00134                                                     enabled = (assignment.enabled and rule.enabled),))
00135             if ISiteRoot.providedBy(context):
00136                 context = None
00137             else:
00138                 context = aq_parent(context)
00139         
00140         return assignments
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file assignments.py.

00164 
00165     def assignable_rules(self):
00166         in_use = set([r['id'] for r in self.assigned_rules()])
00167         assignable = []
00168         for key, rule in getUtility(IRuleStorage).items():
00169             if key not in in_use:
00170                 assignable.append(dict( id = key,
00171                                         title = rule.title,
00172                                         description = rule.description,))
00173         return assignable
        

Here is the call graph for this function:

Definition at line 142 of file assignments.py.

00142 
00143     def assigned_rules(self):
00144         assignable = IRuleAssignmentManager(self.context)
00145         storage = getUtility(IRuleStorage)
00146         events = self._events()
00147         
00148         assignments = []
00149         for key, assignment in assignable.items():
00150             rule = storage.get(key, None)
00151             if rule is not None:
00152                 assignments.append(dict(id = key,
00153                                         title = rule.title,
00154                                         description = rule.description,
00155                                         trigger = events.get(rule.event, "Unknown"),
00156                                         url = self._rule_url(key),
00157                                         bubbles = assignment.bubbles,
00158                                         enabled = assignment.enabled,
00159                                         global_enabled = rule.enabled,))
00160         return assignments
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 92 of file assignments.py.

00092 
00093     def globally_enabled(self):
00094         storage = getUtility(IRuleStorage)
00095         return storage.active
        

Definition at line 161 of file assignments.py.

00161 
00162     def has_rules(self):
00163         return len(self.assigned_rules()) > 0 or len(self.acquired_rules()) > 0
        

Here is the call graph for this function:

Definition at line 101 of file assignments.py.

00101 
00102     def type_name(self):
00103         context = aq_inner(self.context)
00104         fti = context.getTypeInfo()
00105         return fti.getProperty('title', None) or fti.getId()

Here is the call graph for this function:

Definition at line 97 of file assignments.py.

00097 
00098     def view_url(self):
00099         return self.context.absolute_url() + '/@@manage-content-rules'
        

Member Data Documentation

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

Definition at line 24 of file assignments.py.


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