Commit 60ebca09 authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Cleaned up signup page.

parent 71fb6610
......@@ -7,42 +7,11 @@ import goconfig
def application(environ, start_response):
# Construct the default body, along with its header/footer wrapper.
body = []
f = open(goconfig.doc_root + "/site_data/top.part", "r")
top_part = f.read()
f.close()
f = open(goconfig.doc_root + "/site_data/bottom.part", "r")
bottom_part = f.read()
f.close()
post = environ["REQUEST_METHOD"] == "POST"
body = ["Nothing here."]
if post:
# Grab user data, cut off non-relevant fields.
data = environ['wsgi.input']
data = library.parse_post_data( data )
user = data['user'].strip().replace('+',' ').lower()
name = data['name'].strip().replace('+',' ')
desc = data['desc'].strip().replace('+',' ')
if len(user) > 0 and len(name) > 0 and len(desc) > 0:
if library.register_user( user, name, desc ):
body = ["<h3>~Sign Up for Use~</h3>"]
body.append("<p>Application success! Please wait for moderator ")
body.append("approval before using this service.<br/><br/></p>")
else:
body = ["<h3>~Error~</h3>"]
body.append("<p>That username is already registered!<br/><br/></p>")
else:
body = ["<h3>~Error~</h3>"]
body.append("<p>Please complete all forms before submitting.<br/><br/></p>")
else:
body = ["""
signup_form = """
<h3>~Sign Up for Use~</h3>
<form action="" method="post">
<form action="/signup" method="post">
<label for="user">username (NetID)</label>
<br /><br />
......@@ -66,10 +35,48 @@ def application(environ, start_response):
<a href="http://srct.gmu.edu/usage-policy">SRCT Usage Policy</a>.</p>
</form>
"""]
"""
if not (environ["REQUEST_METHOD"] == "POST"):
body = []
body.append( signup_form )
else:
# Grab user data, cut off non-relevant fields.
data = environ['wsgi.input']
data = library.parse_post_data( data )
user = data['user'].strip().replace('+',' ').lower()
name = data['name'].strip().replace('+',' ')
desc = data['desc'].strip().replace('+',' ')
if len(user) > 0 and len(name) > 0 and len(desc) > 0:
if library.register_user( user, name, desc ):
body = []
body.append("<h3>~Sign Up for Use~</h3>")
body.append("<p>Application success! Please wait for moderator ")
body.append("approval before using this service.<br/><br/></p>")
else:
body = []
body.append("<h3>~Error~</h3>")
body.append("<p>That username is already registered!<br/><br/></p>")
else:
body = []
body.append("<h3>~Error~</h3>")
body.append("<p>Please complete all forms before submitting.<br/><br/></p>")
f = open(goconfig.doc_root + "/site_data/top.part", "r")
top = f.read()
f.close()
f = open(goconfig.doc_root + "/site_data/bottom.part", "r")
bottom = f.read()
f.close()
body = ''.join( body )
response = top_part + body + bottom_part
response = top + body + bottom
status = '200 OK'
response_headers = [('Content-type', 'text/html'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment