diff --git a/openlp/plugins/bibles/endpoint.py b/openlp/plugins/bibles/endpoint.py index e8d3add63..8d9c97228 100644 --- a/openlp/plugins/bibles/endpoint.py +++ b/openlp/plugins/bibles/endpoint.py @@ -22,6 +22,7 @@ import logging from openlp.core.api.http.endpoint import Endpoint +from openlp.core.api.http.errors import NotFound from openlp.core.api.endpoint.pluginhelpers import search, live, service from openlp.core.api.http import requires_auth @@ -33,7 +34,6 @@ api_bibles_endpoint = Endpoint('api') @bibles_endpoint.route('search') -@api_bibles_endpoint.route('bibles/search') def bibles_search(request): """ Handles requests for searching the bibles plugin @@ -44,7 +44,6 @@ def bibles_search(request): @bibles_endpoint.route('live') -@api_bibles_endpoint.route('bibles/live') @requires_auth def bibles_live(request): """ @@ -56,6 +55,37 @@ def bibles_live(request): @bibles_endpoint.route('add') +@requires_auth +def bibles_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + service(request, 'bibles', log) + + +@api_bibles_endpoint.route('bibles/search') +def bibles_search(request): + """ + Handles requests for searching the bibles plugin + + :param request: The http request object. + """ + return search(request, 'bibles', log) + + +@api_bibles_endpoint.route('bibles/live') +@requires_auth +def bibles_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'bibles', log) + + @api_bibles_endpoint.route('bibles/add') @requires_auth def bibles_service(request): @@ -64,4 +94,7 @@ def bibles_service(request): :param request: The http request object. """ - return service(request, 'bibles', log) + try: + search(request, 'bibles', log) + except NotFound: + return {'results': {'items': []}} diff --git a/openlp/plugins/custom/endpoint.py b/openlp/plugins/custom/endpoint.py index 9d43754ed..ef2b06be9 100644 --- a/openlp/plugins/custom/endpoint.py +++ b/openlp/plugins/custom/endpoint.py @@ -33,7 +33,6 @@ api_custom_endpoint = Endpoint('api') @custom_endpoint.route('search') -@api_custom_endpoint.route('custom/search') def custom_search(request): """ Handles requests for searching the custom plugin @@ -44,7 +43,6 @@ def custom_search(request): @custom_endpoint.route('live') -@api_custom_endpoint.route('custom/live') @requires_auth def custom_live(request): """ @@ -56,6 +54,37 @@ def custom_live(request): @custom_endpoint.route('add') +@requires_auth +def custom_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + service(request, 'custom', log) + + +@api_custom_endpoint.route('custom/search') +def custom_search(request): + """ + Handles requests for searching the custom plugin + + :param request: The http request object. + """ + return search(request, 'custom', log) + + +@api_custom_endpoint.route('custom/live') +@requires_auth +def custom_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'custom', log) + + @api_custom_endpoint.route('custom/add') @requires_auth def custom_service(request): @@ -64,4 +93,7 @@ def custom_service(request): :param request: The http request object. """ - return service(request, 'custom', log) + try: + search(request, 'custom', log) + except NotFound: + return {'results': {'items': []}} diff --git a/openlp/plugins/images/endpoint.py b/openlp/plugins/images/endpoint.py index c4d5e00f1..860d2b209 100644 --- a/openlp/plugins/images/endpoint.py +++ b/openlp/plugins/images/endpoint.py @@ -22,6 +22,7 @@ import logging from openlp.core.api.http.endpoint import Endpoint +from openlp.core.api.http.errors import NotFound from openlp.core.api.endpoint.pluginhelpers import search, live, service, display_thumbnails from openlp.core.api.http import requires_auth @@ -32,41 +33,6 @@ images_endpoint = Endpoint('images') api_images_endpoint = Endpoint('api') -@images_endpoint.route('search') -@api_images_endpoint.route('images/search') -def images_search(request): - """ - Handles requests for searching the images plugin - - :param request: The http request object. - """ - return search(request, 'images', log) - - -@images_endpoint.route('live') -@api_images_endpoint.route('images/live') -@requires_auth -def images_live(request): - """ - Handles requests for making a song live - - :param request: The http request object. - """ - return live(request, 'images', log) - - -@images_endpoint.route('add') -@api_images_endpoint.route('images/add') -@requires_auth -def images_service(request): - """ - Handles requests for adding a song to the service - - :param request: The http request object. - """ - return service(request, 'images', log) - - # images/thumbnails/320x240/1.jpg @images_endpoint.route('thumbnails/{dimensions}/{file_name}') def images_thumbnails(request, dimensions, file_name): @@ -78,3 +44,70 @@ def images_thumbnails(request, dimensions, file_name): :return: """ return display_thumbnails(request, 'images', log, dimensions, file_name) + + +@images_endpoint.route('search') +def images_search(request): + """ + Handles requests for searching the images plugin + + :param request: The http request object. + """ + return search(request, 'images', log) + + +@images_endpoint.route('live') +@requires_auth +def images_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'images', log) + + +@images_endpoint.route('add') +@requires_auth +def images_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + service(request, 'images', log) + + +@api_images_endpoint.route('images/search') +def images_search(request): + """ + Handles requests for searching the images plugin + + :param request: The http request object. + """ + return search(request, 'images', log) + + +@api_images_endpoint.route('images/live') +@requires_auth +def images_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'images', log) + + +@api_images_endpoint.route('images/add') +@requires_auth +def images_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + try: + search(request, 'images', log) + except NotFound: + return {'results': {'items': []}} diff --git a/openlp/plugins/media/endpoint.py b/openlp/plugins/media/endpoint.py index 19a0089a2..32e86590a 100644 --- a/openlp/plugins/media/endpoint.py +++ b/openlp/plugins/media/endpoint.py @@ -22,6 +22,7 @@ import logging from openlp.core.api.http.endpoint import Endpoint +from openlp.core.api.http.errors import NotFound from openlp.core.api.endpoint.pluginhelpers import search, live, service from openlp.core.api.http import requires_auth @@ -33,7 +34,6 @@ api_media_endpoint = Endpoint('api') @media_endpoint.route('search') -@api_media_endpoint.route('media/search') def media_search(request): """ Handles requests for searching the media plugin @@ -44,7 +44,6 @@ def media_search(request): @media_endpoint.route('live') -@api_media_endpoint.route('media/live') @requires_auth def media_live(request): """ @@ -56,6 +55,37 @@ def media_live(request): @media_endpoint.route('add') +@requires_auth +def media_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + service(request, 'media', log) + + +@api_media_endpoint.route('media/search') +def media_search(request): + """ + Handles requests for searching the media plugin + + :param request: The http request object. + """ + return search(request, 'media', log) + + +@api_media_endpoint.route('media/live') +@requires_auth +def media_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'media', log) + + @api_media_endpoint.route('media/add') @requires_auth def media_service(request): @@ -64,4 +94,7 @@ def media_service(request): :param request: The http request object. """ - return service(request, 'media', log) + try: + search(request, 'media', log) + except NotFound: + return {'results': {'items': []}} diff --git a/openlp/plugins/presentations/endpoint.py b/openlp/plugins/presentations/endpoint.py index 56ff31ad5..495c9b764 100644 --- a/openlp/plugins/presentations/endpoint.py +++ b/openlp/plugins/presentations/endpoint.py @@ -22,6 +22,7 @@ import logging from openlp.core.api.http.endpoint import Endpoint +from openlp.core.api.http.errors import NotFound from openlp.core.api.endpoint.pluginhelpers import search, live, service, display_thumbnails from openlp.core.api.http import requires_auth @@ -32,41 +33,6 @@ presentations_endpoint = Endpoint('presentations') api_presentations_endpoint = Endpoint('api') -@presentations_endpoint.route('search') -@api_presentations_endpoint.route('presentations/search') -def presentations_search(request): - """ - Handles requests for searching the presentations plugin - - :param request: The http request object. - """ - return search(request, 'presentations', log) - - -@presentations_endpoint.route('live') -@api_presentations_endpoint.route('presentations/live') -@requires_auth -def presentations_live(request): - """ - Handles requests for making a song live - - :param request: The http request object. - """ - return live(request, 'presentations', log) - - -@presentations_endpoint.route('add') -@api_presentations_endpoint.route('presentations/add') -@requires_auth -def presentations_service(request): - """ - Handles requests for adding a song to the service - - :param request: The http request object. - """ - return service(request, 'presentations', log) - - # /presentations/thumbnails88x88/PA%20Rota.pdf/slide5.png @presentations_endpoint.route('thumbnails/{dimensions}/{file_name}/{slide}') def presentations_thumbnails(request, dimensions, file_name, slide): @@ -79,3 +45,71 @@ def presentations_thumbnails(request, dimensions, file_name, slide): :return: """ return display_thumbnails(request, 'presentations', log, dimensions, file_name, slide) + + +@presentations_endpoint.route('search') +def presentations_search(request): + """ + Handles requests for searching the presentations plugin + + :param request: The http request object. + """ + return search(request, 'presentations', log) + + +@presentations_endpoint.route('live') +@requires_auth +def presentations_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'presentations', log) + + +@presentations_endpoint.route('add') +@requires_auth +def presentations_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + service(request, 'presentations', log) + + +@api_presentations_endpoint.route('presentations/search') +def presentations_search(request): + """ + Handles requests for searching the presentations plugin + + :param request: The http request object. + """ + return search(request, 'presentations', log) + + +@api_presentations_endpoint.route('presentations/live') +@requires_auth +def presentations_live(request): + """ + Handles requests for making a song live + + :param request: The http request object. + """ + return live(request, 'presentations', log) + + +@api_presentations_endpoint.route('presentations/add') +@requires_auth +def presentations_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + try: + search(request, 'presentations', log) + except NotFound: + return {'results': {'items': []}} + diff --git a/openlp/plugins/songs/endpoint.py b/openlp/plugins/songs/endpoint.py index 67c291fa9..bfab68697 100644 --- a/openlp/plugins/songs/endpoint.py +++ b/openlp/plugins/songs/endpoint.py @@ -40,20 +40,7 @@ def songs_search(request): :param request: The http request object. """ - search(request, 'songs', log) - - -@api_songs_endpoint.route('songs/search') -def songs_search(request): - """ - Handles requests for searching the songs plugin - - :param request: The http request object. - """ - try: - search(request, 'songs', log) - except NotFound: - return {'results': {'items': []}} + return search(request, 'songs', log) @songs_endpoint.route('live') @@ -64,10 +51,31 @@ def songs_live(request): :param request: The http request object. """ - live(request, 'songs', log) + return live(request, 'songs', log) -@songs_endpoint.route('songs/live') +@songs_endpoint.route('add') +@requires_auth +def songs_service(request): + """ + Handles requests for adding a song to the service + + :param request: The http request object. + """ + service(request, 'songs', log) + + +@api_songs_endpoint.route('songs/search') +def songs_search(request): + """ + Handles requests for searching the songs plugin + + :param request: The http request object. + """ + return search(request, 'songs', log) + + +@api_songs_endpoint.route('songs/live') @requires_auth def songs_live(request): """ @@ -75,7 +83,7 @@ def songs_live(request): :param request: The http request object. """ - live(request, 'songs', log) + return live(request, 'songs', log) @api_songs_endpoint.route('songs/add') @@ -86,16 +94,7 @@ def songs_service(request): :param request: The http request object. """ - service(request, 'songs', log) - return {'results': {'success': True}} - - -@songs_endpoint.route('songs/add') -@requires_auth -def songs_service(request): - """ - Handles requests for adding a song to the service - - :param request: The http request object. - """ - service(request, 'songs', log) + try: + search(request, 'songs', log) + except NotFound: + return {'results': {'items': []}}