diff --git a/servicePoints/__pycache__/__init__.cpython-36.pyc b/servicePoints/__pycache__/__init__.cpython-36.pyc index ae8c520b2453458e48760c1786f565c6eb628aac..b890e80cc2b9d8fb67beb2525dc9b78ddd312088 100644 Binary files a/servicePoints/__pycache__/__init__.cpython-36.pyc and b/servicePoints/__pycache__/__init__.cpython-36.pyc differ diff --git a/servicePoints/__pycache__/config.cpython-36.pyc b/servicePoints/__pycache__/config.cpython-36.pyc index e2f47fdc2b33a9855315f2cf9e0a9c0260d21cf5..b66ba84188a594b21aaafed82eaf48f9bd9e303e 100644 Binary files a/servicePoints/__pycache__/config.cpython-36.pyc and b/servicePoints/__pycache__/config.cpython-36.pyc differ diff --git a/servicePoints/__pycache__/model.cpython-36.pyc b/servicePoints/__pycache__/model.cpython-36.pyc index 987ba06aecd14df951ced9f5575b13c29be1c283..86bb7b3a23476b2371ea8739ac81138b684f2091 100644 Binary files a/servicePoints/__pycache__/model.cpython-36.pyc and b/servicePoints/__pycache__/model.cpython-36.pyc differ diff --git a/servicePoints/templates/duplicateTutor.html b/servicePoints/templates/duplicateTutor.html new file mode 100644 index 0000000000000000000000000000000000000000..68478dca6c94b4a073f8e9d7476ec8556be7a433 --- /dev/null +++ b/servicePoints/templates/duplicateTutor.html @@ -0,0 +1,16 @@ +<!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> diff --git a/servicePoints/templates/index.html b/servicePoints/templates/index.html index 38f815182d8e99cee2fee0effa298b4da4ea7878..cae455973550683014d2d63bf0b5d577cef1df7e 100644 --- a/servicePoints/templates/index.html +++ b/servicePoints/templates/index.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"> diff --git a/servicePoints/templates/tutor.html b/servicePoints/templates/tutor.html new file mode 100644 index 0000000000000000000000000000000000000000..1ac13052b76beb67d3ad3daad3c5869b38eff840 --- /dev/null +++ b/servicePoints/templates/tutor.html @@ -0,0 +1,22 @@ +<!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> diff --git a/servicePoints/views/__pycache__/__init__.cpython-36.pyc b/servicePoints/views/__pycache__/__init__.cpython-36.pyc index 1d30055a28038c24f70515e1ec1990883944f38d..180037e3f49e55ada44d0f5f95254730be1535b7 100644 Binary files a/servicePoints/views/__pycache__/__init__.cpython-36.pyc and b/servicePoints/views/__pycache__/__init__.cpython-36.pyc differ diff --git a/servicePoints/views/__pycache__/accounts.cpython-36.pyc b/servicePoints/views/__pycache__/accounts.cpython-36.pyc index 865419fc28b3340d4bb6e9312e8ea0508d78d314..29b95f49454f3040969bbf9ac5eaff5f61fc6be4 100644 Binary files a/servicePoints/views/__pycache__/accounts.cpython-36.pyc and b/servicePoints/views/__pycache__/accounts.cpython-36.pyc differ diff --git a/servicePoints/views/accounts.py b/servicePoints/views/accounts.py index e42976a4ea3967a269a80ce9853e43c3321e7d91..055fd37de57cc0b0650d85c318a628c8f7df826d 100644 --- a/servicePoints/views/accounts.py +++ b/servicePoints/views/accounts.py @@ -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 diff --git a/sql/schema.sql b/sql/schema.sql index cf8c4be358d347da9c7ccf3bb92779695c01c261..74cd21f483ee9512aa8b4e43b40795e7723f5800 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -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 diff --git a/var/servicePoints.sqlite3 b/var/servicePoints.sqlite3 index 12b075764feae87c8ab17d440739fe167aa7a16e..6a0e7d9205f2272c6ae9612c83e0fd77dd25e5fe 100644 Binary files a/var/servicePoints.sqlite3 and b/var/servicePoints.sqlite3 differ