mirror of https://github.com/dirtbags/moth.git
Gussy up register.py
This commit is contained in:
parent
bb3cf22005
commit
4f3c7190d4
|
@ -7,6 +7,22 @@ import string
|
|||
from . import teams
|
||||
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():
|
||||
print('Content-type: text/html')
|
||||
print()
|
||||
|
@ -17,17 +33,8 @@ def main():
|
|||
pw = f.getfirst('pw')
|
||||
confirm_pw = f.getfirst('confirm_pw')
|
||||
|
||||
html = string.Template('''<?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>Team Registration</h1>
|
||||
|
||||
html = string.Template(head('Team Registration') +
|
||||
('''
|
||||
<p>
|
||||
Pick a short team name: you'll be typing it a lot.
|
||||
</p>
|
||||
|
@ -50,10 +57,8 @@ def main():
|
|||
|
||||
<input type="submit" value="Register" />
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
''' % (config.css, config.url('register.cgi')))
|
||||
</form>''' % config.url('register.cgi')) +
|
||||
foot())
|
||||
|
||||
if not (team and pw and confirm_pw): # If we're starting from the beginning?
|
||||
html = html.substitute(team_error='',
|
||||
|
@ -66,7 +71,9 @@ def main():
|
|||
pw_match_error='Passwords do not match')
|
||||
else:
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue