view data/plugin/parser/bbb_create.py @ 591:19bcf1c6ddc6

parser.bbb_create: check for empty passwords
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 31 May 2012 15:27:38 +0200
parents b17f6afb108f
children 8659634e0b29
line wrap: on
line source
# -*- coding: utf-8 -*-
"""
    MoinMoin - Parser for creating a bigbluebutton meeting (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_Setup
import bbb_settings

Dependencies = []

class Parser:
    """
    Lets a user create a meeting.
    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. """
        content = self.request.dicts.get(formatter.page.page_name, {})
        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

        msg = ""
        attendee_password = content["attendee_password"]
        moderator_password = content["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

        if request.user.valid and username in bbb_admin_group:
            recreate = True
            msg = "(!) Successful restarted :) "
            try:
                session = Meeting_Setup(bbb_api_url=bbb_settings.BBB_API_URL, salt=bbb_settings.SALT,
                                    meeting_name=content["meeting_name"], meeting_id=content["meeting_id"],
                                    attendee_password=attendee_password,
                                    moderator_password=moderator_password,
                                    )
                try:
                    session.create_meeting()
                except TypeError:
                    recreate = False
                    msg = "/!\ Usually the meeting is running and you tried to change some important parameters. Stop the Meeting beforehand. X-("

            except KeyError:
                msg = "/!\ Usually not the right parameters or syntax used! X-(  "
                recreate = False



        raw = """

%s
%s
""" % (msg, self.raw)


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