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

553 by mattgiuca
Added new app: Settings (UI for userservice).
1
# IVLE
2
# Copyright (C) 2007-2008 The University of Melbourne
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18
# App: settings
19
# Author: Matt Giuca
20
# Date: 25/2/2008
21
22
# User settings UI
23
# (Also provides UI for administering users, given sufficient privileges).
24
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
25
from ivle import util
553 by mattgiuca
Added new app: Settings (UI for userservice).
26
27
def handle(req):
28
    """Handler for the Settings application."""
29
30
    # Set request attributes
31
    req.content_type = "text/html"
32
    # These files don't really exist - just a test of our linking
33
    # capabilities
560 by mattgiuca
settings: Python code generates all of the HTML for the static page.
34
    req.styles = [
35
        "media/settings/settings.css",
36
    ]
37
    req.scripts = [
38
        "media/settings/settings.js",
39
        "media/common/json2.js",
40
        "media/common/util.js",
41
    ]
850 by dcoles
Console: Moved console up into dispatch. Now any application can, in theory,
42
    req.scripts_init = [
43
        "revert_settings"
44
    ]
553 by mattgiuca
Added new app: Settings (UI for userservice).
45
    req.write_html_head_foot = True     # Have dispatch print head and foot
46
47
    # Start writing data
560 by mattgiuca
settings: Python code generates all of the HTML for the static page.
48
    req.write("""<div id="ivle_padding">
49
50
  <h2>User Profile</h2>
577 by mattgiuca
settings: Now populates all fields on the fly with the info from the DB,
51
  <p><span id="login"></span></p>
52
  <p id="role"></p>
560 by mattgiuca
settings: Python code generates all of the HTML for the static page.
53
  <h3>Change settings</h3>
580 by mattgiuca
settings: Now able to handle the save button. This updates the user's details.
54
  <form action="">
55
    <table>
56
      <tr><td>Display name:</td><td><input type="text"
57
            name="nick" id="nick" size="40" /></td></tr>
58
      <tr><td>Email address:</td><td><input type="text"
59
            name="email" id="email" size="40" /></td></tr>
60
    </table>
61
    <div id="changepassword"></div>
62
    <p id="result"></p>
63
    <p>
64
      <input value="Save" onclick="return save_settings()" id="save"
65
          type="submit" />
66
      <input value="Revert" onclick="return revert_settings()" id="revert"
67
          type="reset" />
68
    </p>
69
  </form>
560 by mattgiuca
settings: Python code generates all of the HTML for the static page.
70
71
  <div id="notices"></div>
72
</div>
73
""")