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

Added tutoring database and sign up page

parent 0cb5f24b
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/style.css">
<title>ServicePoints</title>
</head>
<body>
<p>
You have already signed up for tutoring
</p>
<form action="/accounts/duplicateTutor/" method="post" enctype="multipart/form-data">
<input type="submit" name="return" value="Return to Home" />
</form>
</body>
</html>
......@@ -18,8 +18,8 @@
<a href="/accounts/mask/">
<img src=/images/food.png alt="mask">
</a>
<a href="/accounts/mask/">
<img src=/images/tutor.png alt="mask">
<a href="/accounts/tutorsu/">
<img src=/images/tutor.png alt="tutorsu">
</a>
<a href="/accounts/mask/">
<img src=/images/submit.png alt="mask">
......
<!DOCTYPE html>
<html>
<body>
<a href="/">Home</a>
<title>ServicePoints</title>
<form action="/accounts/tutorsu/" method="post" enctype="multipart/form-data">
<p>
Full Name
<input type="text" name="username" />
</p>
<p>
Tutuoring Subject(s):
<input type="text" name="subjects" />
</p>
<p>
Available times
<input type="text" name="time" />
</p>
<input type="submit" name="signup" value="sign up" />
</form>
</body>
</html>
No preview for this file type
No preview for this file type
......@@ -229,6 +229,13 @@ def duplicateOrgName():
context = {}
return render_template('duplicateOrgName.html', **context)
@servicePoints.app.route('/accounts/duplicateTutor/', methods=['GET', 'POST'])
def duplicateTutor():
if flask.request.method == 'POST':
return flask.redirect(flask.url_for('tutor'))
context = {}
return render_template('duplicateTutor.html', **context)
@servicePoints.app.route('/accounts/incompleteForm/<prev>', methods=['GET', 'POST'])
def incompleteForm(prev):
if flask.request.method == 'POST':
......@@ -247,3 +254,34 @@ def images(filename):
return flask.send_from_directory(
servicePoints.app.config['IMAGES_FOLDER'], filename, as_attachment=True)
return flask.redirect(flask.url_for('login'))
@servicePoints.app.route('/accounts/tutorsu/', methods=['GET', 'POST'])
def tutorsu():
if flask.request.method == 'POST':
flask.session['subjects'] = flask.request.form['subjects']
flask.session['time'] = flask.request.form['time']
cursor = servicePoints.model.get_db().cursor()
name = str(flask.session['username'])
to_add = (name,)
cursor.execute('SELECT * FROM tutors WHERE username=?', to_add)
if cursor.fetchone() is not None:
return flask.redirect(flask.url_for('duplicateTutor'))
# If a user tries to sign up with any empty fields
if flask.session['time'] == '':
return flask.redirect(flask.url_for('incompleteForm', prev="tutorsu"))
if flask.session['subjects'] == '':
return flask.redirect(flask.url_for('incompleteForm', prev="tutorsu"))
data = (flask.session['username'], flask.session['subjects'],
flask.session['time'])
cur = servicePoints.model.get_db()
cur.execute("INSERT INTO tutors(username, subject, time) VALUES (?, ?, ?)", data)
return flask.redirect(flask.url_for('index'))
context = {}
return render_template('tutor.html', **context)
\ No newline at end of file
......@@ -14,4 +14,12 @@ CREATE TABLE orgs(
username VARCHAR(20) NOT NULL,
orgName VARCHAR(40) NOT NULL,
PRIMARY KEY(orgName)
);
CREATE TABLE tutors(
username VARCHAR(20) NOT NULL,
subject VARCHAR(40) NOT NULL,
time VARCHAR(80) NOT NULL,
PRIMARY KEY(username)
);
\ No newline at end of file
No preview for this file type
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