Merge branch 'api_changes' into 'master'

Api changes and fixes

See merge request openlp/openlp!190
This commit is contained in:
Raoul Snyman 2020-05-16 06:11:21 +00:00
commit e8db9dd524
17 changed files with 69 additions and 471 deletions

View File

@ -22,9 +22,11 @@
from openlp.core.api.versions.v1.controller import controller_views
from openlp.core.api.versions.v1.core import core_views
from openlp.core.api.versions.v1.service import service_views
from openlp.core.api.versions.v1.plugins import plugins
def register_blueprints(app):
app.register_blueprint(controller_views)
app.register_blueprint(core_views)
app.register_blueprint(service_views)
app.register_blueprint(plugins)

View File

@ -20,91 +20,58 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
from flask import request, jsonify, Blueprint
from openlp.core.api import app
from openlp.core.api.lib import login_required, extract_request, old_auth
from flask import request, Blueprint, jsonify
from openlp.core.api.lib import extract_request, old_auth
from openlp.core.lib.plugin import PluginStatus
from openlp.core.common.registry import Registry
log = logging.getLogger(__name__)
v1_views = Blueprint('v1-bibles-plugin', __name__)
v2_views = Blueprint('v2-bibles-plugin', __name__)
plugins = Blueprint('v1-plugins', __name__)
def search(text):
plugin = Registry().get('plugin_manager').get_plugin_by_name('bibles')
def search(plugin_name, text):
plugin = Registry().get('plugin_manager').get_plugin_by_name(plugin_name)
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('bibles')
def live(plugin_name, id):
plugin = Registry().get('plugin_manager').get_plugin_by_name(plugin_name)
if plugin.status == PluginStatus.Active and plugin.media_item:
plugin.media_item.bibles_go_live.emit([id, True])
getattr(plugin.media_item, '{action}_go_live'.format(action=plugin_name)).emit([id, True])
def add(id):
plugin = Registry().get('plugin_manager').get_plugin_by_name('bibles')
def add(plugin_name, id):
plugin = Registry().get('plugin_manager').get_plugin_by_name(plugin_name)
if plugin.status == PluginStatus.Active and plugin.media_item:
item_id = plugin.media_item.create_item_from_id(id)
plugin.media_item.bibles_add_to_service.emit([item_id, True])
getattr(plugin.media_item, '{action}_add_to_service'.format(action=plugin_name)).emit([item_id, True])
@v2_views.route('/search')
@login_required
def search_bible():
text = request.args.get('text', '')
result = search(text)
return jsonify(result)
@v2_views.route('/live', methods=['POST'])
@login_required
def send_live():
id = request.json.get('id', -1)
live(id)
return '', 204
@v2_views.route('/add', methods=['POST'])
@login_required
def add_to_service():
id = request.json.get('id', -1)
add(id)
return '', 204
# ---------------- DEPRECATED REMOVE AFTER RELEASE --------------
@v1_views.route('/search')
@plugins.route('/api/<plugin>/search')
@old_auth
def old_search_bible():
def old_search(plugin):
text = extract_request(request.args.get('data', ''), 'text')
return jsonify({'results': {'items': search(text)}})
return jsonify({'results': {'items': search(plugin, text)}})
@v1_views.route('/live')
@plugins.route('/api/<plugin>/add')
@old_auth
def old_send_live():
def old_add(plugin):
id = extract_request(request.args.get('data', ''), 'id')
live(id)
add(plugin, id)
return '', 204
@v1_views.route('/add')
@plugins.route('/api/<plugin>/live')
@old_auth
def old_add_to_service():
def old_live(plugin):
id = extract_request(request.args.get('data', ''), 'id')
add(id)
live(plugin, id)
return '', 204
# ------------ END DEPRECATED ----------------------------------
def register_views():
app.register_blueprint(v2_views, url_prefix='/api/v2/plugins/bibles')
app.register_blueprint(v1_views, url_prefix='/api/bibles')

View File

@ -22,9 +22,11 @@
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
def register_blueprints(app):
app.register_blueprint(controller_views, url_prefix='/api/v2/controller/')
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/')

View File

