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

« back to all changes in this revision

Viewing changes to www/dispatch/html.py

  • Committer: mattgiuca
  • Date: 2008-02-01 07:46:26 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:375
www/common/makeuser.py:
    Now accepts a large number of arguments for all the fields of the user.
    (password, full name, nick name, student id, role)
    Creates a new user in the DB.
    Creates a Unix account for the user on the current machine. (This will
    need to change to create one on the central machine to be propagated).
makeuser script: Accepts all the arguments as above and passes them along to
    www/common/makeuser.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
53
53
    # Write inline JavaScript which gives the client code access to certain
54
54
    # server-side variables.
55
 
    if req.user:
56
 
        username = repr(req.user.login)
 
55
    if req.username:
 
56
        username = repr(req.username)
57
57
    else:
58
58
        username = "null"
59
59
    req.write("""  <script type="text/javascript">
61
61
    username = %s;
62
62
  </script>
63
63
""" % (repr(conf.root_dir), username))
64
 
    iconurl = get_icon_url(req.app, small=True)
 
64
    iconurl = get_icon_url(req.app)
65
65
    if iconurl:
66
66
        req.write("""  <link rel="shortcut icon" href="%s" />
67
67
""" % cgi.escape(iconurl))
73
73
        req.write('  <link rel="stylesheet" type="text/css" href="%s" />\n'
74
74
            % cgi.escape(util.make_path(style)))
75
75
    for script in req.scripts:
76
 
        req.write('  <script type="text/javascript" src="%s"></script>\n'
 
76
        req.write('  <script type="text/javascript" src="%s" />\n'
77
77
            % cgi.escape(util.make_path(script)))
78
78
 
79
79
    req.write("</head>\n\n")
86
86
  <h2>Informatics Virtual Learning Environment</h2>
87
87
""")
88
88
 
89
 
    if req.user:
90
 
        # Get the user's nickname from the request session
91
 
        nickname = req.user.nick
92
 
        req.write('  <p class="userhello"><span id="usernick">%s</span> '
93
 
            '(<span class="username">%s</span>) |\n'
94
 
            '    <a href="%s">Settings</a> |\n'
 
89
    if req.username:
 
90
        req.write('  <p class="userhello">Welcome, <span '
 
91
            'class="username">%s</span> |\n'
95
92
            '    <a href="%s">Help</a> |\n'
96
 
            '    <a href="%s">Sign out</a>\n'
 
93
            '    <a href="%s">Logout</a>\n'
97
94
            '  </p>\n' %
98
 
            (cgi.escape(nickname), cgi.escape(req.user.login),
99
 
             cgi.escape(util.make_path('settings')),
 
95
            (cgi.escape(req.username),
100
96
             cgi.escape(get_help_url(req)),
101
97
             cgi.escape(util.make_path('logout'))))
102
98
    else:
103
99
        req.write('  <p class="userhello">Not logged in.</p>')
104
100
 
105
 
    # ivleheader_tabs is a separate div, so it can be positioned absolutely
106
 
    req.write('</div>\n<div id="ivleheader_tabs">\n')
107
 
 
108
101
    # If the "debuginfo" app is installed, display a warning to the admin to
109
102
    # make sure it is removed in production.
110
103
    if "debuginfo" in conf.apps.app_url:
111
 
        req.write("  <p><small>Warning: debuginfo is enabled. Set "
112
 
            "enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
113
 
            "into production.</small></p>\n")
 
104
        req.write("  <p><small>Warning: debuginfo is enabled. Remove this "
 
105
            "app from conf.apps.app_url when placed into production."
 
106
            "</small></p>\n")
 
107
    # ivleheader_tabs is a separate div, so it can be positioned absolutely
 
108
    req.write('</div>\n<div id="ivleheader_tabs">\n')
114
109
 
115
 
    # If req has a "no_agreement" attribute, then it is because the user has
116
 
    # not signed the agreement; therefore we are displaying the TOS page.
117
 
    # Do not show apps (see dispatch.login).
118
 
    if req.user and not req.user.state == 'no_agreement':
 
110
    if req.username:
119
111
        # Only print app tabs if logged in
120
112
        print_apps_list(req, req.app)
121
113
    req.write('</div>\n<div id="ivlebody">\n')
130
122
def get_help_url(req):
131
123
    """Gets the help URL most relevant to this page, to place as the
132
124
    "help" link at the top of the page."""
133
 
    reqapp = req.app if hasattr(req, 'app') else None
134
 
    if reqapp == 'help':
 
125
    if req.app == 'help':
135
126
        # We're already in help. Link to the exact current page
136
127
        # instead of the generic help page.
137
128
        return req.uri
138
 
    if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
139
 
        help_path = os.path.join('help', reqapp)
 
129
    if conf.apps.app_url[req.app].hashelp:
 
130
        help_path = os.path.join('help', req.app)
140
131
    else:
141
132
        help_path = 'help'
142
133
    return util.make_path(help_path)
145
136
    """Given an app's url name, gets the URL of the icon image for this app,
146
137
    relative to the site root. Returns None if the app has no icon."""
147
138
    if appurl is None: return None
148
 
    try:
149
 
        app = conf.apps.app_url[appurl]
150
 
    except KeyError:
151
 
        # Due to navigating to a bad app
152
 
        return None
 
139
    app = conf.apps.app_url[appurl]
153
140
    if small:
154
141
        icon_dir = conf.apps.app_icon_dir_small
155
142
    else: