Skip to content
Snippets Groups Projects
Commit f1e3daf2 authored by mrschnei's avatar mrschnei
Browse files

Users no longer need to sign up with an Org and can change Org in User Profile

parent 8adc4c22
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html>
<body>
<title>ServicePoints</title>
<p>
Want to register an organization with your new account account?
<a href="/accounts/createOrg/">Register as organization leader</a>
</p>
<form action="/accounts/create/" method="post" enctype="multipart/form-data">
<p>
Student Organization
<input type="text" name="orgName"/>
</p>
<p>
Your Name
<input type="text" name="fullname"/>
</p>
<title>ServicePoints</title>
<p>
Username
<input type="text" name="username"/>
</p>
<p>
Email
<input type="text" name="email"/>
</p>
Want to register an organization with your new account account?
<a href="/accounts/createOrg/">Register as organization leader</a>
</p>
<form action="/accounts/create/" method="post" enctype="multipart/form-data">
<p>
<label for="orgName">Select an Organization:</label>
<select name="orgName" id="orgName">
<option value="NONE">Choose Later</option>
{% for org in orgs %}
<option value="{{org.orgName}}">{{org.orgName}}</option>
{% endfor %}
</select>
</p>
<p>
Your Name
<input type="text" name="fullname" />
</p>
<p>
Username
<input type="text" name="username" />
</p>
<p>
Email
<input type="text" name="email" />
</p>
<p>
Password
<input type="password" name="password" />
</p>
<input type="submit" name="signup" value="sign up" />
</form>
<p>
Password
<input type="password" name="password"/>
Have an account?
<a href="/accounts/login/">Log in</a>
</p>
<input type="submit" name="signup" value="sign up"/>
</form>
<p>
Have an account?
<a href="/accounts/login/">Log in</a>
</p>
</body>
</html>
......@@ -12,7 +12,17 @@
<a href="/accounts/logout/">logout</a>
<a href="/accounts/delete/">delete</a>
<form action="/accounts/profile/" method="post">
<p>
<label for="orgName">Select an Organization:</label>
<select name="orgName" id="orgName">
{% for org in orgs %}
<option value="{{org.orgName}}">{{org.orgName}}</option>
{% endfor %}
</select>
</p>
<input type="submit" name="signup" value="Update Org" />
</form>
</body>
......
......@@ -73,11 +73,8 @@ def create():
if len(str(flask.request.form['password'])) is 0 or len(str(flask.request.form['fullname'])) is 0:
return flask.redirect(flask.url_for('incompleteForm', prev="create"))
if len(str(flask.request.form['orgName'])) is 0 or len(str(flask.request.form['email'])) is 0:
if len(str(flask.request.form['username'])) is 0 or len(str(flask.request.form['email'])) is 0:
return flask.redirect(flask.url_for('incompleteForm', prev="create"))
if len(str(flask.request.form['username'])) is 0:
return flask.redirect(flask.url_for('incompleteForm', prev="create"))
flask.session['username'] = flask.request.form['username']
flask.session['fullname'] = flask.request.form['fullname']
......@@ -95,7 +92,11 @@ def create():
return flask.redirect(flask.url_for('index'))
context = {}
cursor = servicePoints.model.get_db()
cur = cursor.execute("SELECT * FROM orgs")
orgs = cur.fetchall()
context = {"orgs": orgs}
return render_template('create.html', **context)
@servicePoints.app.route('/accounts/createOrg/', methods=['GET', 'POST'])
......@@ -263,9 +264,21 @@ def food():
context = {}
return render_template('food.html', **context)
@servicePoints.app.route('/accounts/profile/')
@servicePoints.app.route('/accounts/profile/', methods=['GET', 'POST'])
def profile():
context = {}
if flask.request.method == 'POST':
orgName = str(flask.request.form['orgName'])
cur = servicePoints.model.get_db()
cur.execute('UPDATE users SET orgName = ? WHERE username = ?',
(orgName, flask.session['username']))
return flask.redirect(flask.url_for('index'))
cursor = servicePoints.model.get_db()
cur = cursor.execute("SELECT * FROM orgs")
orgs = cur.fetchall()
context = {"orgs": orgs}
return render_template('userProfile.html', **context)
@servicePoints.app.route('/images/<path:filename>', methods=['GET', 'POST'])
......@@ -310,8 +323,7 @@ def tutorsu():
username = flask.session["username"]
cur2 = cursor.execute('SELECT email FROM users WHERE '
'username =:who',
{"who": username})
'username =:who', {"who": username})
emails = cur2.fetchall()
# Add database info to context
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment