Changeset f9798f in indico
- Timestamp:
- 04/27/12 15:39:28 (13 months ago)
- Branches:
- master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
- Children:
- c06c72
- Parents:
- d71fd2
- git-author:
- Matthew Pugh <matthew.alexander.pugh@…> (04/27/12 14:48:06)
- git-committer:
- Jose Benito <jose.benito.gonzalez@…> (04/27/12 15:39:28)
- Location:
- indico/ext/statistics
- Files:
-
- 2 edited
-
chrome.py (modified) (3 diffs)
-
register.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/ext/statistics/chrome.py
rbe54ff6 rf9798f 46 46 def fillManagementSideMenu(cls, obj, params={}): 47 47 if obj._conf.canModify(obj._rh._aw): 48 params['Statistics'] = wcomponents.SideMenuItem(_('Statistics'), 49 UHConfModifStatistics.getURL(obj._conf)) 48 49 if StatisticsRegister().hasActivePlugins(): 50 params['Statistics'] = wcomponents.SideMenuItem(_('Statistics'), 51 UHConfModifStatistics.getURL(obj._conf)) 50 52 51 53 … … 60 62 """ 61 63 stats = PluginsHolder().getPluginType('statistics') 62 63 if not stats.isActive(): 64 register = StatisticsRegister() 65 66 if not stats.isActive() or not register.hasActivePlugins(): 64 67 return False 65 68 66 register = StatisticsRegister()67 69 key = 'extraFooterContent' 68 70 extension = {} … … 174 176 self._conf = self._rh._conf 175 177 self._register = StatisticsRegister() 176 self._plugins = self._register.getAllPlugins( )178 self._plugins = self._register.getAllPlugins(activeOnly=True) 177 179 self._templateClass = templateClass 178 180 self._extraJS = [] -
indico/ext/statistics/register.py
rd22bcc rf9798f 63 63 self._buildRegister() 64 64 65 def getAllPlugins(self, instantiate=True): 65 66 def hasActivePlugins(self): 67 """ 68 Returns True only if any implementations are active in the PluginsHolder 69 """ 70 71 activePlugins = list(p for p in self.getAllPlugins(True) if p.isActive()) 72 73 # The resultant activePlugins is only True if there are any plugins. 74 return bool(activePlugins) 75 76 def getAllPlugins(self, instantiate=True, activeOnly=False): 66 77 """ 67 78 Returns a list of all plugin class registered, if instantiate is 68 True, instates all objects before appending to the list. 79 True, instates all objects before appending to the list. By default 80 this method only returns active implementations, however all implementations 81 may be returned by setting activeOnly to True. 69 82 """ 70 83 result = [] … … 72 85 if instantiate: 73 86 for plugin in self._getRegister().values(): 87 88 if activeOnly and not plugin().isActive(): 89 continue 90 74 91 result.append(plugin()) 75 92 else: 76 result = self._getRegister().values() 93 if activeOnly: 94 result = list(p for p in self._getRegister().values() if p().isActive()) 95 else: 96 result = self._getRegister().values() 77 97 78 98 return result … … 84 104 return self._getRegister().keys() 85 105 86 def getAllPluginJSHooks(self, extra=None ):106 def getAllPluginJSHooks(self, extra=None, includeInactive=False): 87 107 """ 88 108 Returns a list of JSHook objects which contain the parameters … … 94 114 95 115 for plugin in self.getAllPlugins(True): 116 117 if not includeInactive and not plugin.isActive(): 118 continue 96 119 97 120 if extra is not None:
Note: See TracChangeset
for help on using the changeset viewer.
