From 5fc728d2b1d9ddff6db40c80cfda7274a93a3cc9 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Wed, 27 May 2020 13:51:06 +0200 Subject: [PATCH] Rename get_one(...) -> get_or_404(...) --- livesync/indico_livesync/controllers.py | 4 ++-- livesync/indico_livesync/util.py | 10 +++++----- piwik/indico_piwik/reports.py | 4 ++-- piwik/setup.py | 4 ++-- search/indico_search/controllers.py | 4 ++-- search/setup.py | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/livesync/indico_livesync/controllers.py b/livesync/indico_livesync/controllers.py index dce5ba1..db8663e 100644 --- a/livesync/indico_livesync/controllers.py +++ b/livesync/indico_livesync/controllers.py @@ -30,7 +30,7 @@ class RHDeleteAgent(RHAdminBase): """Deletes a LiveSync agent""" def _process_args(self): - self.agent = LiveSyncAgent.get_one(request.view_args['agent_id']) + self.agent = LiveSyncAgent.get_or_404(request.view_args['agent_id']) def _process(self): db.session.delete(self.agent) @@ -66,7 +66,7 @@ class RHEditAgent(RHAdminBase): """Edits a LiveSync agent""" def _process_args(self): - self.agent = LiveSyncAgent.get_one(request.view_args['agent_id']) + self.agent = LiveSyncAgent.get_or_404(request.view_args['agent_id']) if self.agent.backend is None: flash(_('Cannot edit an agent that is not loaded'), 'error') return redirect(url_for('plugins.details', plugin='livesync')) diff --git a/livesync/indico_livesync/util.py b/livesync/indico_livesync/util.py index a36034d..09b090c 100644 --- a/livesync/indico_livesync/util.py +++ b/livesync/indico_livesync/util.py @@ -43,15 +43,15 @@ def obj_deref(ref): """Returns the object identified by `ref`""" from indico_livesync.models.queue import EntryType if ref['type'] == EntryType.category: - return Category.get_one(ref['category_id']) + return Category.get_or_404(ref['category_id']) elif ref['type'] == EntryType.event: - return Event.get_one(ref['event_id']) + return Event.get_or_404(ref['event_id']) elif ref['type'] == EntryType.session: - return Session.get_one(ref['session_id']) + return Session.get_or_404(ref['session_id']) elif ref['type'] == EntryType.contribution: - return Contribution.get_one(ref['contrib_id']) + return Contribution.get_or_404(ref['contrib_id']) elif ref['type'] == EntryType.subcontribution: - return SubContribution.get_one(ref['subcontrib_id']) + return SubContribution.get_or_404(ref['subcontrib_id']) else: raise ValueError('Unexpected object type: {}'.format(ref['type'])) diff --git a/piwik/indico_piwik/reports.py b/piwik/indico_piwik/reports.py index b469dcb..bbc8343 100644 --- a/piwik/indico_piwik/reports.py +++ b/piwik/indico_piwik/reports.py @@ -44,7 +44,7 @@ class ReportBase(Serializer): @property def event(self): - return Event.get_one(self.event_id, is_deleted=False) + return Event.get_or_404(self.event_id, is_deleted=False) @classmethod def get(cls, *args, **kwargs): @@ -139,7 +139,7 @@ class ReportMaterial(ReportBase): __public__ = ['material'] def _build_report(self): - event = Event.get_one(self.params['event_id'], is_deleted=False) + event = Event.get_or_404(self.params['event_id'], is_deleted=False) new_material = get_nested_attached_items(event) self.material = {'tree': [self._format_data(new_material)]} diff --git a/piwik/setup.py b/piwik/setup.py index 3905f3c..087de52 100644 --- a/piwik/setup.py +++ b/piwik/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup setup( name='indico-plugin-piwik', - version='2.2', + version='2.3-dev', description='Piwik integration for global and event-specific statistics in Indico', url='https://github.com/indico/indico-plugins', license='MIT', @@ -22,7 +22,7 @@ setup( zip_safe=False, include_package_data=True, install_requires=[ - 'indico>=2.2.dev0' + 'indico>=2.3.dev0' ], classifiers=[ 'Environment :: Plugins', diff --git a/search/indico_search/controllers.py b/search/indico_search/controllers.py index 00dfbd9..e0d945f 100644 --- a/search/indico_search/controllers.py +++ b/search/indico_search/controllers.py @@ -24,10 +24,10 @@ class RHSearch(RH): def _process_args(self): if 'confId' in request.view_args: - self.obj = Event.get_one(request.view_args['confId'], is_deleted=False) + self.obj = Event.get_or_404(request.view_args['confId'], is_deleted=False) self.obj_type = 'event' elif 'category_id' in request.view_args: - self.obj = Category.get_one(request.view_args['category_id'], is_deleted=False) + self.obj = Category.get_or_404(request.view_args['category_id'], is_deleted=False) self.obj_type = 'category' if not self.obj.is_root else None else: self.obj = Category.get_root() diff --git a/search/setup.py b/search/setup.py index ba6bd65..721c912 100644 --- a/search/setup.py +++ b/search/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup setup( name='indico-plugin-search', - version='2.2', + version='2.3-dev', description='Framework for searching content in Indico', url='https://github.com/indico/indico-plugins', license='MIT', @@ -22,7 +22,7 @@ setup( zip_safe=False, include_package_data=True, install_requires=[ - 'indico>=2.2.dev0' + 'indico>=2.3.dev0' ], classifiers=[ 'Environment :: Plugins',