view data/plugin/action/submit_bbb_start_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 - Starts Meeting for bigbluebutton

    @copyright: 2012-2016 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
"""
import urllib
from MoinMoin.Page import Page
from MoinMoin import wikiutil

# pip install bigbluebutton
try:
    from bigbluebutton import MeetingSetup
except ImportError:
    MeetingSetup = None
try:    
    import bbb_settings
except ImportError:
    bbb_settings = None

def execute(pagename, request):
    """
    Lets a Moderator of a meeting start this.
    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.
    """
    if MeetingSetup 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, state = ("Sorry you have not enough priviledges!", "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:
        if request.args and request.args["action"] == u'submit_bbb_start_meeting':
            content = request.dicts.get(pagename, {})
            msg, state = ("You have not this priviledge to start this meeting!", "error")
            responsible = content["responsible"]
            if request.user.name != responsible:
                request.theme.add_msg(msg, state)
                Page(request, pagename).send_page()
                return

            attendee_password = content["attendee_password"]
            moderator_password = content["moderator_password"]
            try:
                pre_upload_url = content["pre_upload_url"]
                pre_upload_url = wikiutil.escape(pre_upload_url)
            except KeyError:
                pre_upload_url = None
            msg, state = ("Sorry, we don't support empty passwords!", "error")
            if not attendee_password.strip() or not moderator_password.strip():
                request.theme.add_msg(msg, state)
                Page(request, pagename).send_page()

                return
            meeting_id = content["meeting_id"]
            meeting_name = content["meeting_name"]
            recreate = True
            scriptname = request.script_root
            if scriptname:
                scriptname = scriptname.lstrip('/') + '/'
            url = "%s%s%s" % (request.host_url, scriptname, pagename.lstrip('/'))
            msg, state = ("Meeting started ", "info")
            try:
                session = MeetingSetup(bbb_api_url=bbb_settings.BBB_API_URL, salt=bbb_settings.SALT,
                                    meeting_name=meeting_name, meeting_id=meeting_id,
                                    attendee_password=attendee_password,
                                    moderator_password=moderator_password,
                                    logout_url=url, pre_upload_slide=pre_upload_url
                                    )
                try:
                    session.create_meeting()
                except TypeError:
                    recreate = False
                    msg, state = ("Usually the meeting is running and you tried to change some important parameters. Stop the Meeting beforehand.", "error")

            except KeyError:
                msg, state = ("Usually not the right parameters or syntax used! Check the page content.  ", "error")
                recreate = False


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