From 00fb55a00e60548a477617dc52bf61073448a9a4 Mon Sep 17 00:00:00 2001
From: mrschnei <mrschnei@umich.edu>
Date: Thu, 16 Jul 2020 14:56:54 -0400
Subject: [PATCH] Updated tutor page

---
 servicePoints/templates/index.html        |  1 +
 servicePoints/templates/submitPoints.html |  2 +-
 servicePoints/templates/tutor.html        | 12 ++++++++----
 servicePoints/views/accounts.py           | 14 ++++----------
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/servicePoints/templates/index.html b/servicePoints/templates/index.html
index 50f2bab..aca9228 100644
--- a/servicePoints/templates/index.html
+++ b/servicePoints/templates/index.html
@@ -52,6 +52,7 @@
         <button onclick="myFunction()" class="dropbtn">Settings</button>
         <div id="myDropdown" class="dropdown-content">
             <a href="/accounts/profile/">Profile</a>
+            <hr />
             <a href="/accounts/logout/">Logout</a>
         </div>
     </div>
diff --git a/servicePoints/templates/submitPoints.html b/servicePoints/templates/submitPoints.html
index cd49ae0..9406729 100644
--- a/servicePoints/templates/submitPoints.html
+++ b/servicePoints/templates/submitPoints.html
@@ -6,7 +6,7 @@
         <p>{{username}}</p>
         <p>{{org}}</p>
         <p>Hours: {{hours}}</p>
-        <a href="/accounts/index/">Back to Homepage</a>
+        <a href="/">Back to Homepage</a>
     </head>   
 
     <form action="/accounts/submitPoints/" method="post" enctype="multipart/form-data">
diff --git a/servicePoints/templates/tutor.html b/servicePoints/templates/tutor.html
index 3903d76..158dd1c 100644
--- a/servicePoints/templates/tutor.html
+++ b/servicePoints/templates/tutor.html
@@ -91,7 +91,7 @@
                 <label for="subjects"><b>Tutoring Subject(s)</b></label>
                 <input type="text" placeholder="Enter Subject(s)" name="subjects" required>
 
-                <label for="time"><b>Available Times</b></label>
+                <label for="time"><b>Available Times (Day of the week: time)</b></label>
                 <input type="text" placeholder="Enter Times" name="time" required>
 
                 <div class="clearfix">
@@ -104,10 +104,14 @@
 
     <hr>
 
-    <h3>Username, Subject, Time, Email</h3>
+    <h1>Welcome to the Service Points Tutoring page!</h1>
+
+    <p>Search through our database of current tutors or sign up to have your name and information listed.</p>
+
+    <h3>Name, Subject(s), Time, Email</h3>
     <p>
-        {% for tutor, email_ in zip(tutors, emails) %}
-        <p>{{tutor.username}}, {{tutor.subject}}, {{tutor.time}}, {{email_.email}}</p>
+        {% for tutor, user in zip(tutors, tutorsN) %}
+        <p>{{user.fullname}}, {{tutor.subject}}, {{tutor.time}}, {{user.email}}</p>
         {% endfor %}
     </p>
 
diff --git a/servicePoints/views/accounts.py b/servicePoints/views/accounts.py
index 73daee0..e1e8f86 100644
--- a/servicePoints/views/accounts.py
+++ b/servicePoints/views/accounts.py
@@ -66,10 +66,6 @@ def create():
         if cursor.fetchone() is not None:
             return flask.redirect(flask.url_for('duplicateUsername', prev='create'))
 
-        cursor.execute('SELECT * FROM orgs WHERE orgName=?', to_join)
-        if cursor.fetchone() is None:
-            return flask.redirect(flask.url_for('orgNotFound'))
-
         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")) 
 
@@ -318,16 +314,14 @@ def tutorsu():
 
     cursor = servicePoints.model.get_db()
 
-    cur = cursor.execute("SELECT * FROM tutors")
+    cur = cursor.execute("SELECT subject, time FROM tutors")
     tutors = cur.fetchall()
 
-    username = flask.session["username"]
-    cur2 = cursor.execute('SELECT email FROM users WHERE '
-                    'username =:who', {"who": username})
-    emails = cur2.fetchall()
+    cur2 = cursor.execute('SELECT fullname, email FROM users WHERE username IN (SELECT username FROM tutors)')
+    tutorsN = cur2.fetchall()
 
     # Add database info to context
-    context = {"tutors": tutors, "emails": emails}
+    context = {"tutors": tutors, "tutorsN": tutorsN}
     return flask.render_template("tutor.html", **context,zip=zip)
 
 @servicePoints.app.route('/accounts/submitPoints/', methods=['GET', 'POST'])
-- 
GitLab