@ -23,94 +23,65 @@ 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.api.lib import login_required
from openlp.core.lib.plugin import PluginStatus
from openlp.core.common.registry import Registry
log = logging.getLogger(__name__)
v1_songs = Blueprint('v1-songs-plugin', __name__)
v2_songs = Blueprint('v2-songs-plugin', __name__)
plugins = Blueprint('v2-plugins', __name__)
def search(text):
plugin = Registry().get('plugin_manager').get_plugin_by_name('songs')
def search(plugin_name, text):
plugin = Registry().get('plugin_manager').get_plugin_by_name(plugin_name)
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('songs')
def live(plugin_name, id):
plugin = Registry().get('plugin_manager').get_plugin_by_name(plugin_name)
if plugin.status == PluginStatus.Active and plugin.media_item:
plugin.media_item.songs_go_live.emit([id, True])
getattr(plugin.media_item, '{action}_go_live'.format(action=plugin_name)).emit([id, True])
def add(id):
plugin = Registry().get('plugin_manager').get_plugin_by_name('songs')
def add(plugin_name, id):
plugin = Registry().get('plugin_manager').get_plugin_by_name(plugin_name)
if plugin.status == PluginStatus.Active and plugin.media_item:
item_id = plugin.media_item.create_item_from_id(id)
plugin.media_item.songs_add_to_service.emit([item_id, True])
getattr(plugin.media_item, '{action}_add_to_service'.format(action=plugin_name)).emit([item_id, True])
@v2_songs.route('/search')
@plugins.route('/<plugin>/search')
@login_required
def search_view():
def search_view(plugin):
log.debug(f'{plugin}/search search called')
text = request.args.get('text', '')
result = search(text)
result = search(plugin, text)
return jsonify(result)
@v2_songs.route('/add', methods=['POST'])
@plugins.route('/<plugin>/add', methods=['POST'])
@login_required
def add_view():
def add_view(plugin):
log.debug(f'{plugin}/add search called')
data = request.json
if not data:
abort(400)
id = data.get('id', -1)
add(id)
add(plugin, id)
return '', 204
@v2_songs.route('/live', methods=['POST'])
@plugins.route('/<plugin>/live', methods=['POST'])
@login_required
def live_view():
def live_view(plugin):
log.debug(f'{plugin}/live search called')
data = request.json
if not data:
abort(400)
id = data.get('id', -1)
live(id)
live(plugin, id)
return '', 204
# ----------------- DEPRECATED --------------
@v1_songs.route('/search')
@old_auth
def old_search():
text = extract_request(request.args.get('data', ''), 'text')
return jsonify({'results': {'items': search(text)}})
@v1_songs.route('/add')
@old_auth
def old_add():
id = extract_request(request.args.get('data', ''), 'id')
add(id)
return '', 204
@v1_songs.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_songs, url_prefix='/api/v2/plugins/songs/')
app.register_blueprint(v1_songs, url_prefix='/api/songs/')

View File

@ -50,7 +50,8 @@ def service_items():
'plugin': str(service_item.name),
'ccli_number': str(ccli_number),
'notes': str(service_item.notes),
'selected': (service_item.unique_identifier == current_unique_identifier)
'selected': (service_item.unique_identifier == current_unique_identifier),
'is_valid': str(service_item.is_valid)
})
return jsonify(service_items)
@ -101,3 +102,10 @@ def service_direction():
abort(400)
getattr(Registry().get('service_manager'), 'servicemanager_{action}_item'.format(action=action)).emit()
return '', 204
@service_views.route('/new', methods=['GET'])
@login_required
def new_service():
getattr(Registry().get('service_manager'), 'servicemanager_new_file').emit()
return '', 204

View File

@ -630,14 +630,18 @@ class ServiceItem(RegistryProperties):
else:
return self.slides
def get_rendered_frame(self, row):
def get_rendered_frame(self, row, clean=False):
"""
Returns the correct frame for a given list and renders it if required.
:param row: The service item slide to be returned
:param clean: do I want HTML tags or not
"""
if self.service_item_type == ServiceItemType.Text:
return self.rendered_slides[row]['text']
if clean:
return self.display_slides[row]['text']
else:
return self.rendered_slides[row]['text']
elif self.service_item_type == ServiceItemType.Image:
return self.slides[row]['path']
else:

View File

