diff --git a/openlp/core/api/versions/v2/__init__.py b/openlp/core/api/versions/v2/__init__.py
index 16b1fca57..e8e8d8d9f 100644
--- a/openlp/core/api/versions/v2/__init__.py
+++ b/openlp/core/api/versions/v2/__init__.py
@@ -22,7 +22,7 @@
from openlp.core.api.versions.v2.controller import controller_views
from openlp.core.api.versions.v2.core import core
from openlp.core.api.versions.v2.service import service_views
-from openlp.core.api.versions.v2.plugins import plugins
+from openlp.core.api.versions.v2.plugins import plugins, alert_1_views, alert_2_views
def register_blueprints(app):
@@ -30,3 +30,5 @@ def register_blueprints(app):
app.register_blueprint(core, url_prefix='/api/v2/core/')
app.register_blueprint(service_views, url_prefix='/api/v2/service/')
app.register_blueprint(plugins, url_prefix='/api/v2/plugins/')
+ app.register_blueprint(alert_2_views, url_prefix='/api/v2/plugins/alerts')
+ app.register_blueprint(alert_1_views, url_prefix='/api/alert')
diff --git a/openlp/core/api/versions/v2/plugins.py b/openlp/core/api/versions/v2/plugins.py
index f1d050c0e..05a09f720 100644
--- a/openlp/core/api/versions/v2/plugins.py
+++ b/openlp/core/api/versions/v2/plugins.py
@@ -24,7 +24,7 @@ import logging
import re
from flask import abort, request, Blueprint, jsonify
-from openlp.core.api.lib import login_required
+from openlp.core.api.lib import login_required, extract_request, old_success_response, old_auth
from openlp.core.lib.plugin import PluginStatus
from openlp.core.common.registry import Registry
from openlp.plugins.songs.lib import transpose_lyrics
@@ -33,6 +33,8 @@ log = logging.getLogger(__name__)
plugins = Blueprint('v2-plugins', __name__)
+alert_1_views = Blueprint('v1-alert-plugin', __name__)
+alert_2_views = Blueprint('v2-alert-plugin', __name__)
def search(plugin_name, text):
@@ -172,3 +174,27 @@ def transpose(transpose_value):
chord_slides.append({'chords': verse_list[i + 1].strip(), 'verse': verse_list[i]})
return jsonify(chord_slides), 200
abort(400)
+
+
+@alert_2_views.route('', methods=['POST'])
+@login_required
+def alert():
+ data = request.json
+ if not data:
+ abort(400)
+ alert = data.get('text', '')
+ if alert:
+ if Registry().get('plugin_manager').get_plugin_by_name('alerts').status == PluginStatus.Active:
+ Registry().get('alerts_manager').alerts_text.emit([alert])
+ return '', 204
+ abort(400)
+
+
+@alert_1_views.route('')
+@old_auth
+def old_alert():
+ alert = extract_request(request.args.get('data', ''), 'text')
+ if alert:
+ if Registry().get('plugin_manager').get_plugin_by_name('alerts').status == PluginStatus.Active:
+ Registry().get('alerts_manager').alerts_text.emit([alert])
+ return old_success_response()
diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py
index 8993a7655..90eca8b65 100644
--- a/openlp/plugins/alerts/alertsplugin.py
+++ b/openlp/plugins/alerts/alertsplugin.py
@@ -29,7 +29,6 @@ from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.lib.theme import VerticalType
from openlp.core.lib.ui import create_action
from openlp.core.ui.icons import UiIcons
-from openlp.plugins.alerts.remote import register_views
from openlp.plugins.alerts.forms.alertform import AlertForm
from openlp.plugins.alerts.lib.alertsmanager import AlertsManager
from openlp.plugins.alerts.lib.alertstab import AlertsTab
@@ -139,7 +138,6 @@ class AlertsPlugin(Plugin):
self.tools_alert_item.setVisible(True)
action_list = ActionList.get_instance()
action_list.add_action(self.tools_alert_item, UiStrings().Tools)
- register_views()
def finalise(self):
"""
diff --git a/openlp/plugins/alerts/remote.py b/openlp/plugins/alerts/remote.py
deleted file mode 100644
index 6e6c6dea7..000000000
--- a/openlp/plugins/alerts/remote.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- coding: utf-8 -*-
-
-##########################################################################
-# OpenLP - Open Source Lyrics Projection #
-# ---------------------------------------------------------------------- #
-# Copyright (c) 2008-2023 OpenLP Developers #
-# ---------------------------------------------------------------------- #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see . #
-##########################################################################
-from flask import Blueprint, request, abort
-
-from openlp.core.api import app
-from openlp.core.api.lib import login_required, extract_request, old_success_response, old_auth
-from openlp.core.common.registry import Registry
-from openlp.core.lib.plugin import PluginStatus
-
-
-v1_views = Blueprint('v1-alert-plugin', __name__)
-v2_views = Blueprint('v2-alert-plugin', __name__)
-
-
-@v2_views.route('', methods=['POST'])
-@login_required
-def alert():
- data = request.json
- if not data:
- abort(400)
- alert = data.get('text', '')
- if alert:
- if Registry().get('plugin_manager').get_plugin_by_name('alerts').status == PluginStatus.Active:
- Registry().get('alerts_manager').alerts_text.emit([alert])
- return '', 204
- abort(400)
-
-
-@v1_views.route('')
-@old_auth
-def old_alert():
- alert = extract_request(request.args.get('data', ''), 'text')
- if alert:
- if Registry().get('plugin_manager').get_plugin_by_name('alerts').status == PluginStatus.Active:
- Registry().get('alerts_manager').alerts_text.emit([alert])
- return old_success_response()
-
-
-def register_views():
- app.register_blueprint(v2_views, url_prefix='/api/v2/plugins/alerts')
- app.register_blueprint(v1_views, url_prefix='/api/alert')
diff --git a/openlp/plugins/media/remote.py b/openlp/plugins/media/remote.py
deleted file mode 100644
index 0f1974308..000000000
--- a/openlp/plugins/media/remote.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-##########################################################################
-# OpenLP - Open Source Lyrics Projection #
-# ---------------------------------------------------------------------- #
-# Copyright (c) 2008-2023 OpenLP Developers #
-# ---------------------------------------------------------------------- #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see . #
-##########################################################################
-import logging
-
-from flask import abort, request, Blueprint, jsonify
-
-from openlp.core.api import app
-from openlp.core.api.lib import login_required, extract_request, old_auth
-from openlp.core.lib.plugin import PluginStatus
-from openlp.core.common.registry import Registry
-
-log = logging.getLogger(__name__)
-
-
-v1_media = Blueprint('v1-media-plugin', __name__)
-v2_media = Blueprint('v2-media-plugin', __name__)
-
-
-def search(text):
- plugin = Registry().get('plugin_manager').get_plugin_by_name('media')
- if plugin.status == PluginStatus.Active and plugin.media_item and plugin.media_item.has_search:
- results = plugin.media_item.search(text, False)
- return results
- return None
-
-
-def live(id):
- plugin = Registry().get('plugin_manager').get_plugin_by_name('media')
- if plugin.status == PluginStatus.Active and plugin.media_item:
- plugin.media_item.media_go_live.emit([id, True])
-
-
-def add(id):
- plugin = Registry().get('plugin_manager').get_plugin_by_name('media')
- if plugin.status == PluginStatus.Active and plugin.media_item:
- item_id = plugin.media_item.create_item_from_id(id)
- plugin.media_item.media_add_to_service.emit([item_id, True])
-
-
-@v2_media.route('/search')
-@login_required
-def search_view():
- text = request.args.get('text', '')
- result = search(text)
- return jsonify(result)
-
-
-@v2_media.route('/add', methods=['POST'])
-@login_required
-def add_view():
- data = request.json
- if not data:
- abort(400)
- id = data.get('id', -1)
- add(id)
- return '', 204
-
-
-@v2_media.route('/live', methods=['POST'])
-@login_required
-def live_view():
- data = request.json
- if not data:
- abort(400)
- id = data.get('id', -1)
- live(id)
- return '', 204
-
-
-# ----------------- DEPRECATED --------------
-@v1_media.route('/search')
-@old_auth
-def old_search():
- text = extract_request(request.args.get('data', ''), 'text')
- return jsonify({'results': {'items': search(text)}})
-
-
-@v1_media.route('/add')
-@old_auth
-def old_add():
- id = extract_request(request.args.get('data', ''), 'id')
- add(id)
- return '', 204
-
-
-@v1_media.route('/live')
-@old_auth
-def old_live():
- id = extract_request(request.args.get('data', ''), 'id')
- live(id)
- return '', 204
-# ---------------- END DEPRECATED ----------------
-
-
-def register_views():
- app.register_blueprint(v2_media, url_prefix='/api/v2/plugins/media/')
- app.register_blueprint(v1_media, url_prefix='/api/media/')
diff --git a/tests/openlp_plugins/alerts/test_plugin.py b/tests/openlp_plugins/alerts/test_plugin.py
index ca248e775..dfc411857 100644
--- a/tests/openlp_plugins/alerts/test_plugin.py
+++ b/tests/openlp_plugins/alerts/test_plugin.py
@@ -32,8 +32,7 @@ from openlp.plugins.alerts.alertsplugin import AlertsPlugin
def plugin_env(mocked_manager, settings, state, registry):
"""An instance of the AlertsPlugin"""
mocked_manager.return_value = MagicMock()
- with patch('openlp.plugins.alerts.alertsplugin.register_views'):
- return AlertsPlugin(), settings
+ return AlertsPlugin(), settings
def test_plugin_about():
@@ -77,12 +76,10 @@ def test_alerts_initialise(plugin_env):
plugin = plugin_env[0]
plugin.tools_alert_item = MagicMock()
# WHEN: I request the form
- with patch('openlp.core.common.actions.ActionList') as mocked_actionlist, \
- patch('openlp.plugins.alerts.alertsplugin.register_views') as mocked_register_views:
+ with patch('openlp.core.common.actions.ActionList') as mocked_actionlist:
plugin.initialise()
# THEN: the form is loaded
mocked_actionlist.instance.add_action.assert_called_once()
- mocked_register_views.assert_called_once_with()
plugin.tools_alert_item.setVisible.assert_called_once_with(True)