diff --git a/livesync/indico_livesync/blueprint.py b/livesync/indico_livesync/blueprint.py index c81b7b9..891ccac 100644 --- a/livesync/indico_livesync/blueprint.py +++ b/livesync/indico_livesync/blueprint.py @@ -23,5 +23,5 @@ from indico_livesync.controllers import RHAddAgent, RHEditAgent, RHDeleteAgent blueprint = IndicoPluginBlueprint('livesync', 'indico_livesync', url_prefix='/admin/plugins/livesync') blueprint.add_url_rule('/agents/create/', 'add_agent', RHAddAgent, methods=('GET', 'POST')) -blueprint.add_url_rule('/agents//', 'edit_agent', RHEditAgent, methods=('GET', 'POST')) -blueprint.add_url_rule('/agents//delete', 'delete_agent', RHDeleteAgent, methods=('POST',)) +blueprint.add_url_rule('/agents/', 'edit_agent', RHEditAgent, methods=('GET', 'POST')) +blueprint.add_url_rule('/agents/', 'delete_agent', RHDeleteAgent, methods=('DELETE',)) diff --git a/livesync/indico_livesync/controllers.py b/livesync/indico_livesync/controllers.py index 74293d0..307a65d 100644 --- a/livesync/indico_livesync/controllers.py +++ b/livesync/indico_livesync/controllers.py @@ -20,9 +20,10 @@ from flask import request, redirect, flash from flask_pluginengine import render_plugin_template, current_plugin from indico.core.db import db +from indico.modules.admin import RHAdminBase from indico.web.flask.util import url_for from indico.web.forms.base import FormDefaults -from MaKaC.webinterface.rh.admins import RHAdminBase +from indico.web.util import jsonify_data from indico_livesync import _ from indico_livesync.models.agents import LiveSyncAgent @@ -38,12 +39,12 @@ class RHDeleteAgent(RHAdminBase): """Deletes a LiveSync agent""" def _checkParams(self): - self.agent = LiveSyncAgent.find_one(id=request.view_args['agent_id']) + self.agent = LiveSyncAgent.get_one(request.view_args['agent_id']) def _process(self): db.session.delete(self.agent) flash(_('Agent deleted'), 'success') - return redirect(url_for('plugins.details', plugin='livesync')) + return jsonify_data(flash=False) class RHAddAgent(RHAdminBase): @@ -71,7 +72,7 @@ class RHEditAgent(RHAdminBase): """Edits a LiveSync agent""" def _checkParams(self): - self.agent = LiveSyncAgent.find_one(id=request.view_args['agent_id']) + self.agent = LiveSyncAgent.get_one(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/plugin.py b/livesync/indico_livesync/plugin.py index c739d2d..62decdb 100644 --- a/livesync/indico_livesync/plugin.py +++ b/livesync/indico_livesync/plugin.py @@ -16,13 +16,10 @@ from __future__ import unicode_literals -from flask import request - from wtforms.validators import NumberRange from wtforms.fields.html5 import IntegerField from indico.core.plugins import IndicoPlugin, PluginCategory, wrap_cli_manager -from indico.core.plugins.views import WPPlugins from indico.web.forms.base import IndicoForm from indico.web.forms.fields import MultipleItemsField @@ -63,15 +60,10 @@ class LiveSyncPlugin(IndicoPlugin): self.backend_classes = {} connect_signals(self) self.template_hook('plugin-details', self._extend_plugin_details) - self.inject_js('livesync_admin_js', WPPlugins, subclasses=False, - condition=lambda: request.view_args.get('plugin') == self.name) def get_blueprints(self): return blueprint - def register_assets(self): - self.register_js_bundle('livesync_admin_js', 'js/livesync_admin.js') - def add_cli_command(self, manager): manager.add_command('livesync', wrap_cli_manager(cli_manager, self)) diff --git a/livesync/indico_livesync/static/js/livesync_admin.js b/livesync/indico_livesync/static/js/livesync_admin.js deleted file mode 100644 index 5bfdbbc..0000000 --- a/livesync/indico_livesync/static/js/livesync_admin.js +++ /dev/null @@ -1,20 +0,0 @@ -(function(global) { - var $t = $T.domain('livesync'); - global.liveSyncPluginPage = function liveSyncPluginPage() { - $('.js-delete-agent').on('click', function(e) { - e.preventDefault(); - var $this = $(this); - var msg = $t.gettext('Do you really want to delete this agent and all its queue entries?'); - new ConfirmPopup($t.gettext('Delete this agent?'), msg, function(confirmed) { - if (!confirmed) { - return; - } - - $('
', { - action: $this.data('href'), - method: 'post' - }).appendTo('body').submit(); - }).open(); - }); - }; -})(window); diff --git a/livesync/indico_livesync/templates/plugin_details_extra.html b/livesync/indico_livesync/templates/plugin_details_extra.html index fe2d790..666f24d 100644 --- a/livesync/indico_livesync/templates/plugin_details_extra.html +++ b/livesync/indico_livesync/templates/plugin_details_extra.html @@ -42,8 +42,13 @@ {{ agent.queue.filter_by(processed=false).count() }} - + {%- if agent.backend -%} {%- endif -%} @@ -78,7 +83,3 @@ indico livesync initial_export {{ agent.id }} {% endif %} - -