@ -316,6 +316,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
servicemanager_set_item_by_uuid = QtCore.pyqtSignal(str)
servicemanager_next_item = QtCore.pyqtSignal()
servicemanager_previous_item = QtCore.pyqtSignal()
servicemanager_new_file = QtCore.pyqtSignal()
def __init__(self, parent=None):
"""
@ -344,6 +345,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
self.servicemanager_set_item_by_uuid.connect(self.set_item_by_uuid)
self.servicemanager_next_item.connect(self.next_item)
self.servicemanager_previous_item.connect(self.previous_item)
self.servicemanager_new_file.connect(self.new_file)
def bootstrap_post_set_up(self):
"""
@ -511,6 +513,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
self.set_modified(False)
self.settings.setValue('servicemanager/last file', None)
self.plugin_manager.new_service_created()
self.live_controller.slide_count = 0
def create_basic_service(self):
"""
@ -1324,7 +1327,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
service_item_from_item.service_item_type is not ServiceItemType.Text:
text = slide['title'].replace('\n', ' ')
else:
text = service_item_from_item.get_rendered_frame(slide_index)
text = service_item_from_item.get_rendered_frame(slide_index, clean=True)
child.setText(0, text[:40])
child.setData(0, QtCore.Qt.UserRole, slide_index)
if service_item == item_index:

View File

@ -27,7 +27,6 @@ from openlp.core.common.i18n import UiStrings, translate
from openlp.core.ui.icons import UiIcons
from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.lib.ui import create_action
from openlp.plugins.bibles.remote import register_views
from openlp.plugins.bibles.lib.biblestab import BiblesTab
from openlp.plugins.bibles.lib.manager import BibleManager
from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem
@ -48,7 +47,6 @@ class BiblePlugin(Plugin):
self.icon_path = UiIcons().bible
self.icon = UiIcons().bible
self.manager = BibleManager(self)
register_views()
State().add_service('bible', self.weight, is_plugin=True)
State().update_pre_conditions('bible', self.check_pre_conditions())

View File

@ -31,7 +31,6 @@ from openlp.core.lib import build_icon
from openlp.core.lib.db import Manager
from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons
from openlp.plugins.custom.remote import register_views
from openlp.plugins.custom.lib.db import CustomSlide, init_schema
from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
from openlp.plugins.custom.lib.customtab import CustomTab
@ -55,7 +54,6 @@ class CustomPlugin(Plugin):
self.db_manager = Manager('custom', init_schema)
self.icon_path = UiIcons().clone
self.icon = build_icon(self.icon_path)
register_views()
State().add_service(self.name, self.weight, is_plugin=True)
State().update_pre_conditions(self.name, self.check_pre_conditions())

View File

@ -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-2020 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; version 2 of the License. #
# #
# 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, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
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_custom = Blueprint('v1-custom-plugin', __name__)
v2_custom = Blueprint('v2-custom-plugin', __name__)
def search(text):
plugin = Registry().get('plugin_manager').get_plugin_by_name('custom')
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('custom')
if plugin.status == PluginStatus.Active and plugin.media_item:
plugin.media_item.custom_go_live.emit([id, True])
def add(id):
plugin = Registry().get('plugin_manager').get_plugin_by_name('custom')
if plugin.status == PluginStatus.Active and plugin.media_item:
item_id = plugin.media_item.create_item_from_id(id)
plugin.media_item.custom_add_to_service.emit([item_id, True])
@v2_custom.route('/search')
@login_required
def search_view():
text = request.args.get('text', '')
result = search(text)
return jsonify(result)
@v2_custom.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_custom.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_custom.route('/search')
@old_auth
def old_search():
text = extract_request(request.args.get('data', ''), 'text')
return jsonify({'results': {'items': search(text)}})
@v1_custom.route('/add')
@old_auth
def old_add():
id = extract_request(request.args.get('data', ''), 'id')
add(id)
return '', 204
@v1_custom.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_custom, url_prefix='/api/v2/plugins/custom/')
app.register_blueprint(v1_custom, url_prefix='/api/custom/')

View File

@ -27,7 +27,6 @@ from openlp.core.lib import build_icon
from openlp.core.lib.db import Manager
from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons
from openlp.plugins.images.remote import register_views
from openlp.plugins.images.lib import upgrade
from openlp.plugins.images.lib.mediaitem import ImageMediaItem
from openlp.plugins.images.lib.imagetab import ImageTab
@ -46,7 +45,6 @@ class ImagePlugin(Plugin):
self.weight = -7
self.icon_path = UiIcons().picture
self.icon = build_icon(self.icon_path)
register_views()
State().add_service('image', self.weight, is_plugin=True)
State().update_pre_conditions('image', self.check_pre_conditions())

View File

@ -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-2020 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; version 2 of the License. #
# #
# 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, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
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_images = Blueprint('v1-images-plugin', __name__)
v2_images = Blueprint('v2-images-plugin', __name__)
def search(text):
plugin = Registry().get('plugin_manager').get_plugin_by_name('images')
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('images')
if plugin.status == PluginStatus.Active and plugin.media_item:
plugin.media_item.images_go_live.emit([id, True])
def add(id):
plugin = Registry().get('plugin_manager').get_plugin_by_name('images')
if plugin.status == PluginStatus.Active and plugin.media_item:
item_id = plugin.media_item.create_item_from_id(id)
plugin.media_item.images_add_to_service.emit([item_id, True])
@v2_images.route('/search')
@login_required
def search_view():
text = request.args.get('text', '')
result = search(text)
return jsonify(result)
@v2_images.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_images.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_images.route('/search')
@old_auth
def old_search():
text = extract_request(request.args.get('data', ''), 'text')
return jsonify({'results': {'items': search(text)}})
@v1_images.route('/add')
@old_auth
def old_add():
id = extract_request(request.args.get('data', ''), 'id')
add(id)
return '', 204
@v1_images.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_images, url_prefix='/api/v2/plugins/images/')
app.register_blueprint(v1_images, url_prefix='/api/images/')

View File

@ -28,7 +28,6 @@ from openlp.core.common.i18n import translate
from openlp.core.ui.icons import UiIcons
from openlp.core.lib import build_icon
from openlp.core.lib.plugin import Plugin, StringContent
from openlp.plugins.media.remote import register_views
from openlp.plugins.media.lib.mediaitem import MediaMediaItem
@ -50,7 +49,6 @@ class MediaPlugin(Plugin):
self.icon = build_icon(self.icon_path)
# passed with drag and drop messages
self.dnd_id = 'Media'
register_views()
State().add_service(self.name, self.weight, requires='mediacontroller', is_plugin=True)
State().update_pre_conditions(self.name, self.check_pre_conditions())

View File

@ -304,6 +304,7 @@ class PresentationMediaItem(MediaManagerItem):
:param item: The Song item to be used
:param remote: Triggered from remote
:param context: Why is it being generated
:param file_path: Path for the file to be processes
:param kwargs: Consume other unused args specified by the base implementation, but not use by this one.
"""
if item:
@ -313,7 +314,7 @@ class PresentationMediaItem(MediaManagerItem):
if len(items) > 1:
return False
if file_path is None:
file_path = items[0].data(QtCore.Qt.UserRole)
file_path = Path(items[0].data(QtCore.Qt.UserRole))
file_type = file_path.suffix.lower()[1:]
if not self.display_type_combo_box.currentText():
return False
@ -365,7 +366,7 @@ class PresentationMediaItem(MediaManagerItem):
service_item.processor = self.display_type_combo_box.currentText()
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
for bitem in items:
file_path = bitem.data(QtCore.Qt.UserRole)
file_path = Path(bitem.data(QtCore.Qt.UserRole))
path, file_name = file_path.parent, file_path.name
service_item.title = file_name
if file_path.exists():

