mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
VC/Vidyo: remove obsolete vc rooms
This commit is contained in:
parent
07efefc863
commit
0070419a1b
65
vc_vidyo/indico_vc_vidyo/http_api.py
Normal file
65
vc_vidyo/indico_vc_vidyo/http_api.py
Normal file
@ -0,0 +1,65 @@
|
||||
# This file is part of Indico.
|
||||
# Copyright (C) 2002 - 2016 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
from flask import request
|
||||
|
||||
from indico.modules.vc.models.vc_rooms import VCRoom, VCRoomStatus
|
||||
from indico.web.http_api.hooks.base import HTTPAPIHook
|
||||
|
||||
|
||||
class DeleteVCRoomAPI(HTTPAPIHook):
|
||||
PREFIX = 'api'
|
||||
TYPES = ('deletevcroom',)
|
||||
RE = r'vidyo'
|
||||
GUEST_ALLOWED = False
|
||||
VALID_FORMATS = ('json',)
|
||||
COMMIT = True
|
||||
HTTP_POST = True
|
||||
|
||||
def _hasAccess(self, aw):
|
||||
from indico_vc_vidyo.plugin import VidyoPlugin
|
||||
return aw.getUser().user in VidyoPlugin.settings.acls.get('managers')
|
||||
|
||||
def _getParams(self):
|
||||
super(DeleteVCRoomAPI, self)._getParams()
|
||||
self._room_ids = map(int, request.form.getlist('rid'))
|
||||
|
||||
def api_deletevcroom(self, aw):
|
||||
from indico_vc_vidyo.plugin import VidyoPlugin
|
||||
from indico_vc_vidyo.api import APIException
|
||||
|
||||
success = []
|
||||
failed = []
|
||||
not_in_db = []
|
||||
|
||||
for rid in self._room_ids:
|
||||
room = VCRoom.query.filter(VCRoom.type == 'vidyo',
|
||||
VCRoom.status == VCRoomStatus.created,
|
||||
VCRoom.data.contains({'vidyo_id': str(rid)})).first()
|
||||
if not room:
|
||||
not_in_db.append(rid)
|
||||
continue
|
||||
try:
|
||||
room.plugin.delete_room(room, None)
|
||||
except APIException:
|
||||
failed.append(rid)
|
||||
VidyoPlugin.logger.exception('Could not delete VC room %s', room)
|
||||
else:
|
||||
room.status = VCRoomStatus.deleted
|
||||
success.append(rid)
|
||||
VidyoPlugin.logger.info('%s deleted', room)
|
||||
|
||||
return {'success': success, 'failed': failed, 'missing': not_in_db}
|
||||
@ -33,12 +33,14 @@ from indico.modules.vc.views import WPVCEventPage, WPVCManageEvent
|
||||
from indico.util.user import retrieve_principal
|
||||
from indico.web.forms.fields import IndicoPasswordField
|
||||
from indico.web.forms.widgets import CKEditorWidget
|
||||
from indico.web.http_api.hooks.base import HTTPAPIHook
|
||||
|
||||
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.http_api import DeleteVCRoomAPI
|
||||
from indico_vc_vidyo.util import iter_user_identities, iter_extensions, update_room_from_obj
|
||||
from indico_vc_vidyo.models.vidyo_extensions import VidyoExtension
|
||||
|
||||
@ -87,6 +89,7 @@ class VidyoPlugin(VCPluginMixin, IndicoPlugin):
|
||||
self.inject_js('vc_vidyo_js', WPTPLConferenceDisplay)
|
||||
self.inject_js('vc_vidyo_js', WPVCEventPage)
|
||||
self.inject_js('vc_vidyo_js', WPVCManageEvent)
|
||||
HTTPAPIHook.register(DeleteVCRoomAPI)
|
||||
|
||||
@property
|
||||
def default_settings(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user