Ticket #3937: trac_3937.patch

File trac_3937.patch, 8.2 KB (added by Mike Hansen, 14 years ago)
  • sage/server/notebook/template.py

    # HG changeset patch
    # User Timothy Clemans <timothy.clemans@gmail.com>
    # Date 1224803176 25200
    # Node ID db0997423340c86bf778ed475cce4f14c4c0866e
    # Parent  c6bf3105ffa9200e5e73a5944d704e9b9d306400
    Trac #3937
    
    diff -r c6bf3105ffa9 -r db0997423340 sage/server/notebook/template.py
    a b  
    3232
    3333# Define variables for each template
    3434G = globals()
    35 templates = ['login', 'yes_no', 'registration']
     35templates = ['login', 'yes_no', 'registration', 'account_settings']
    3636for name in templates:
    3737    G[name] =  PageTemplate('%s.html'%name)
  • new file sage/server/notebook/templates/account_settings.html

    diff -r c6bf3105ffa9 -r db0997423340 sage/server/notebook/templates/account_settings.html
    - +  
     1{% extends "base.html" %}
     2
     3{% block title %}Account Settings{% endblock %}
     4{% block css %}account_settings{% endblock %}
     5
     6{% block content %}
     7<h1>Account Settings</h1>
     8
     9  <form method="post" action="/settings">
     10   
     11    <div class="section">
     12      <h2>Change Auto-Save Interval</h2>
     13      <div>
     14          {{ autosave }}
     15        Minutes:
     16        <select name="autosave">
     17        {% for i, selected in autosave_intervals %}
     18          <option{{ selected }}>{{ i }}</option>
     19        {% endfor %}
     20        </select>
     21      </div>
     22    </div>
     23    <div class="section">
     24      <h2>Change Password</h2>
     25      <div id="passwd">
     26        Old password: <input type="password" name="Oldpass" /><br />
     27        New password: <input type="password" name="Newpass" /><br />
     28        Retype new password: <input type="password" name="RetypePass" />
     29      </div>
     30    </div>
     31
     32    {% if email %}
     33        <div class="section">
     34          <h2>Change E-mail Address</h2>
     35   
     36          <div>
     37            <table style="float:right"><tr><td>Current e-mail:</td><td>{{ email_address }}</td></tr>
     38            <tr><td></td><td>{{ email_confirmed }}</td></tr>
     39            <tr><td style="text-align:right">New e-mail:</td><td><input type="text" name="Newemail" class="c1" /></td></tr></table>
     40            <div style="clear:both"></div>
     41          </div>
     42        </div>
     43        {% endif %}
     44    <div id="buttons">
     45    <input type="submit" value="Save">
     46    <input type="button" value="Cancel" style="margin-left:5px" onClick="parent.location='/home/{{ username }}'">   
     47    </div>
     48  </form>
     49{% endblock %}
     50 No newline at end of file
  • deleted file sage/server/notebook/templates/register.html

    diff -r c6bf3105ffa9 -r db0997423340 sage/server/notebook/templates/register.html
    + -  
    1 {% extends "base.html" %}
    2 
    3 {% block title %}Sign up{% endblock %}
    4 
    5 {% block content %}
    6 <div id="wrapper">
    7 <h1>Sign up for a Sage Notebook account</h1>
    8 $error
    9 <form method="POST" action="/register">
    10 <ol>
    11 <li><h2>Create a username</h2>
    12 <p>Your username must start with a letter and be between 4 and 32 characters long. You may only use letters, numbers, underscores, and one dot (.).</p>
    13 <input type="text" name="username" value="{{ username }}" class="entry" />
    14 {% if username_error %}
    15 
    16 {% endif %}
    17 </li>
    18 <li><h2>Create a good password</h2>
    19 <p>Your password must be between 6 and 32 characters long. Your password can not contain your username nor spaces.</p>
    20 <input type="password" name="password" class="entry" />
    21 {% if password_error %}
    22 
    23 {% endif %}
    24 </li>
    25 <li><h2>Re-type your password</h2>
    26 <input type="password" name="retype_password" class="entry" />
    27 {% if confirm_pass_error %}
    28 
    29 {% endif %}
    30 </li>
    31 $email_box
    32 </ol>
    33 <input type="submit" value="Create account" class="button" />
    34 <input type="button" value="Cancel" style="margin-left:10px" onClick="parent.location='/'" class="button" />
    35 </form>
    36 </div>
    37 {% endblock %}
    38  No newline at end of file
  • sage/server/notebook/twist.py

    diff -r c6bf3105ffa9 -r db0997423340 sage/server/notebook/twist.py
    a b  
    915915            elif request.args['Newpass'][0] != request.args['RetypePass'][0]:
    916916                error = 'The passwords you entered do not match.'
    917917           
    918             if not error: #webbrowser may auto fill in "old password" even though the user may nto want to change her passwords   
     918            if not error: #webbrowser may auto fill in "old password" even though the user may not want to change her password
    919919                notebook.change_password(self.username, request.args['Newpass'][0])
    920920                redirect_to_logout = True
    921921        if notebook.conf()['email']:
     
    932932        if redirect_to_home:
    933933            return http.RedirectResponse('/home/%s' % self.username)
    934934       
    935         s = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    936     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    937 
    938 <html xmlns="http://www.w3.org/1999/xhtml">
    939 <head>
    940   <title>Account Settings</title>
    941 <style type="text/css">
    942 /*<![CDATA[*/
    943   @import url('/css/reset.css');
    944  
    945   html {
    946 font-size:100.1%
    947 }
    948  
    949   body {
    950     font:100%/1.4 Arial, Helvetica, sans-serif;
    951   }
    952   h1 {
    953     font-size:2em;
    954     padding:0 5px;
    955     background:#DCDCDC;
    956     border-bottom:1px solid #CCC;
    957   }
    958   #buttons {
    959     padding:5px;
    960     background:#DCDCDC
    961   }
    962   h2 {
    963     font-size:1.5em
    964   }
    965   .section {
    966     padding:5px;
    967     border-bottom:1px solid #CCC;
    968   }
    969   .section > div {
    970     text-align:right;
    971     max-width:350px;
    972   }
    973   td {padding-left:5px}
    974 /*]]>*/
    975 </style>
    976 <style type="text/css">
    977 /*<![CDATA[*/
    978  input.c1 {width:200px}
    979 /*]]>*/
    980 </style>
    981 </head>
    982 
    983 <body>
    984   <h1>Account Settings</h1>
    985 
    986   <form method="post" action="/settings">
    987    
    988     <div class="section">
    989       <h2>Change Auto-Save Interval</h2>
    990       <div>
    991 Minutes: <select name="autosave">
    992       """
    993         for i in range(1, 10, 2):
    994             s += '<option%s>%s</option>' % (' selected' if notebook.user(self.username)['autosave_interval']/60 == i else '', i)
    995         s += '</select></div></div>'
    996         if notebook.conf()['email']:
    997             email_section = """
    998             <div class="section">
    999           <h2>Change E-mail Address</h2>
    1000    
    1001           <div>
    1002             <table style="float:right"><tr><td>Current e-mail:</td><td>%s</td></tr>
    1003             <tr><td></td><td>%s</td></tr>
    1004             <tr><td style="text-align:right">New e-mail:</td><td><input type="text" name="Newemail" class="c1" /></td></tr></table>
    1005             <div style="clear:both"></div>
    1006           </div>
    1007         </div>
    1008             """ % ('None' if notebook.user(self.username)._User__email == '' else notebook.user(self.username)._User__email, 'Not confirmed' if not notebook.user(self.username).is_email_confirmed() else 'Confirmed')
    1009         else: email_section = ''
    1010         s += """
    1011     <div class="section">
    1012       <h2>Change Password</h2>
    1013       <div id="passwd">
    1014         Old password: <input type="password" name="Oldpass" /><br />
    1015         New password: <input type="password" name="Newpass" /><br />
    1016         Retype new password: <input type="password" name="RetypePass" />
    1017       </div>
    1018     </div>
    1019 
    1020     %s
    1021     <div id="buttons">
    1022     <input type="submit" value="Save">""" % email_section
    1023         s += '<input type="button" value="Cancel" style="margin-left:5px" onClick="parent.location=\'/home/%s\'">' % self.username
    1024         s += """   
    1025     </div>
    1026   </form>
    1027 </body>
    1028 </html>
    1029 """
    1030         return http.Response(stream=s)
     935        template_dict = {}
     936        template_dict['autosave_intervals'] = ((i, ' selected') if notebook.user(self.username)['autosave_interval']/60 == i else (i, '') for i in range(1, 10, 2))
     937        template_dict['email'] = notebook.conf()['email']
     938        if template_dict['email']:
     939            template_dict['email_address'] = 'None' if not notebook.user(self.username)._User__email else notebook.user(self.username)._User__email
     940            template_dict['email_confirmed'] = 'Not confirmed' if not notebook.user(self.username).is_email_confirmed() else 'Confirmed'
     941        return http.Response(stream=template.account_settings(**template_dict))
    1031942
    1032943########################################################
    1033944# Set output type of a cell