View File

@ -32,7 +32,6 @@ from openlp.core.lib import build_icon
from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.state import State
from openlp.core.ui.icons import UiIcons
from openlp.plugins.presentations.remote import register_views
from openlp.plugins.presentations.lib.presentationcontroller import PresentationController
from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem
from openlp.plugins.presentations.lib.presentationtab import PresentationTab
@ -58,7 +57,6 @@ class PresentationPlugin(Plugin):
self.weight = -8
self.icon_path = UiIcons().presentation
self.icon = build_icon(self.icon_path)
register_views()
State().add_service('presentation', self.weight, is_plugin=True)
State().update_pre_conditions('presentation', self.check_pre_conditions())

View File

@ -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-2020 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; version 2 of the License. #
# #
# 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, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
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_presentations = Blueprint('v1-presentations-plugin', __name__)
v2_presentations = Blueprint('v2-presentations-plugin', __name__)
def search(text):
plugin = Registry().get('plugin_manager').get_plugin_by_name('presentations')
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('presentations')
if plugin.status == PluginStatus.Active and plugin.media_item:
plugin.media_item.presentations_go_live.emit([id, True])
def add(id):
plugin = Registry().get('plugin_manager').get_plugin_by_name('presentations')
if plugin.status == PluginStatus.Active and plugin.media_item:
item_id = plugin.media_item.create_item_from_id(id)
plugin.media_item.presentations_add_to_service.emit([item_id, True])
@v2_presentations.route('/search')
@login_required
def search_view():
text = request.args.get('text', '')
result = search(text)
return jsonify(result)
@v2_presentations.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_presentations.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_presentations.route('/search')
@old_auth
def old_search():
text = extract_request(request.args.get('data', ''), 'text')
return jsonify({'results': {'items': search(text)}})
@v1_presentations.route('/add')
@old_auth
def old_add():
id = extract_request(request.args.get('data', ''), 'id')
add(id)
return '', 204
@v1_presentations.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_presentations, url_prefix='/api/v2/plugins/presentations/')
app.register_blueprint(v1_presentations, url_prefix='/api/presentations/')

View File

@ -40,7 +40,6 @@ from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.lib.ui import create_action
from openlp.core.ui.icons import UiIcons
from openlp.plugins.songs import reporting
from openlp.plugins.songs.remote import register_views
from openlp.plugins.songs.forms.duplicatesongremovalform import DuplicateSongRemovalForm
from openlp.plugins.songs.forms.songselectform import SongSelectForm
from openlp.plugins.songs.lib import clean_song, upgrade
@ -127,7 +126,6 @@ class SongsPlugin(Plugin):
self.icon = build_icon(self.icon_path)
self.songselect_form = None
self.settings.extend_default_settings(song_footer)
register_views()
State().add_service(self.name, self.weight, is_plugin=True)
State().update_pre_conditions(self.name, self.check_pre_conditions())
if not self.settings.value('songs/last import type'):