mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
Piwik: Hide event integration if site_id missing
This commit is contained in:
parent
4229a24c15
commit
dc577364cf
@ -15,6 +15,7 @@
|
||||
# along with Indico; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from flask import jsonify, request
|
||||
from werkzeug.exceptions import NotFound
|
||||
|
||||
from indico.modules.events.management.controllers import RHManageEventBase
|
||||
|
||||
@ -23,7 +24,15 @@ from indico_piwik.reports import (ReportCountries, ReportDevices, ReportDownload
|
||||
from indico_piwik.views import WPStatistics
|
||||
|
||||
|
||||
class RHStatistics(RHManageEventBase):
|
||||
class RHPiwikBase(RHManageEventBase):
|
||||
def _process_args(self):
|
||||
from indico_piwik.plugin import PiwikPlugin
|
||||
RHManageEventBase._process_args(self)
|
||||
if not PiwikPlugin.settings.get('site_id_events'):
|
||||
raise NotFound
|
||||
|
||||
|
||||
class RHStatistics(RHPiwikBase):
|
||||
def _process(self):
|
||||
report = ReportGeneral.get(event_id=self.event.id,
|
||||
contrib_id=request.args.get('contrib_id'),
|
||||
@ -32,11 +41,11 @@ class RHStatistics(RHManageEventBase):
|
||||
return WPStatistics.render_template('statistics.html', self.event, report=report)
|
||||
|
||||
|
||||
class RHApiBase(RHManageEventBase):
|
||||
class RHApiBase(RHPiwikBase):
|
||||
ALLOW_LOCKED = True
|
||||
|
||||
def _process_args(self):
|
||||
RHManageEventBase._process_args(self)
|
||||
RHPiwikBase._process_args(self)
|
||||
self._report_params = {'start_date': request.args.get('start_date'),
|
||||
'end_date': request.args.get('end_date')}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ class PiwikPlugin(IndicoPlugin):
|
||||
**event_tracking_params)
|
||||
|
||||
def add_sidemenu_item(self, sender, event, **kwargs):
|
||||
if not event.can_manage(session.user):
|
||||
if not event.can_manage(session.user) or not PiwikPlugin.settings.get('site_id_events'):
|
||||
return
|
||||
return SideMenuItem(u'statistics', _(u"Statistics"), url_for_plugin(u'piwik.view', event), section=u'reports')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user