annotate data/plugin/action/submit_bbb_close_meeting.py @ 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 8c908e614131
children 127da830be6c
rev   line source
588
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - Create Meeting for bigbluebutton
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 @copyright: 2012 MoinMoin:ReimarBauer
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 """
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 import urllib
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 from MoinMoin.Page import Page
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 # pip install bigbluebutton
606
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
11 try:
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
12 from bigbluebutton import Meeting
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
13 except ImportError:
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
14 Meeting = None
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
15 try:
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
16 import bbb_settings
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
17 except ImportError:
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
18 bbb_settings = None
588
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 def execute(pagename, request):
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 """
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 Lets a Moderator of a meeting closing this meeting.
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 It requires a bbb_admin_group defined in wikiconfig.py.
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 Only a user of this group is allowed to use this action.
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 On same directory as wikiconfig.py you need
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 a "bbb_settings.py" module with the SALT and the BBB_API_URL.
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 Example Call by using http://moinmo.in/MacroMarket/FormCreate
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 <<FormHeader(submit_bbb_close_meeting)>>
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 || Meeting ID || <<FormText(meeting_id,maxlength=50)>> ||
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 || Moderator Password: || <<FormText(password,maxlength=50)>> ||
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 ||<-2:> <<FormSubmit(Send)>> ||
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 <<FormFooter()>>
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34 """
606
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
35 if Meeting is None or bbb_settings is None:
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
36 msg, state = ("bigbluebutton module not installed or bbb_settings missing!", "error")
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
37 request.theme.add_msg(msg, state)
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
38 Page(request, pagename).send_page()
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
39 return
7909cd319ce8 bbb: bug fix for parser lookup by extensions. We check now if bigbluebutton lib is installed.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 596
diff changeset
40
588
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 _ = request.getText
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 username = request.user.name
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 groups = request.groups
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 msg = ["Sorry you have not enough previledges", "error"]
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45 try:
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46 bbb_admin_group = groups.get(request.cfg.bbb_admin_group, [])
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47 except AttributeError:
608
8c908e614131 bbb: bug fix for sending msg and state
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 606
diff changeset
48 request.theme.add_msg(msg, state)
588
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 Page(request, pagename).send_page()
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 return
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
51
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52 if request.user.valid and username in bbb_admin_group:
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
596
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
54 msg, state = ("Can't close this meeting", "err")
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
55 if request.args and request.args["action"] == u'submit_bbb_close_meeting':
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
56 meeting_id = request.args["meeting_id"]
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
57 password = request.args["password"]
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
58 else:
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
59 meeting_id = request.form["meeting_id"]
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
60 password = request.form["password"]
588
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61
596
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
62 status = meeting.end_meeting(meeting_id, password)
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
63 if status:
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
64 msg, state = ('Meeting %s closed' % meeting_id, 'info')
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
65
84ef153f8363 bbb: session close url to parser as action call added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 588
diff changeset
66 request.theme.add_msg(msg, state)
588
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 Page(request, pagename).send_page()
50f81f786081 Initial Version of a parser and actions for accessing a BigBlueButton instance.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68