From e3de8ea3dc654e8f176e80cd1ecc2a623688a43b Mon Sep 17 00:00:00 2001 From: Sruti Guhathakurta Date: Fri, 11 Nov 2016 18:50:37 -0500 Subject: [PATCH 01/27] favorites worksgit add . --- .DS_Store | Bin 6148 -> 6148 bytes app/static/.DS_Store | Bin 6148 -> 10244 bytes app/static/images/emptystar.png | Bin 0 -> 2876 bytes app/static/images/star.png | Bin 0 -> 1849 bytes app/templates/edit_add_resource.html | 21 ++--- app/templates/edit_user.html | 17 ++--- app/templates/home.html | 24 +++++- app/templates/layout.html | 20 ++++- app/templates/resource_detail.html | 19 +++-- app/templates/search.html | 6 ++ app/views.py | 110 ++++++++++++++++++++------- 11 files changed, 152 insertions(+), 65 deletions(-) create mode 100644 app/static/images/emptystar.png create mode 100644 app/static/images/star.png diff --git a/.DS_Store b/.DS_Store index d2003b264a924900360884cd1b49e5dd09dad800..77f90c77e167267f51dce1bdae5af88da8d598e5 100644 GIT binary patch delta 313 zcmZoMXfc@J&&a(oU^g=(_hcTHy%Hyq3UV@wOAHLIGcqx=u(GjpaBy&Q@N!Rn$|65m zfYrP{IyfW0JRq?oBPp?nlarH!GhRTvy4uJjsKdRk7+QjY*2L>)qHx*E_4- zbwUz?d_Y3t#tjZ!_(uE*NL&!82aZUbX z)^7{|q|kD602Tlk*f=*wv3m${J#Pb)QZtjt3Hk%8IX-i6WDeNs35|e8KqH_L& zoIxVe6}faJs>C3wb|BIn^?7CAmR!065m&}_)Rl>

3o$h$YN{Uxfnml*TAvh6HWZ>wrfUSUCE)4+=kn6KTWfy=fEtQEMiSf^ws4fM@q zGDfCqPVerXo1L-F&AqTUW9?qJfbu-bdxkOnT<&6Vy}7-!`^Mgz@5yZwl{#Qdj=TN) zD5>3TmZQLDK^d#;s+TX{%&-QFV%U%>CAMjbJ*imE$b+52}%eNiRUknN?Nm!Fx z^3`fAC`BG$X@#Q9_maKzs|XXw=C5@G9zIAWWTk+=#Z8jUuglR=zydFm$>vK+Yrt8! z4A)^9Zo>||3m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lanz!s7WU+P1;Nfw=WtCyoG%7 z(x5khF_ooRo@(G3E*-=w^b%{R4gY7MYanJ<`I?_NdwYF7XK*oglL>vWIu?;DfyjTgLx|6_iDEibOJ|V zuA99hIg)3Pj{<{P^XxRKgG(0qT)|^YAQrD=k@NC>93U327TF(S@k*U|H398H$ChLY z@VoDWN{!^ajp6{2xV6ZB(IV#nk+>zklk+esQ3{dC3W<@Nhe?T2h)h;U6gjUS)dAk) zmngF2ovsgnOM#7o9x{KYuLl2nEcOAvGW^N?s|x?`+e;_%vwu#RiQj}C0v@CE)(iE( zhtaKS?2Pt-nOIquF@ zt1;W$yI2|c3P+wriF@skmodA|`Cu}zCT9Onc=GO*xHc}?idhs+f;qsqAv}iB7SGa^93tJj%MRlb>=N=S$=jIv1YkXOah>nowL>1HvLtN7 zyg`!8Wx$VA7T>)Bex0$AXu%%Nn+EDIo0>*l!fJzrSrMf%*15HNRtxXz(Zv0OcS$b#3PKnU2!HRE6PnuY{IOM zon@MVk0_mkOiWf3o0RwshdY!dltsWF49`XCCo6_dO7s9vVQ!A(k%_?548Jjy>dA_0 z=nv#`;7nONiD4#YrTQQ@3uNusu^O`~?o#9zp-CE5z)irPm{kc=%Sv*%XlO)^0ai$x nP!vT`6h%=KMNt$*$qfGkzumR(I|(q;00000NkvXXu0mjfj1g)F literal 0 HcmV?d00001 diff --git a/app/templates/edit_add_resource.html b/app/templates/edit_add_resource.html index dd4b25b..8ac83f5 100644 --- a/app/templates/edit_add_resource.html +++ b/app/templates/edit_add_resource.html @@ -3,10 +3,10 @@ {%block content %}

-
+
- {% else %} @@ -19,19 +19,19 @@
- {% else %} placeholder="123 E. EnterStreet St."> {% endif %} - {% else %} placeholder = "City"> {% endif %} - {% else %} @@ -47,7 +47,7 @@
-
- - + +
-
-
- -
-
diff --git a/app/templates/edit_user.html b/app/templates/edit_user.html index 32d406d..a676ce9 100644 --- a/app/templates/edit_user.html +++ b/app/templates/edit_user.html @@ -3,12 +3,12 @@ {%block content %}
-
+
-
@@ -19,7 +19,7 @@
- +
@@ -29,7 +29,7 @@

Resources

-
-
- -
-
diff --git a/app/templates/home.html b/app/templates/home.html index 4de5b42..f737f30 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -8,9 +8,29 @@
+

Search for Resource by Category

@@ -41,6 +43,12 @@

{{ category[0] }} + + + + {% with messages = get_flashed_messages() %} + {% if messages %} +
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+ {% endif %} + {% endwith %} + + {% block content %} + {% endblock %} + + + diff --git a/app/views.py b/app/views.py index 9459793..b7d8a13 100644 --- a/app/views.py +++ b/app/views.py @@ -17,13 +17,12 @@ def login(): conn = mysql.connection cursor = conn.cursor() - cursor.execute("SELECT Username, Name FROM USER WHERE Username='" + username + "' AND PASSWORD='" + password + "';") + cursor.execute("SELECT Username FROM USER WHERE Username='" + username + "' AND PASSWORD='" + password + "';") data = cursor.fetchall() if len(data) > 0: session['logged_in'] = True session['user'] = username - session['name'] = data[0][1] cursor2 = conn.cursor() cursor2.execute("SELECT * FROM Category_Names;") @@ -77,6 +76,39 @@ def edit_user(): return render_template('edit_user.html', title = 'edit profile', user = user, categories = categories, userdata = userdata, userresource = userresource) +@app.route('/searchName//', methods=["GET"]) +def searchName(name): + if not session.get('logged_in'): + return redirect('login') + else: + user = session.get('user') + categories = session.get('categories') + + conn = mysql.connection + cursor = conn.cursor() + + cursor.execute(""" + SELECT rev.rating, res.name, res.description, res.Address_State AS State, + res.Address_City AS City, res.Address_Zip AS Zip, res.Address_Street AS Street, + res.Address_Number AS Num +FROM ( + SELECT * + FROM Resource + WHERE name = %s + ) res +NATURAL LEFT JOIN ( + SELECT ID, AVG(Rating) AS rating + FROM Reviews + GROUP BY ID + ) rev +ORDER BY rev.rating DESC; + """, (name, )) + + resources = cursor.fetchall() + print resources + + return render_template('search.html', resources=resources, categories=categories, user=user) + @app.route('/search//', methods=["GET"]) def search(ctgry): print ctgry @@ -91,29 +123,29 @@ def search(ctgry): cursor.execute(""" SELECT rev.rating, res.name, res.description, res.Address_State AS State, - res.Address_City AS City, res.Address_Zip AS Zip, res.Address_Street AS Street, - res.Address_Number AS Num - FROM ( - SELECT * - FROM Resource - NATURAL JOIN ( - SELECT ID - FROM Categories - WHERE Name = %s - ) categories - ) res - NATURAL LEFT JOIN ( - SELECT ID, AVG(Rating) AS rating - FROM Reviews - GROUP BY ID - ) rev - ORDER BY rev.rating DESC; + res.Address_City AS City, res.Address_Zip AS Zip, res.Address_Street AS Street, + res.Address_Number AS Num +FROM ( + SELECT * + FROM Resource + NATURAL JOIN ( + SELECT ID + FROM Categories + WHERE Name = %s + ) categories + ) res +NATURAL LEFT JOIN ( + SELECT ID, AVG(Rating) AS rating + FROM Reviews + GROUP BY ID + ) rev +ORDER BY rev.rating DESC; """, (ctgry, )) resources = cursor.fetchall() print resources - return render_template('search.html', resources=resources, categories=categories) + return render_template('search.html', resources=resources, categories=categories, user=user) @app.route('/resource_detail') def resource_detail(): @@ -126,9 +158,69 @@ def resource_detail(): cursor = conn.cursor() cursor.execute("SELECT * FROM RESOURCE WHERE Name = '" + resourcename + "';") resource = cursor.fetchall() + id=resource[0][12] + cursor2 = conn.cursor() + cursor2.execute("SELECT Phone_Number FROM Phone_Numbers WHERE ID = %s;", (id,)) + cursor3 = conn.cursor() + cursor3.execute("SELECT * FROM User_Favorites WHERE Username = %s AND ID = %s;", (user, id, )) + phones=cursor2.fetchall() + isfav = cursor3.fetchall() + if len(isfav) > 0: + favorite = True + else: + favorite = False categories = session.get('categories') return render_template('resource_detail.html', title='resource details', - user = user, categories = categories, resource = resource) + user = user, categories = categories, resource = resource, phones = phones, favorite = favorite) + +@app.route('/deletefav/', methods=['GET']) +def deletefav(resourceid): + user = session.get('user') + conn = mysql.connection + cursor = conn.cursor() + cursor.execute("""DELETE FROM User_Favorites +WHERE Username = %s AND ID = %s;""", (user, resourceid, )) + conn.commit() + return redirect(url_for('favorites')) + +@app.route('/addfav/', methods=['GET']) +def addfav(resourceid): + user = session.get('user') + conn = mysql.connection + cursor = conn.cursor() + cursor.execute("""INSERT INTO User_Favorites + VALUES (%s, %s);""", (user, resourceid, )) + conn.commit() + return redirect(url_for('favorites')) + +@app.route('/favorites') +def favorites(): + if not session.get('logged_in'): + return redirect('login') + else: + user = session.get('user') + conn = mysql.connection + cursor = conn.cursor() + cursor.execute("""SELECT rev.avg_rating AS Rating, res.name AS Name, res.description AS Description, res.Address_State AS State, + res.Address_City AS city, res.Address_Zip AS Zip, res.Address_Street AS Street, res.Address_Number AS Num +FROM ( + SELECT * + FROM ( + SELECT ID + FROM User_Favorites + WHERE Username = %s + ) favs + NATURAL JOIN Resource + ) res +NATURAL LEFT JOIN ( + SELECT ID, AVG(Rating) AS avg_rating + FROM Reviews + GROUP BY ID + ) rev +ORDER BY rev.avg_rating DESC;""", (user, )) + resources = cursor.fetchall() + categories = session.get('categories') + return render_template('search.html', resources=resources, categories=categories, user=user, favorites = True) @app.route('/organizations') def organizations(): @@ -166,19 +258,17 @@ def user_detail(): return render_template('user_detail.html', title='User Details', user = user, orgdata = orgdata, detailorg = detailorg, categories = categories, resources = resources) -@app.route('/edit_add_resource') -def edit_add_resource(): +@app.route('/editresource', methods=['GET', 'POST']) +def editresource(name): if not session.get('logged_in'): return redirect('login') else: - resource = None user = session.get('user') conn = mysql.connection - if 'resource' in request.args: - resourceName = request.args['resource'] - cursor = conn.cursor() - cursor.execute("SELECT * FROM Resource WHERE Name = '" + resourceName + "';") - resource = cursor.fetchall() + resourceName = name + cursor = conn.cursor() + cursor.execute("SELECT * FROM Resource WHERE Name = '" + resourceName + "';") + resource = cursor.fetchall() if request.method == 'POST': resourceName = request.form['resourceName'] resourcePhone = request.form['resourcePhone'] @@ -187,19 +277,37 @@ def edit_add_resource(): resourceState = request.form['resourceState'] resourceZip = request.form['resourceZip'] resourceDescription = request.form['resourceDescription'] - if resource != None: - cursor2 = conn.cursor() - cursor2.execute("UPDATE Resource SET Name = '" + resourceName + "', Address_State = '" + resourceState - + "', Address_City = '" + resourceCity + "', Address_Zip = '" + resourceZip + "', Address_Street = '" - + resourceStreet + "', Description = '" + resourceDescription + "' WHERE Username = '" + - user + "';") - return redirect(url_for('edit_user')) - else: - cursor3 = conn.cursor() - cursor3.execute("INSERT INTO Resource (Name, Username, Address_State, Address_City, Address_Zip, Address_Street, Description) VALUES (" + - resourceName + ", " + user + ", " + resourceState + ", " + resourceCity + ", " + resourceZip - + ", " + resourceStreet + ", " + resourceDescription + ");") - return redirect(url_for('edit_user')) - categories = session.get('categories') - return render_template('edit_add_resource.html', title = "Edit Resource", user = user, - categories = categories, resource = resource) + cursor2 = conn.cursor() + cursor2.execute("UPDATE Resource SET Name = '" + resourceName + "', Address_State = '" + resourceState + + "', Address_City = '" + resourceCity + "', Address_Zip = '" + resourceZip + "', Address_Street = '" + + resourceStreet + "', Description = '" + resourceDescription + "' WHERE Username = '" + + user + "';") + return redirect(url_for('edit_user')) + categories = session.get('categories') + return render_template('edit_add_resource.html', title = "Edit Resource", user = user, + categories = categories, resource = resource) + +@app.route('/addresource', methods = ['GET', 'POST']) +def addresource(): + if not session.get('logged_in'): + return redirect('login') + else: + user = session.get('user') + conn = mysql.connection + cursor = conn.cursor() + if request.method == 'POST': + resourceName = request.form['resourceName'] + resourcePhone = request.form['resourcePhone'] + resourceStreet = request.form['resourceStreet'] + resourceCity = request.form['resourceCity'] + resourceState = request.form['resourceState'] + resourceZip = request.form['resourceZip'] + resourceDescription = request.form['resourceDescription'] + cursor3 = conn.cursor() + cursor3.execute("INSERT INTO Resource (Name, Username, Address_State, Address_City, Address_Zip, Address_Street, Description) VALUES (" + + resourceName + ", " + user + ", " + resourceState + ", " + resourceCity + ", " + resourceZip + + ", " + resourceStreet + ", " + resourceDescription + ");") + return redirect(url_for('edit_user')) + categories = session.get('categories') + return render_template('edit_add_resource.html', title = "Add Resource", user = user, + categories = categories) From 3ef0bf742bbc7d1973604d9ab313a3c31cf22382 Mon Sep 17 00:00:00 2001 From: michaelchen523 Date: Mon, 14 Nov 2016 19:30:21 -0500 Subject: [PATCH 06/27] Committing --- app/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views.py b/app/views.py index b7d8a13..6fecd2f 100644 --- a/app/views.py +++ b/app/views.py @@ -71,6 +71,7 @@ def edit_user(): cursor.execute("UPDATE Users SET Organization = '" + orgName + "', Phone = '" + orgPhone + "', Description = '" + orgDescription + "' WHERE Username = '" + user + "';") + return redirect(url_for('edit_user')) return render_template('edit_user.html', title = 'edit profile', user = user, From 44cf058495480c183f04085baab4662827510d93 Mon Sep 17 00:00:00 2001 From: michaelchen523 Date: Mon, 14 Nov 2016 20:27:02 -0500 Subject: [PATCH 07/27] Changes made --- app/static/js/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/static/js/index.js b/app/static/js/index.js index ff95b20..9f52f7f 100644 --- a/app/static/js/index.js +++ b/app/static/js/index.js @@ -8,7 +8,7 @@ function goBack() { window.history.back(); } -function searchname() { - var sname = document.getElementById("Search").value; - window.location = {{ url_for('searchName', name= sname) }}; -} +// function searchname() { +// var sname = document.getElementById("Search").value; +// window.location = {{ url_for('searchName', name= sname) }}; +// } From 811a23bf337f10dfe1ddfb764417e20c0185bd9d Mon Sep 17 00:00:00 2001 From: Sruti Guhathakurta Date: Mon, 14 Nov 2016 20:55:30 -0500 Subject: [PATCH 08/27] maps works --- app/templates/search.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/search.html b/app/templates/search.html index dd19f4b..314ff35 100644 --- a/app/templates/search.html +++ b/app/templates/search.html @@ -103,7 +103,7 @@

Rating: {{ resource[0] }}

center: atlanta }); - var addresses = [{% for resource in resources %} "{{resource[6]}} {{resource[5]}}, {{resource[3]}}, {{resource[2]}} {{resource[4]}}", {% endfor %}] + var addresses = [{% for resource in resources %} "{{resource[7]}} {{resource[6]}}, {{resource[4]}}, {{resource[3]}} {{resource[5]}}", {% endfor %}] for (x = 0; x < addresses.length; x++) { From d8b9eafc37c69d0f0497fe8f6842a527ea4a1ee3 Mon Sep 17 00:00:00 2001 From: Sruti Guhathakurta Date: Mon, 14 Nov 2016 20:56:48 -0500 Subject: [PATCH 09/27] phone numbers working --- app/templates/resource_detail.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/resource_detail.html b/app/templates/resource_detail.html index bad944e..dbb3b86 100644 --- a/app/templates/resource_detail.html +++ b/app/templates/resource_detail.html @@ -15,7 +15,7 @@

{{ resource[0][0] }}

Rating

{% for phone in phones %} -

phone[0]

+

{{phone[0]}}

{% endfor %}

{{ resource[0][6] }} {{ resource[0][5] }}

{{ resource[0][3] }}, {{resource[0][2] }}

From d686237138ea1855cf41484440d167e13c9b217a Mon Sep 17 00:00:00 2001 From: Sruti Guhathakurta Date: Mon, 14 Nov 2016 21:02:53 -0500 Subject: [PATCH 10/27] edited minor thing --- app/templates/edit_add_resource.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/edit_add_resource.html b/app/templates/edit_add_resource.html index 8ac83f5..45b8d0c 100644 --- a/app/templates/edit_add_resource.html +++ b/app/templates/edit_add_resource.html @@ -8,7 +8,7 @@
+ value = "{{ resource[0][0] }}"> {% else %} placeholder = "Resource Name"> {% endif %} From 871d8ad75598776db333c5c3e09c0f8f24c2dafa Mon Sep 17 00:00:00 2001 From: michaelchen523 Date: Mon, 14 Nov 2016 21:04:25 -0500 Subject: [PATCH 11/27] started editing user --- app/templates/edit_user.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/templates/edit_user.html b/app/templates/edit_user.html index cb2d6a1..bf09a49 100644 --- a/app/templates/edit_user.html +++ b/app/templates/edit_user.html @@ -1,8 +1,9 @@ {% extends 'layout.html' %} -{%block content %} +{% block content %}
+ {{ userdata[0][3] }}
@@ -12,15 +13,14 @@ { % else % } placeholder="Organization Name">
- +
- +
- +
- - +

Resources

From b0a19559bc42809100d5da2c799810291cd13fbe Mon Sep 17 00:00:00 2001 From: michaelchen523 Date: Mon, 14 Nov 2016 22:56:42 -0500 Subject: [PATCH 12/27] Finished edit user --- app/templates/edit_user.html | 23 +++++++++--------- app/views.py | 45 +++++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/app/templates/edit_user.html b/app/templates/edit_user.html index bf09a49..0e88eb2 100644 --- a/app/templates/edit_user.html +++ b/app/templates/edit_user.html @@ -3,24 +3,23 @@ {% block content %}
- {{ userdata[0][3] }} - +

Organization Name: {{ userdata[0][3] }}

+
- +
- + +
- +
- - +
- +

Resources

diff --git a/app/views.py b/app/views.py index 6fecd2f..9eee926 100644 --- a/app/views.py +++ b/app/views.py @@ -55,27 +55,36 @@ def edit_user(): if not session.get('logged_in'): return redirect('login') else: - user = session.get('user') - categories = session.get('categories') conn = mysql.connection - cursor = conn.cursor() - cursor.execute("SELECT * FROM USER WHERE Username='" + user + "';") - userdata = cursor.fetchall() - cursor2 = conn.cursor() - cursor2.execute("SELECT Name FROM RESOURCE WHERE Creator_Username='" + user + "';") - userresource = cursor2.fetchall() if request.method == 'POST': - orgName = request.form['orgName'] - orgPhone = request.form['orgPhone'] - orgDescription = request.form['orgDescription'] - - cursor.execute("UPDATE Users SET Organization = '" + orgName + "', Phone = '" + orgPhone + - "', Description = '" + orgDescription + "' WHERE Username = '" + user + "';") + username = request.form['username'] + password = request.form['password'] + email = request.form['email'] + print username + print password + print email - return redirect(url_for('edit_user')) - - return render_template('edit_user.html', title = 'edit profile', user = user, - categories = categories, userdata = userdata, userresource = userresource) + cursor3 = conn.cursor() + cursor3.execute( + """ + UPDATE User + SET Email = %s, Password = %s + WHERE Username = %s; + """, (email, password, username) + ) + conn.commit() + return redirect('edit_user') + else: + user = session.get('user') + categories = session.get('categories') + cursor = conn.cursor() + cursor.execute("SELECT * FROM USER WHERE Username='" + user + "';") + userdata = cursor.fetchall() + cursor2 = conn.cursor() + cursor2.execute("SELECT Name FROM RESOURCE WHERE Creator_Username='" + user + "';") + userresource = cursor2.fetchall() + return render_template('edit_user.html', title = 'edit profile', user = user, + categories = categories, userdata = userdata, userresource = userresource) @app.route('/searchName//', methods=["GET"]) def searchName(name): From e1245a3c437e2687564cd557712d4102fc55c582 Mon Sep 17 00:00:00 2001 From: Sruti Guhathakurta Date: Mon, 14 Nov 2016 23:17:37 -0500 Subject: [PATCH 13/27] started edit/add resource stuff --- app/static/js/index.js | 14 ++++++++ app/templates/edit_add_resource.html | 51 +++++++++++++++++++++++----- app/views.py | 11 +++++- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/app/static/js/index.js b/app/static/js/index.js index 9f52f7f..21d1d7a 100644 --- a/app/static/js/index.js +++ b/app/static/js/index.js @@ -2,12 +2,26 @@ $(document).ready(function() { $(".dropdown-toggle").dropdown(); + $(".specific").hide(); + + $("#edit-resource").on('click', '#addphone',function() { + var newDiv = $(".resourcePhone")[0].outerHTML; + $(".phone").append(newDiv); + $(".resourcePhone:last").attr("placeholder", "(000)000-0000"); + $(".resourcePhone:last").removeAttr("value"); + }); + + $("#next").click(function() { + $(".specific").show(); + $("#cancel").hide(); + }) }); function goBack() { window.history.back(); } + // function searchname() { // var sname = document.getElementById("Search").value; // window.location = {{ url_for('searchName', name= sname) }}; diff --git a/app/templates/edit_add_resource.html b/app/templates/edit_add_resource.html index 45b8d0c..748be22 100644 --- a/app/templates/edit_add_resource.html +++ b/app/templates/edit_add_resource.html @@ -3,7 +3,7 @@ {%block content %}
- +
{% endif %}
- -
- + +
+ {% if phones %} + {% for phone in phones %} + + {% endfor %} + {% else %} + + {% endif %} + +Add
@@ -49,15 +56,41 @@
{% else %} - placeholder="Enter Description"> + placeholder="Enter Description"> {% endif %} -
+ + {% for category in categories %} +
+ {{ category[0] }}: {{ category[1] }} +
+ {% endfor %}
- - + + +
+
+

{{ checkList }}

+ {% if 'Childcare' in checkList %} +
+

Childcare

+

Attribz

+
+ {% endif %} + {% if 'Education' in checkList %} +
+

Education

+

Attribz

+
+ {% endif %} + {% if 'Employment' in checkList %} +
+

Employment

+

Attribz

+
+ {% endif %}
diff --git a/app/views.py b/app/views.py index 6fecd2f..7ab4931 100644 --- a/app/views.py +++ b/app/views.py @@ -270,6 +270,10 @@ def editresource(name): cursor = conn.cursor() cursor.execute("SELECT * FROM Resource WHERE Name = '" + resourceName + "';") resource = cursor.fetchall() + id=resource[0][12] + cursor2 = conn.cursor() + cursor2.execute("SELECT Phone_Number FROM Phone_Numbers WHERE ID = %s;", (id,)) + phones = cursor2.fetchall() if request.method == 'POST': resourceName = request.form['resourceName'] resourcePhone = request.form['resourcePhone'] @@ -286,7 +290,7 @@ def editresource(name): return redirect(url_for('edit_user')) categories = session.get('categories') return render_template('edit_add_resource.html', title = "Edit Resource", user = user, - categories = categories, resource = resource) + categories = categories, resource = resource, phones = phones) @app.route('/addresource', methods = ['GET', 'POST']) def addresource(): @@ -312,3 +316,8 @@ def addresource(): categories = session.get('categories') return render_template('edit_add_resource.html', title = "Add Resource", user = user, categories = categories) + +@app.route('/showNext', methods=['GET']) +def showNext(): + checkList = request.GET.getlist('checkedCategory') + return redirect(url_for('edit_user', checkList = checkList)) From a8a1af9375bdf5e2b6ebd171fdba9eda0ac1da5f Mon Sep 17 00:00:00 2001 From: Sruti Guhathakurta Date: Mon, 14 Nov 2016 23:21:53 -0500 Subject: [PATCH 14/27] minor changes have to figure out getting values from checkbox --- app/templates/edit_add_resource.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/templates/edit_add_resource.html b/app/templates/edit_add_resource.html index 748be22..8652f21 100644 --- a/app/templates/edit_add_resource.html +++ b/app/templates/edit_add_resource.html @@ -91,6 +91,10 @@

Employment

Attribz

{% endif %} +
+ + +
From 30b9233f1db8d52a28d450fce2b1d4d2a49a8f23 Mon Sep 17 00:00:00 2001 From: michaelchen523 Date: Tue, 15 Nov 2016 00:06:33 -0500 Subject: [PATCH 15/27] Update user works --- app/templates/edit_user.html | 6 ------ app/views.py | 8 ++------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/templates/edit_user.html b/app/templates/edit_user.html index 0e88eb2..32f79ce 100644 --- a/app/templates/edit_user.html +++ b/app/templates/edit_user.html @@ -5,12 +5,6 @@

Organization Name: {{ userdata[0][3] }}

- -
- -
-
Date: Tue, 15 Nov 2016 10:23:47 -0500 Subject: [PATCH 16/27] Resources to My resources --- app/templates/edit_user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/edit_user.html b/app/templates/edit_user.html index 32f79ce..6817563 100644 --- a/app/templates/edit_user.html +++ b/app/templates/edit_user.html @@ -16,7 +16,7 @@

Organization Name: {{ userdata[0][3] }}

value= {{userdata[0][1]}}>
-

Resources

+

My Resources