changeset 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 9e82360a5592
children 43461463758f
files data/plugin/action/submit_bbb_create_meeting.py data/plugin/action/submit_bbb_start_meeting.py data/plugin/parser/bbb_create.py
diffstat 3 files changed, 131 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/submit_bbb_create_meeting.py	Wed Jun 13 14:44:05 2012 +0200
+++ b/data/plugin/action/submit_bbb_create_meeting.py	Thu Jun 14 09:38:07 2012 +0200
@@ -8,15 +8,12 @@
 
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.Page import Page
-# pip install bigbluebutton
-from bigbluebutton import Meeting_Setup
 import bbb_settings
 
 def execute(pagename, request):
     """
     Creates a bigbluebutton meeting and stores the definitions on a wiki sub page.
-    This page is protected by acls for the responsible user. By reloading the Definition
-    page the session becomes recreated.
+    This page is protected by acls for the responsible user. 
     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.
@@ -34,11 +31,11 @@
     """
     username = request.user.name
     groups = request.groups
-    msg = ["Sorry you have not enough previledges", "error"]
+    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[0], msg[1])
+        request.theme.add_msg(msg, state)
         Page(request, pagename).send_page()
         return
 
@@ -49,23 +46,10 @@
         moderator_password = request.form["moderator_password"]
 
         if not attendee_password.strip() or not moderator_password.strip():
-            msg = ["Sorry, we don't support empty passwords!", "error"]
-            request.theme.add_msg(msg[0], msg[1])
+            msg, state = ("Sorry, we don't support empty passwords!", "error")
+            request.theme.add_msg(msg, state)
             Page(request, pagename).send_page()
             return
-        scriptname = request.script_root
-        if scriptname:
-            scriptname = scriptname.lstrip('/') + '/'
-        url = "%s%s%s" % (request.host_url, scriptname, pagename.lstrip('/'))
-        session = Meeting_Setup(bbb_api_url=bbb_settings.BBB_API_URL,
-                                salt=bbb_settings.SALT,
-                                meeting_name=request.form["meeting_name"],
-                                meeting_id=request.form["meeting_id"],
-                                attendee_password=attendee_password,
-                                moderator_password=moderator_password,
-                                logout_url=url,
-                               )
-        session.create_meeting()
 
         sub_pagename = u'%s/%s' % (pagename, request.form["meeting_name"])
         keyval = "\n".join([' %s:: %s' % (key, value) for key, value in request.form.iteritems() if not (key.startswith('labels') or key.startswith('action') or key.startswith('doit'))])
@@ -76,12 +60,13 @@
                  "keyval": keyval,
                  "bbb_admin_group": bbb_admin_group.name}
 
-        try:
-            # We write without acl check
-            PageEditor(request, sub_pagename)._write_file(result, action='SAVE')
-            msg = (_(u"OK!"), "info")
-        except PageEditor.SaveError:
-            msg = (_(u"A severe error occured:"), "error")
-    request.theme.add_msg(msg[0], msg[1])
-    Page(request, pagename).send_page()
+        if request.user.may.write(sub_pagename):
+            try:
+                # We write without acl check
+                PageEditor(request, sub_pagename)._write_file(result, action='SAVE')
+                msg, state = (_(u"OK!"), "info")
+            except PageEditor.SaveError:
+                msg, state = (_(u"A severe error occured:"), "error")
+    request.theme.add_msg(msg, state)
+    Page(request, sub_pagename).send_page()
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/submit_bbb_start_meeting.py	Thu Jun 14 09:38:07 2012 +0200
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - Starts Meeting for bigbluebutton
+
+    @copyright: 2012 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+import urllib
+from MoinMoin.Page import Page
+# pip install bigbluebutton
+from bigbluebutton import Meeting_Setup
+import bbb_settings
+
+
+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.
+    """
+
+    _ = 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[0], msg[1])
+        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"]
+            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 = Meeting_Setup(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,
+                                    )
+                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()
+
--- a/data/plugin/parser/bbb_create.py	Wed Jun 13 14:44:05 2012 +0200
+++ b/data/plugin/parser/bbb_create.py	Thu Jun 14 09:38:07 2012 +0200
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 """
-    MoinMoin - Parser for creating a bigbluebutton meeting (http://www.bigbluebutton.org/)
+    MoinMoin - Parser for bigbluebutton meeting controls (http://www.bigbluebutton.org/)
 
     @copyright: 2012 MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
@@ -9,14 +9,14 @@
 import time
 from MoinMoin import wikiutil
 # pip install bigbluebutton
-from bigbluebutton import Meeting_Setup, Meeting
+from bigbluebutton import Meeting
 import bbb_settings
 
 Dependencies = []
 
 class Parser:
     """
-    Lets a user create a meeting.
+    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
@@ -58,65 +58,53 @@
             wiki_parser.format(formatter)
             return
 
-        msg = ""
+
         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
 
-        if request.user.valid and username in bbb_admin_group:
-            recreate = True
-            scriptname = request.script_root
-            if scriptname:
-                scriptname = scriptname.lstrip('/') + '/'
-            url = "%s%s%s" % (request.host_url, scriptname, pagename.lstrip('/'))
-            msg = "(!) Meeting started :) "
-            try:
-                session = Meeting_Setup(bbb_api_url=bbb_settings.BBB_API_URL, salt=bbb_settings.SALT,
-                                    meeting_name=content["meeting_name"], meeting_id=meeting_id,
-                                    attendee_password=attendee_password,
-                                    moderator_password=moderator_password,
-                                    logout_url=url,
-                                    )
-                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
+        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})
 
-        actions = []
-        if request.user.valid and request.user.may.read(pagename):
-            meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
-
-            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),
+                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:
-                if msg:
-                     msg += "\n\n/!\ A Moderator has to join this meeting before someone else can join in!"
                 else:
-                    msg = " /!\ A Moderator has to join this meeting before someone else can join in!"
-            if request.user.may.write(pagename):
-                if meeting.is_running(meeting_id):
-                    msg += "\n\n(!) Someone else is already attending this meeting"
-                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})
-                actions.append(u' . <<Action(submit_bbb_close_meeting, text="Close this meeting", meeting_id=%(meeting_id)s, password=%(password)s)>>' % {"meeting_id": meeting_id,
+                    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 request.user.may.delete(pagename):
+                                                                                                                                              })
+
+            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")>>')
-        else:
-            if request.user.valid and request.user.may.write(pagename):
-                actions.append(u' . <<Action(edit, text="edit meeting")>>')
+                
+
 
         raw = u"""
 %(msg)s