Ticket #3937: sage-3937_1.patch

File sage-3937_1.patch, 5.0 KB (added by Timothy Clemans, 14 years ago)
  • sage/server/notebook/template.py

    # HG changeset patch
    # User Timothy Clemans <timothy.clemans@gmail.com>
    # Date 1219662478 25200
    # Node ID aa016698c71abcd2cd0217069677d7021b3ef81a
    # Parent  758e810565059c533029db42a4abaad2b678716f
    #3937 1
    
    diff -r 758e81056505 -r aa016698c71a sage/server/notebook/template.py
    a b  
    3131
    3232# Define variables for each template
    3333G = globals()
    34 templates = ['login', 'yes_no', 'registration']
     34templates = ['login', 'yes_no', 'registration', 'account_settings']
    3535for name in templates:
    3636    G[name] =  PageTemplate('%s.html'%name)
     37 No newline at end of file
  • sage/server/notebook/twist.py

    diff -r 758e81056505 -r aa016698c71a sage/server/notebook/twist.py
    a b  
    884884            elif request.args['Newpass'][0] != request.args['RetypePass'][0]:
    885885                error = 'The passwords you entered do not match.'
    886886           
    887             if not error: #webbrowser may auto fill in "old password" even though the user may nto want to change her passwords   
     887            if not error: #webbrowser may auto fill in "old password" even though the user may not want to change her password
    888888                notebook.change_password(self.username, request.args['Newpass'][0])
    889889                redirect_to_logout = True
    890890        if notebook.conf()['email']:
     
    901901        if redirect_to_home:
    902902            return http.RedirectResponse('/home/%s' % self.username)
    903903       
    904         s = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    905     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    906 
    907 <html xmlns="http://www.w3.org/1999/xhtml">
    908 <head>
    909   <title>Account Settings</title>
    910 <style type="text/css">
    911 /*<![CDATA[*/
    912   @import url('/css/reset.css');
    913  
    914   html {
    915 font-size:100.1%
    916 }
    917  
    918   body {
    919     font:100%/1.4 Arial, Helvetica, sans-serif;
    920   }
    921   h1 {
    922     font-size:2em;
    923     padding:0 5px;
    924     background:#DCDCDC;
    925     border-bottom:1px solid #CCC;
    926   }
    927   #buttons {
    928     padding:5px;
    929     background:#DCDCDC
    930   }
    931   h2 {
    932     font-size:1.5em
    933   }
    934   .section {
    935     padding:5px;
    936     border-bottom:1px solid #CCC;
    937   }
    938   .section > div {
    939     text-align:right;
    940     max-width:350px;
    941   }
    942   td {padding-left:5px}
    943 /*]]>*/
    944 </style>
    945 <style type="text/css">
    946 /*<![CDATA[*/
    947  input.c1 {width:200px}
    948 /*]]>*/
    949 </style>
    950 </head>
    951 
    952 <body>
    953   <h1>Account Settings</h1>
    954 
    955   <form method="post" action="/settings">
    956    
    957     <div class="section">
    958       <h2>Change Auto-Save Interval</h2>
    959       <div>
    960 Minutes: <select name="autosave">
    961       """
    962         for i in range(1, 10, 2):
    963             s += '<option%s>%s</option>' % (' selected' if notebook.user(self.username)['autosave_interval']/60 == i else '', i)
    964         s += '</select></div></div>'
    965         if notebook.conf()['email']:
    966             email_section = """
    967             <div class="section">
    968           <h2>Change E-mail Address</h2>
    969    
    970           <div>
    971             <table style="float:right"><tr><td>Current e-mail:</td><td>%s</td></tr>
    972             <tr><td></td><td>%s</td></tr>
    973             <tr><td style="text-align:right">New e-mail:</td><td><input type="text" name="Newemail" class="c1" /></td></tr></table>
    974             <div style="clear:both"></div>
    975           </div>
    976         </div>
    977             """ % ('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')
    978         else: email_section = ''
    979         s += """
    980     <div class="section">
    981       <h2>Change Password</h2>
    982       <div id="passwd">
    983         Old password: <input type="password" name="Oldpass" /><br />
    984         New password: <input type="password" name="Newpass" /><br />
    985         Retype new password: <input type="password" name="RetypePass" />
    986       </div>
    987     </div>
    988 
    989     %s
    990     <div id="buttons">
    991     <input type="submit" value="Save">""" % email_section
    992         s += '<input type="button" value="Cancel" style="margin-left:5px" onClick="parent.location=\'/home/%s\'">' % self.username
    993         s += """   
    994     </div>
    995   </form>
    996 </body>
    997 </html>
    998 """
    999         return http.Response(stream=s)
     904        template_dict = {}
     905        template_dict['autosave_intervals'] = ((i, ' selected') if notebook.user(self.username)['autosave_interval']/60 == i else (i, '') for i in range(1, 10, 2))
     906        template_dict['email'] = notebook.conf()['email']
     907        if template_dict['email']:
     908            template_dict['email_address'] = 'None' if not notebook.user(self.username)._User__email else notebook.user(self.username)._User__email
     909            template_dict['email_confirmed'] = 'Not confirmed' if not notebook.user(self.username).is_email_confirmed() else 'Confirmed'
     910        return http.Response(stream=template.account_settings(**template_dict))
    1000911
    1001912########################################################
    1002913# Set output type of a cell