Skip to content
Snippets Groups Projects
Commit e43bc7e8 authored by aebopp's avatar aebopp
Browse files

edit tutor info

parent f74224e0
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
} }
.su { .su {
float: right; text-align:center;
} }
/* Clear floats */ /* Clear floats */
...@@ -74,10 +74,6 @@ ...@@ -74,10 +74,6 @@
<a href="/">Home</a> <a href="/">Home</a>
<title>ServicePoints</title> <title>ServicePoints</title>
<div class="su">
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto; right: 35px">Sign Up</button>
</div>
<div id="id01" class="modal"> <div id="id01" class="modal">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span> <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span>
<form class="modal-content" action="/accounts/tutorsu/" method="post"> <form class="modal-content" action="/accounts/tutorsu/" method="post">
...@@ -95,8 +91,11 @@ ...@@ -95,8 +91,11 @@
<input type="text" placeholder="Enter Times" name="time" required> <input type="text" placeholder="Enter Times" name="time" required>
<div class="clearfix"> <div class="clearfix">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button> <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<button type="submit" class="signup">Sign Up</button> <form action="/accounts/tutor/" method="post">
<input type="submit" class="signup" name="sign" value="Sign Up" />
</form>
</div> </div>
</div> </div>
</form> </form>
...@@ -106,8 +105,24 @@ ...@@ -106,8 +105,24 @@
<h1>Welcome to the Service Points Tutoring page!</h1> <h1>Welcome to the Service Points Tutoring page!</h1>
{% if registered == 0 %}
<p>Search through our database of current tutors or sign up to have your name and information listed.</p> <p>Search through our database of current tutors or sign up to have your name and information listed.</p>
<div class="su">
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto; right: 35px">Sign Up</button>
</div>
{% endif %}
{% if registered == 1 %}
<p>Search through our database of current tutors or edit your listed information.</p>
<div class="su">
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto; right: 35px">Edit Information</button>
<button value='delete' type="submit" class="signup">Delete Profile</button>
</div>
{% endif %}
<h3>Name, Subject(s), Time, Email</h3> <h3>Name, Subject(s), Time, Email</h3>
<p> <p>
{% for tutor, user in zip(tutors, tutorsN) %} {% for tutor, user in zip(tutors, tutorsN) %}
......
No preview for this file type
...@@ -437,32 +437,43 @@ def images(filename): ...@@ -437,32 +437,43 @@ def images(filename):
def tutorsu(): def tutorsu():
if flask.request.method == 'POST': if flask.request.method == 'POST':
if 'sign' in flask.request.form:
flask.session['subjects'] = flask.request.form['subjects'] flask.session['subjects'] = flask.request.form['subjects']
flask.session['time'] = flask.request.form['time'] flask.session['time'] = flask.request.form['time']
cursor = servicePoints.model.get_db().cursor() cursor = servicePoints.model.get_db().cursor()
name = str(flask.session['username']) name = str(flask.session['username'])
to_add = (name,) # If a user tries to sign up with any empty fields
cursor.execute('SELECT * FROM tutors WHERE username=?', to_add) if flask.session['time'] == '':
if cursor.fetchone() is not None: return flask.redirect(flask.url_for('incompleteForm', prev="tutorsu"))
return flask.redirect(flask.url_for('duplicateTutor')) if flask.session['subjects'] == '':
return flask.redirect(flask.url_for('incompleteForm', prev="tutorsu"))
# If a user tries to sign up with any empty fields data = (flask.session['username'], flask.session['subjects'],
if flask.session['time'] == '': 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')) to_add = (name,)
cursor.execute('SELECT * FROM tutors WHERE username=?', to_add)
if cursor.fetchone() is not None:
cur = servicePoints.model.get_db()
cur.execute("UPDATE tutors SET username = ?, subject=?, time=?", data)
else:
cur = servicePoints.model.get_db()
cur.execute("INSERT INTO tutors(username, subject, time) VALUES (?, ?, ?)", data)
cursor = servicePoints.model.get_db() return flask.redirect(flask.url_for('tutorsu'))
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:
registered = 1
else:
registered = 0
cursor = servicePoints.model.get_db()
cur = cursor.execute("SELECT subject, time FROM tutors") cur = cursor.execute("SELECT subject, time FROM tutors")
tutors = cur.fetchall() tutors = cur.fetchall()
...@@ -470,7 +481,7 @@ def tutorsu(): ...@@ -470,7 +481,7 @@ def tutorsu():
tutorsN = cur2.fetchall() tutorsN = cur2.fetchall()
# Add database info to context # Add database info to context
context = {"tutors": tutors, "tutorsN": tutorsN} context = {"tutors": tutors, "tutorsN": tutorsN, "registered": registered}
return flask.render_template("tutor.html", **context,zip=zip) return flask.render_template("tutor.html", **context,zip=zip)
@servicePoints.app.route('/accounts/submitPoints/', methods=['GET', 'POST']) @servicePoints.app.route('/accounts/submitPoints/', methods=['GET', 'POST'])
......
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