view data/plugin/parser/ @ 625:f4e63b74b969

FormSubmit: adapt to werkzeug MultiDict
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Mar 2013 17:47:30 +0100
parents 8f2aa479f8cd
children 127da830be6c
line wrap: on
line source
# -*- coding: utf-8 -*-
    MoinMoin - Parser for bigbluebutton meeting controls (

    @copyright: 2012 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.

import time
from MoinMoin import wikiutil
# pip install bigbluebutton
    from bigbluebutton import Meeting
except ImportError:
    Meeting = None
    import bbb_settings
except ImportError:
    bbb_settings = None

Dependencies = []
extensions = ['.bbb']

class Parser:
    Lets a user create a meeting page
    It requires a bbb_admin_group defined in
    Only a user of this group is allowed to use this parser. 
    On same directory as you need
    a "" module with the SALT and the BBB_API_URL.
    #acl YOURNAME:read,write,delete,revert All:
    #format bbb_create
    responsible:: YOURNAME
    meeting_name:: The name of the meeting
    meeting_id:: The ID of the meeting
    attendee_password:: The password for attendee (viewer)
    moderator_password:: The password for moderator

    extensions = ''
    Dependencies = []

    def __init__(self, raw, request, **kw):
        self.raw = raw
        self.request = request
        self.form = request.form
        self._ = request.getText
        self.start_line = kw.get('start_line', 0)

    def format(self, formatter):
        """ Send the text. """
        pagename =
        content = self.request.dicts.get(pagename, {})
        request = self.request
        username =
        groups = request.groups
            bbb_admin_group = groups.get(request.cfg.bbb_admin_group, [])
        except AttributeError:
            wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
            wiki_parser = wiki_parser.Parser(self.raw, self.request)

        attendee_password = content["attendee_password"]
        moderator_password = content["moderator_password"]
        meeting_id = content["meeting_id"]
        responsible = content["responsible"]
        if Meeting is not None and bbb_settings is not None:
            meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
            #XXX meeting.is_running is only True if someone had joined in, so we use meeting_info instead
            meeting_info = meeting.meeting_info(meeting_id, moderator_password)
            meeting_data = """\
|| '''Meeting ID''' || '''Participation Count''' || '''Moderator Count'''||
|| %(meeting_id)s || 0 || 0 ||""" % {"meeting_id": meeting_id
            if  meeting_info:
                users = meeting_info["users"]
                users_in_meeting = ["%s %s" % (user["name"], user["role"][0]) for user in users]
                meeting_data = """\
|| '''Meeting ID''' || '''Participation Count''' || '''Moderator Count'''|| '''users''' ||
|| %(meeting_id)s || %(participant_count)s || %(moderator_count)s || %(users)s ||""" % {"meeting_id": meeting_id,
                                                                               "participant_count": meeting_info["participant_count"],
                                                                               "moderator_count": meeting_info["moderator_count"],
                                                                               "users": '<<BR>>'.join(users_in_meeting),
            if not attendee_password.strip() or not moderator_password.strip():
                wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
                wiki_parser = wiki_parser.Parser(self.raw, self.request)
            actions = []
            actions_text = ""
            guest_info_text = ""
            msg = "\n\n/!\ A Moderator has to start the meeting before someone else can join in!"
            if request.user.valid and
                if meeting_info:
                    msg = "\n\n (!) Meeting is running. Please join in!"
                    if username == responsible:
                        actions.append(u' . [[%(moderator_url)s|Join as moderator (%(username)s)]]' % {"moderator_url": meeting.join_url(meeting_id,, moderator_password),
                                                                                                       "username": username})
                    if meeting.is_running(meeting_id):
                        actions.append(u' . [[%(attendee_url)s|Join as visitor (%(username)s)]]' % {"attendee_url": meeting.join_url(meeting_id,, attendee_password),
                                                                                                "username": username})
                        msg = "\n\n/!\ Wait until the moderator has joined this meeting!"
                    if username == responsible:
                        msg = "\n\n/!\ A Moderator has to start the meeting before someone else can join in!"
                        actions.append(u' . <<Action(submit_bbb_start_meeting, text="Click to start this meeting")>>')
                if request.user.may.write(pagename) and meeting_info:
                    if username == responsible:
                        actions.append(u' . <<Action(submit_bbb_close_meeting, text="Close this meeting", meeting_id=%(meeting_id)s, password=%(password)s)>>' % {"meeting_id": meeting_id,
                                                                                                                                                      "password": moderator_password
                        if "GUEST_URL" in bbb_settings.__dict__:
                            guest_info_text = "(!) External users can get access by using this URL: %s" % bbb_settings.GUEST_URL
                if not meeting_info and request.user.may.delete(pagename) and username == responsible:
                    # users with before rights should know to use commands of the menu
                    actions.append(u' . <<Action(edit, text="edit meeting parameter")>>')
                    actions.append(u' . <<Action(DeletePage, text="remove meeting permanently")>>')
                if actions:
                    actions_text = """{{{#!wiki dotted
    """ % {"actions": '\n'.join(actions)}
            raw = u"""
Current participants and state of users in this meeting. 
    """ % {"msg": msg,
           "meeting_data": meeting_data,
           "actions_text": actions_text,
           "guest_info_text": guest_info_text,
            wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
            wiki_parser = wiki_parser.Parser(raw, self.request)