view data/plugin/parser/bbb_create.py @ 599:31ef7dc6168a

bbb: action submit_bbb_start_meeting introduced and similar code from submit_bbb_create_meeting amd bbb_create removed. Meetings have to be started by the responsible moderator before someone else can join.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 14 Jun 2012 09:38:07 +0200
parents 0b31dafef3cf
children 43461463758f
line wrap: on
line source
# -*- coding: utf-8 -*-
"""
    MoinMoin - Parser for bigbluebutton meeting controls (http://www.bigbluebutton.org/)

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

import time
from MoinMoin import wikiutil
# pip install bigbluebutton
from bigbluebutton import Meeting
import bbb_settings

Dependencies = []

class Parser:
    """
    Lets a user create a meeting page
    It requires a bbb_admin_group defined in wikiconfig.py.
    Only a user of this group is allowed to use this parser. 
    On same directory as wikiconfig.py you need
    a "bbb_settings.py" module with the SALT and the BBB_API_URL.
    
    Example:
    
    #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 = formatter.page.page_name
        content = self.request.dicts.get(pagename, {})
        request = self.request
        username = request.user.name
        groups = request.groups
        try:
            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)
            wiki_parser.format(formatter)
            return


        attendee_password = content["attendee_password"]
        moderator_password = content["moderator_password"]
        meeting_id = content["meeting_id"]
        responsible = content["responsible"]

        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)

        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)
            wiki_parser.format(formatter)
            return

        actions = []
        msg = "\n\n/!\ A Moderator has to start the meeting before someone else can join in!"
        if request.user.valid and request.user.may.read(pagename):
            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, request.user.name, 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, request.user.name, attendee_password),
                                                                                            "username": username})
                else:
                    msg = "\n\n/!\ Wait until the moderator has joined this meeting!"
            else:
                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 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")>>')
                


        raw = u"""
%(msg)s

{{{#!wiki dotted
%(actions)s
}}}

""" % {"msg": msg,
       "actions": '\n'.join(actions)
      }


        wiki_parser = wikiutil.importPlugin(self.request.cfg, "parser", "text_moin_wiki", None)
        wiki_parser = wiki_parser.Parser(raw, self.request)
        wiki_parser.format(formatter)