Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
60ebca09
Commit
60ebca09
authored
Nov 08, 2013
by
Jean Michel Rouly
Browse files
Cleaned up signup page.
parent
71fb6610
Changes
1
Hide whitespace changes
Inline
Side-by-side
wsgi/signup.py
View file @
60ebca09
...
...
@@ -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'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment