~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/groups/__init__.py

  • Committer: dcoles
  • Date: 2008-08-09 08:05:13 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1001
Groups: Added the view half of the group admin panel. This lets people with the 
MANAGEGROUPS capibility to see all the project sets and groups in each subject 
offering for that subject. Next is to use the new userservice calls to add and 
modify these groups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
import cgi
27
27
 
28
 
from common import util
 
28
from common import (util, caps)
29
29
import common.db
30
30
 
31
31
def handle(req):
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"]
 
35
    req.scripts = [
 
36
        "media/groups/groups.js",
 
37
        "media/common/util.js",
 
38
        "media/common/json2.js",
 
39
    ]
36
40
    req.write_html_head_foot = True     # Have dispatch print head and foot
37
41
 
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)
 
60
        
54
61
        req.write("</div>\n")
55
62
    finally:
56
63
        db.close()
57
64
 
 
65
def show_groupadmin_panel(req, db):
 
66
    """
 
67
    Shows the group admin panel
 
68
    """
 
69
    req.write("<hr/>\n")
 
70
    req.write("<h1>Group Administration</h1>")
 
71
    # Choose subject
 
72
    subjects = db.get_subjects()
 
73
    req.write("<p>Manage a subject's groups:</p>\n")
 
74
    req.write("<select id=\"subject_select\">\n")
 
75
    for s in subjects:
 
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>")
 
82
 
58
83
def show_subject_panel(req, db, offeringid, subj_name):
59
84
    """
60
85
    Show the group management panel for a particular subject.
61
86
    Prints to req.
62
87
    """
 
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)
88
114
    if True:        # XXX Only if offering allows students to create groups
89
115
        req.write('<input type="button" onclick="create(%d)" '
90
116
            'value="Create Group" />\n' % offeringid)
 
117
    req.write("</div>")