diff --git a/servicePoints/templates/hourError.html b/servicePoints/templates/hourError.html new file mode 100644 index 0000000000000000000000000000000000000000..61628d15814ca117fb6c29b5423025536ae3d064 --- /dev/null +++ b/servicePoints/templates/hourError.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/style.css"> + <title>ServicePoints</title> + </head> + + <body> + <p> + Please submit the numerical form of the number of hours you'd like to assign: + 1, 2, 3, 4, ... + </p> + <form action="/accounts/hourError/" method="post" enctype="multipart/form-data"> + <input type="submit" name="return" value="Return to View Member Requests"/> + </form> + </body> +</html> diff --git a/servicePoints/templates/index.html b/servicePoints/templates/index.html index 52cf883bfcd36f94c6388281f77cae7bf17ea8a7..f0c4ffcff6a81a517155f4ba8bf067427aeb574b 100644 --- a/servicePoints/templates/index.html +++ b/servicePoints/templates/index.html @@ -78,10 +78,10 @@ {% if leader == 1 %} <a href="/accounts/viewMemberPoints/"> - <img src=/images/view.png alt="mask"> + <img src=/images/view.png alt="view"> </a> - <a href="/accounts/mask/"> - <img src=/images/requests.png alt="mask"> + <a href="/accounts/viewRequests/"> + <img src=/images/requests.png alt="requests"> </a> {% endif %} </p> diff --git a/servicePoints/templates/viewRequests.html b/servicePoints/templates/viewRequests.html new file mode 100644 index 0000000000000000000000000000000000000000..0fdfe3e8d00a6288b1d7e58450bdb0e311801c7a --- /dev/null +++ b/servicePoints/templates/viewRequests.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> + <head> + <a href="/">Home</a> + </head> +<body> + <title>ServicePoints</title> + <p> + {{org}} members' requests: + </p> + {% for request in requests %} + <p> + {{request.member}} is requesting ServicePoints for ({{request.service}}): + </p> + <p> + <img src=/images/{{request.filename}} alt="img"> + </p> + <p> + Enter the number of hours you'd like to assign in it's numerical form (1, 2, 3...): + <form action="/accounts/viewRequests/" method="post" enctype="multipart/form-data"> + <input type="hidden" name="postid" value="{{request.postid}}"/> + <input type="hidden" name="user" value="{{request.member}}"/> + <input type="text" name="numHours" /> + <input type="submit" name="confirm" value="confirm"/> + </form> + Please give an explanation as to why you're denying this request: + <form action="/accounts/viewRequests/" method="post" enctype="multipart/form-data"> + <input type="hidden" name="postid" value="{{request.postid}}"/> + <input type="text" name="reason" /> + <input type="submit" name = "deny" value="deny" /> + </form> + </p> + {% endfor %} +</body> +</html> diff --git a/servicePoints/views/__pycache__/accounts.cpython-36.pyc b/servicePoints/views/__pycache__/accounts.cpython-36.pyc index a936282d588a76d6f91fe8266db2ec3c2b01c054..b03320044795d6266b104aa0e7e976c03badcd88 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 5da6780e929e230c49ae00f2f9a3f7df4db7326f..ee8fbaecbf9150c447aae1e060586a14545a42b8 100644 --- a/servicePoints/views/accounts.py +++ b/servicePoints/views/accounts.py @@ -172,6 +172,39 @@ def viewMemberPoints(): return render_template('viewMemberPoints.html', **context) return flask.redirect(flask.url_for('login')) +@servicePoints.app.route('/accounts/viewRequests/', methods=['GET', 'POST']) +def viewRequests(): + if 'username' in flask.session: + if flask.request.method == 'POST': + if 'deny' in flask.request.form: + post = flask.request.form["postid"] + servicePoints.model.get_db().execute('DELETE FROM requests WHERE postid =:one ', + {"one": post}) + if 'confirm' in flask.request.form: + try: + numHours = int(flask.request.form["numHours"]) + except: + return flask.redirect(flask.url_for('hourError')) + post = flask.request.form["postid"] + user = flask.request.form["user"] + hours = servicePoints.model.get_db().execute('SELECT hours FROM users WHERE username =:one ', + {"one": user}) + dbHours = hours.fetchone() + dbHours["hours"] += numHours + servicePoints.model.get_db().execute('UPDATE users SET hours =:one WHERE username =:two ', + {"one": dbHours["hours"], "two": user}) + servicePoints.model.get_db().execute('DELETE FROM requests WHERE postid =:one ', + {"one": post}) + + username = flask.session["username"] + cursor = servicePoints.model.get_db() + leaderCur = cursor.execute('SELECT postid, member, service, filename FROM requests WHERE ' + 'leader =:who', + {"who": username}) + results = leaderCur.fetchall() + context = {'requests': results} + return render_template('viewRequests.html', **context) + return flask.redirect(flask.url_for('login')) @servicePoints.app.route('/', methods=['GET', 'POST']) def index(): @@ -253,6 +286,14 @@ def duplicateOrgName(): context = {} return render_template('duplicateOrgName.html', **context) +@servicePoints.app.route('/accounts/hourError/', methods=['GET', 'POST']) +def hourError(): + if flask.request.method == 'POST': + return flask.redirect(flask.url_for('viewRequests')) + context = {} + return render_template('hourError.html', **context) + + @servicePoints.app.route('/accounts/duplicateTutor/', methods=['GET', 'POST']) def duplicateTutor(): if flask.request.method == 'POST': diff --git a/sql/schema.sql b/sql/schema.sql index fab44f6b328d4742195604282e9b35ec874a1358..1e08c1eb640d5e6496aa0642b290e6199f958f70 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -6,7 +6,7 @@ CREATE TABLE users( email VARCHAR(40) NOT NULL, orgName VARCHAR(40) NOT NULL, password VARCHAR(256) NOT NULL, - hours VARCHAR(40) NOT NULL, + hours INTEGER NOT NULL, PRIMARY KEY(username) ); diff --git a/var/servicePoints.sqlite3 b/var/servicePoints.sqlite3 index b6ad11000aa06460c22e48c1bdf775fe143a0fe5..c7704ebcdf577154892ec824ac58a38b738e2d20 100644 Binary files a/var/servicePoints.sqlite3 and b/var/servicePoints.sqlite3 differ