changeset 592:8659634e0b29

parser.bbb_create: refactored to show links to visitors of the page instead of text If read and write rights on the page are given, a moderator and visitor link is shown also an additional edit link. If read only then a visitor link. If delete right is given an action link for deleting is shown.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 11 Jun 2012 16:03:47 +0200
parents 19bcf1c6ddc6
children ad72bd94694c
files data/plugin/parser/bbb_create.py
diffstat 1 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/bbb_create.py	Thu May 31 15:27:38 2012 +0200
+++ b/data/plugin/parser/bbb_create.py	Mon Jun 11 16:03:47 2012 +0200
@@ -9,7 +9,7 @@
 import time
 from MoinMoin import wikiutil
 # pip install bigbluebutton
-from bigbluebutton import Meeting_Setup
+from bigbluebutton import Meeting_Setup, Meeting
 import bbb_settings
 
 Dependencies = []
@@ -45,7 +45,8 @@
 
     def format(self, formatter):
         """ Send the text. """
-        content = self.request.dicts.get(formatter.page.page_name, {})
+        pagename = formatter.page.page_name
+        content = self.request.dicts.get(pagename, {})
         request = self.request
         username = request.user.name
         groups = request.groups
@@ -60,6 +61,7 @@
         msg = ""
         attendee_password = content["attendee_password"]
         moderator_password = content["moderator_password"]
+        meeting_id = content["meeting_id"]
         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)
@@ -68,10 +70,10 @@
 
         if request.user.valid and username in bbb_admin_group:
             recreate = True
-            msg = "(!) Successful restarted :) "
+            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=content["meeting_id"],
+                                    meeting_name=content["meeting_name"], meeting_id=meeting_id,
                                     attendee_password=attendee_password,
                                     moderator_password=moderator_password,
                                     )
@@ -85,13 +87,40 @@
                 msg = "/!\ Usually not the right parameters or syntax used! X-(  "
                 recreate = False
 
-
+        actions = []
+        if request.user.valid and request.user.may.read(pagename):
+            meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
 
-        raw = """
+            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(edit, text="edit meeting")>>')
+            if request.user.may.delete(pagename):
+                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")>>')
 
-%s
-%s
-""" % (msg, self.raw)
+        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)