Gussy up register.py

This commit is contained in:
Neale Pickett 2009-10-07 10:38:30 -06:00
parent bb3cf22005
commit 4f3c7190d4
1 changed files with 23 additions and 16 deletions

View File

@ -7,6 +7,22 @@ import string
from . import teams from . import teams
from . import config from . import config
def head(title):
return '''<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Team Registration</title>
<link rel="stylesheet" href="%s" type="text/css" />
</head>
<body>
<h1>%s</h1>
''' % (config.css, title)
def foot():
return '''</body></html>'''
def main(): def main():
print('Content-type: text/html') print('Content-type: text/html')
print() print()
@ -17,17 +33,8 @@ def main():
pw = f.getfirst('pw') pw = f.getfirst('pw')
confirm_pw = f.getfirst('confirm_pw') confirm_pw = f.getfirst('confirm_pw')
html = string.Template('''<?xml version="1.0" encoding="UTF-8" ?> html = string.Template(head('Team Registration') +
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ('''
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Team Registration</title>
<link rel="stylesheet" href="%s" type="text/css" />
</head>
<body>
<h1>Team Registration</h1>
<p> <p>
Pick a short team name: you'll be typing it a lot. Pick a short team name: you'll be typing it a lot.
</p> </p>
@ -50,10 +57,8 @@ def main():
<input type="submit" value="Register" /> <input type="submit" value="Register" />
</fieldset> </fieldset>
</form> </form>''' % config.url('register.cgi')) +
</body> foot())
</html>
''' % (config.css, config.url('register.cgi')))
if not (team and pw and confirm_pw): # If we're starting from the beginning? if not (team and pw and confirm_pw): # If we're starting from the beginning?
html = html.substitute(team_error='', html = html.substitute(team_error='',
@ -66,7 +71,9 @@ def main():
pw_match_error='Passwords do not match') pw_match_error='Passwords do not match')
else: else:
teams.add(team, pw) teams.add(team, pw)
html = 'Team registered.' html = (head('Team registered') +
('<p>Congratulations, <samp>%s</samp> is now registered. Go <a href="%s">back to the front page</a> and start playing!</p>' % (team, config.url(''))) +
foot())
print(html) print(html)