28
from common import util
28
from common import (util, caps)
32
32
# Set request attributes
33
33
req.content_type = "text/html"
34
34
req.styles = ["media/groups/groups.css"]
35
req.scripts = ["media/groups/groups.js"]
36
"media/groups/groups.js",
37
"media/common/util.js",
38
"media/common/json2.js",
36
40
req.write_html_head_foot = True # Have dispatch print head and foot
38
42
req.write('<div id="ivle_padding">\n')
51
55
for subject in subjects:
52
56
show_subject_panel(req, db, subject['offeringid'],
53
57
subject['subj_name'])
58
if req.user.hasCap(caps.CAP_MANAGEGROUPS):
59
show_groupadmin_panel(req, db)
54
61
req.write("</div>\n")
65
def show_groupadmin_panel(req, db):
67
Shows the group admin panel
70
req.write("<h1>Group Administration</h1>")
72
subjects = db.get_subjects()
73
req.write("<p>Manage a subject's groups:</p>\n")
74
req.write("<select id=\"subject_select\">\n")
76
req.write(" <option value=\"%d\">%s: %s</option>\n"%
77
(s['subjectid'], s['subj_code'], s['subj_name']))
78
req.write("</select>\n")
79
req.write("<input type=\"button\" value=\"Manage Subject\" \
80
onclick=\"manage_subject()\" />\n")
81
req.write("<div id=\"subject_div\"></div>")
58
83
def show_subject_panel(req, db, offeringid, subj_name):
60
85
Show the group management panel for a particular subject.
88
req.write("<div id=\"subject%d\"class=\"subject\">"%offeringid)
63
89
req.write("<h1>%s</h1>\n" % cgi.escape(subj_name))
64
90
# Get the groups this user is in, for this offering
65
91
groups = db.get_groups_by_user(req.user.login, offeringid=offeringid)