view data/plugin/action/submit_bbb_close_meeting.py @ 654:8c828d7b6cd4 tip

PDFList: check for pyPdf.utils.PdfReadError
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 07 Dec 2016 14:27:25 +0100
parents 127da830be6c
children
line wrap: on
line source
# -*- coding: utf-8 -*-
"""
    MoinMoin - Create Meeting for bigbluebutton

    @copyright: 2012-2016 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
"""
import urllib
from MoinMoin.Page import Page
# pip install bigbluebutton
try:
    from bigbluebutton import Meeting
except ImportError:
    Meeting = None
try:    
    import bbb_settings
except ImportError:
    bbb_settings = None

def execute(pagename, request):
    """
    Lets a Moderator of a meeting closing this meeting.
    It requires a bbb_admin_group defined in wikiconfig.py.
    Only a user of this group is allowed to use this action. 
    On same directory as wikiconfig.py you need
    a "bbb_settings.py" module with the SALT and the BBB_API_URL.

    Example Call by using http://moinmo.in/MacroMarket/FormCreate
    <<FormHeader(submit_bbb_close_meeting)>>
    || Meeting ID || <<FormText(meeting_id,maxlength=50)>> ||
    || Moderator Password: || <<FormText(password,maxlength=50)>> ||
    ||<-2:> <<FormSubmit(Send)>> ||
    <<FormFooter()>>
    """
    if Meeting is None or bbb_settings is None:
        msg, state = ("bigbluebutton module not installed or bbb_settings missing!", "error")
        request.theme.add_msg(msg, state)
        Page(request, pagename).send_page()
        return
    
    _ = request.getText
    username = request.user.name
    groups = request.groups
    msg = ["Sorry you have not enough previledges", "error"]
    try:
        bbb_admin_group = groups.get(request.cfg.bbb_admin_group, [])
    except AttributeError:
        request.theme.add_msg(msg, state)
        Page(request, pagename).send_page()
        return

    if request.user.valid and username in bbb_admin_group:
        meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
        msg, state = ("Can't close this meeting", "err")
        if request.args and request.args["action"] == u'submit_bbb_close_meeting':
            meeting_id = request.args["meeting_id"]
            password = request.args["password"]
        else:
            meeting_id = request.form["meeting_id"]
            password = request.form["password"]

        status = meeting.end_meeting(meeting_id, password)            
        if status:
            msg, state = ('Meeting %s closed' % meeting_id, 'info')

        request.theme.add_msg(msg, state)
        Page(request, pagename).send_page()