diff --git a/vc_vidyo/indico_vc_vidyo/blueprint.py b/vc_vidyo/indico_vc_vidyo/blueprint.py new file mode 100644 index 0000000..7b57497 --- /dev/null +++ b/vc_vidyo/indico_vc_vidyo/blueprint.py @@ -0,0 +1,25 @@ +# This file is part of Indico. +# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN). +# +# Indico 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. +# +# Indico 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 Indico; if not, see .from __future__ import unicode_literals + +from indico.core.plugins import IndicoPluginBlueprint + +from indico_vc_vidyo.controllers import RHVidyoRoomOwner + +blueprint = IndicoPluginBlueprint('vc_vidyo', 'indico_vc_vidyo') + +# Room management +blueprint.add_url_rule('/event//manage/videoconference/vidyo//room-owner/', + 'set_room_owner', RHVidyoRoomOwner, methods=('POST',), defaults={'service': 'vidyo'}) diff --git a/vc_vidyo/indico_vc_vidyo/controllers.py b/vc_vidyo/indico_vc_vidyo/controllers.py new file mode 100644 index 0000000..a001b2e --- /dev/null +++ b/vc_vidyo/indico_vc_vidyo/controllers.py @@ -0,0 +1,38 @@ +# This file is part of Indico. +# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN). +# +# Indico 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. +# +# Indico 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 Indico; if not, see . + +import transaction +from flask import flash, jsonify, session + +from indico.modules.vc.controllers import RHVCSystemEventBase +from indico.modules.vc.exceptions import VCRoomError +from indico.util.i18n import _ + + +class RHVidyoRoomOwner(RHVCSystemEventBase): + def _process(self): + result = {} + self.vc_room.vidyo_extension.owned_by_user = session.user + try: + self.plugin.update_room(self.vc_room, self.event) + except VCRoomError as err: + result['error'] = {'message': err.message} + result['success'] = False + transaction.abort() + else: + flash(_("You are now the owner of the room '{room.name}'".format(room=self.vc_room)), 'success') + result['success'] = True + return jsonify(result) diff --git a/vc_vidyo/indico_vc_vidyo/plugin.py b/vc_vidyo/indico_vc_vidyo/plugin.py index 8c1af57..480ad18 100644 --- a/vc_vidyo/indico_vc_vidyo/plugin.py +++ b/vc_vidyo/indico_vc_vidyo/plugin.py @@ -25,7 +25,7 @@ from wtforms.validators import NumberRange, DataRequired from indico.core.auth import multipass from indico.core.config import Config -from indico.core.plugins import IndicoPlugin, url_for_plugin, IndicoPluginBlueprint, wrap_cli_manager +from indico.core.plugins import IndicoPlugin, url_for_plugin, wrap_cli_manager from indico.core import signals from indico.modules.vc.exceptions import VCRoomError, VCRoomNotFoundError from indico.modules.vc import VCPluginSettingsFormBase, VCPluginMixin @@ -36,6 +36,7 @@ from indico.web.forms.widgets import CKEditorWidget from indico_vc_vidyo import _ from indico_vc_vidyo.api import AdminClient, APIException, RoomNotFoundAPIException +from indico_vc_vidyo.blueprint import blueprint from indico_vc_vidyo.cli import cli_manager from indico_vc_vidyo.forms import VCRoomForm, VCRoomAttachForm from indico_vc_vidyo.util import iter_user_identities, iter_extensions, update_room_from_obj @@ -298,7 +299,7 @@ class VidyoPlugin(VCPluginMixin, IndicoPlugin): return client.get_room(vc_room.data['vidyo_id']) def get_blueprints(self): - return IndicoPluginBlueprint('vc_vidyo', __name__) + return blueprint def register_assets(self): self.register_js_bundle('vc_vidyo_js', 'js/vc_vidyo.js') diff --git a/vc_vidyo/indico_vc_vidyo/static/js/vc_vidyo.js b/vc_vidyo/indico_vc_vidyo/static/js/vc_vidyo.js index fd04e49..6fd733f 100644 --- a/vc_vidyo/indico_vc_vidyo/static/js/vc_vidyo.js +++ b/vc_vidyo/indico_vc_vidyo/static/js/vc_vidyo.js @@ -11,13 +11,7 @@ $(function() { $.ajax({ url: $this.data('href'), method: 'POST', - complete: IndicoUI.Dialogs.Util.progress(), - contentType: 'application/json', - data: JSON.stringify({ - data: { - owner: ['User', $('body').data('userId')] - } - }) + complete: IndicoUI.Dialogs.Util.progress() }).done(function(result) { if (handleAjaxError(result)) { return; diff --git a/vc_vidyo/indico_vc_vidyo/templates/buttons.html b/vc_vidyo/indico_vc_vidyo/templates/buttons.html index 57268f5..6bfbdc0 100644 --- a/vc_vidyo/indico_vc_vidyo/templates/buttons.html +++ b/vc_vidyo/indico_vc_vidyo/templates/buttons.html @@ -1,11 +1,11 @@ -{% macro render_make_me_moderator(event, vc_room, event_vc_room, extra_classes='') %} +{% macro render_make_me_owner(event, vc_room, event_vc_room, extra_classes='') %} {% if session.user != vc_room.vidyo_extension.owned_by_user and event.canModify(session.user) %}