From f2276dcb5f5fd1787dab15e3eb6ccaac08456df2 Mon Sep 17 00:00:00 2001 From: paco Date: Sat, 11 Feb 2023 16:17:22 -0500 Subject: [PATCH 1/5] adding sesion --- app.py | 1 + templates/home.html | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index f48402c..ef11ec7 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ app = Flask(__name__) +# Adding session for user def validate_user(email, password): print("validating user...") diff --git a/templates/home.html b/templates/home.html index 0b92787..5e3266e 100644 --- a/templates/home.html +++ b/templates/home.html @@ -15,9 +15,9 @@

ACTIVITY TRACKER HOME

{% if data %} -

Welcome!

-

{{ data.name }}

-

{{ data.phone }}

+

Welcome {{ data.name }}!

+

+ {% endif %}

From 0666c37ab74b780f191ff345df5b46f7392c14e2 Mon Sep 17 00:00:00 2001 From: paco Date: Sat, 11 Feb 2023 16:51:01 -0500 Subject: [PATCH 2/5] added session --- app.py | 27 ++++++++++++++---- .../2029240f6d1128be89ddc32729463129 | Bin 0 -> 9 bytes .../4047f535c2255800d72ebf8f8d9ab16d | Bin 0 -> 38 bytes static/data/activity_tracker.db | Bin 8192 -> 12288 bytes static/styles.css | 6 ++++ templates/home.html | 8 +++--- 6 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 flask_session/2029240f6d1128be89ddc32729463129 create mode 100644 flask_session/4047f535c2255800d72ebf8f8d9ab16d diff --git a/app.py b/app.py index ef11ec7..8b9e414 100644 --- a/app.py +++ b/app.py @@ -1,9 +1,14 @@ -from flask import Flask, render_template, request +from flask import Flask, render_template, request, session, url_for, redirect import sqlite3 +# The Session instance is not used for direct access, you should always use flask.session +from flask_session import Session app = Flask(__name__) # Adding session for user +app.config["SESSION_PERMANENT"] = False #allow it to expire +app.config["SESSION_TYPE"] = "filesystem" #store the session locally +Session(app) def validate_user(email, password): print("validating user...") @@ -59,8 +64,11 @@ def signup(): @app.route('/home') def home(): - - return render_template('home.html') + data ={} + if session.get("name"): + return render_template('home.html') + else: + return redirect(url_for('index')) @app.route('/login_user' , methods=['POST']) def login_user(): @@ -78,6 +86,9 @@ def login_user(): "phone": user["phone"] } + #set the user session + session["name"] = user["name"] + #load home if there is a user, along with data. return render_template('home.html', data=data) @@ -101,15 +112,19 @@ def post_user(): pw = request.form['password'] store_user(name, email, phone, pw) - users = get_all_users() # print(users) - #get the last user entered new_user = users.pop() - return render_template('index.html', user=new_user) +@app.route('/logout') +def logout(): + session["name"] = None + return redirect(url_for('index')) + + + if __name__ == '__main__': app.run(debug=True, host='0.0.0.0') \ No newline at end of file diff --git a/flask_session/2029240f6d1128be89ddc32729463129 b/flask_session/2029240f6d1128be89ddc32729463129 new file mode 100644 index 0000000000000000000000000000000000000000..0596e012514d13dab859a6f4b53c5613662c19a8 GIT binary patch literal 9 QcmZQzU|?uq@n+Nm00XK3{{R30 literal 0 HcmV?d00001 diff --git a/flask_session/4047f535c2255800d72ebf8f8d9ab16d b/flask_session/4047f535c2255800d72ebf8f8d9ab16d new file mode 100644 index 0000000000000000000000000000000000000000..27f253b2b4e379fdf5cd7eb9292842cb5105bae1 GIT binary patch literal 38 pcmX^1LLjAqWvVy>1k_IHVaZF(O`X!inVg@Js*smjQ8J}i4*=yd3~c}a literal 0 HcmV?d00001 diff --git a/static/data/activity_tracker.db b/static/data/activity_tracker.db index 89852c80e015de8aad04a4e6b91be496d6a4ca5d..80c2d06c976c41934df25d932ce1039244e255c0 100644 GIT binary patch delta 219 zcmZp0Xh@hKEhxgkz`zW|Fu*)f#~3K6XJEw(6k_7%W8h!R&$qE~9$$T<5EHw&ygXxL zaYKNjx5aQ_Mzu0cSl)Z*l#%z~24{5+`Q(&E&jc(KeBgqo7d0*H3a&5QYC1=v82 OWf0g{Xv9CU;RFCEay}sd delta 53 zcmZojXmFSyEhx;uz`z8=Fu*iX$CzK3LC?U77bwKYznFo4@n%5 .commit-tease, .user-profile-mini-avatar, .avatar, .vcard-details, .signup-prompt-bg { display: none !IMPORTANT; }
- +

Logout

ACTIVITY TRACKER HOME

- {% if data %} -

Welcome {{ data.name }}!

+ +

Welcome {{ session.name }}!

- {% endif %} +

From 316d2ad417547116ae7b7707670da45ad8a846db Mon Sep 17 00:00:00 2001 From: paco Date: Sun, 12 Feb 2023 15:56:13 -0500 Subject: [PATCH 3/5] new activities can be added --- app.py | 72 ++++++++++++++++-- .../4047f535c2255800d72ebf8f8d9ab16d | Bin 38 -> 289 bytes static/data/activity_tracker.db | Bin 12288 -> 12288 bytes static/styles.css | 59 +++++++++++++- templates/home.html | 40 ++++++++-- templates/index.html | 11 ++- 6 files changed, 167 insertions(+), 15 deletions(-) diff --git a/app.py b/app.py index 8b9e414..320aa71 100644 --- a/app.py +++ b/app.py @@ -2,6 +2,7 @@ import sqlite3 # The Session instance is not used for direct access, you should always use flask.session from flask_session import Session +from datetime import datetime app = Flask(__name__) @@ -17,10 +18,10 @@ def validate_user(email, password): conn = sqlite3.connect('./static/data/activity_tracker.db') curs = conn.cursor() #get all columns if there is a match - result = curs.execute("SELECT name, email, phone FROM users WHERE email=(?) AND password= (?)", [email, password]) + result = curs.execute("SELECT rowid, name, email, phone FROM users WHERE email=(?) AND password= (?)", [email, password]) for row in result: - user = {'name': row[0], 'email': row[1], 'phone': row[2]} + user = {'rowid': row[0], 'name': row[1], 'email': row[2], 'phone': row[3]} conn.close() return user @@ -53,6 +54,39 @@ def get_all_users(): return all_users +def get_all_user_activities(id): + conn = sqlite3.connect('./static/data/activity_tracker.db') + curs = conn.cursor() + activities = [] # will store them in a list + result = curs.execute("SELECT * from activities WHERE user_id=(?)", (id,)) + for row in result: + activity = { + 'activity_name' : row[0], + 'date': row[1], + 'quantity': row[2], + 'description': row[3], + 'type': row[4] + } + activities.append(activity) + + conn.close() + + return activities + + +def store_activity(name, activity_type, desc, user, qty): + + now = datetime.now() # current date and time + date_time = now.strftime("%m/%d/%Y, %H:%M:%S") + + conn = sqlite3.connect('./static/data/activity_tracker.db') + curs = conn.cursor() + curs.execute("INSERT INTO activities (activity_name, date, quantity, description, user_id, type) VALUES((?),(?),(?),(?),(?),(?))", + (name, date_time, qty, desc, user, activity_type)) + + conn.commit() + conn.close() + @app.route('/') def index(): @@ -66,6 +100,10 @@ def signup(): def home(): data ={} if session.get("name"): + + #make sure we have the latest ones, after every new one is added + activities = get_all_user_activities(userid) + session["activities"] = activities return render_template('home.html') else: return redirect(url_for('index')) @@ -80,19 +118,23 @@ def login_user(): user = validate_user(email, password) if user: - data = { "name": user["name"], - "phone": user["phone"] + "phone": user["phone"], + "id": user["rowid"] + } #set the user session session["name"] = user["name"] + session["userid"] = user["rowid"] + userid = user["rowid"] + activities = get_all_user_activities(userid) + session["activities"] = activities #load home if there is a user, along with data. return render_template('home.html', data=data) - else: error_msg = "Login failed" @@ -102,6 +144,24 @@ def login_user(): #no user redirects back to the main login page, with error msg. return render_template('index.html', data=data) +@app.route('/post_activity', methods=['POST']) +def post_activity(): + name = request.form['activity-name'] + activity_type = request.form['activity-type'] + description = request.form['activity-desc'] + quantity = request.form["activity-qty"] + userid = session["userid"] + store_activity(name, activity_type, description, userid, quantity) + + user_activities = get_all_user_activities(session['userid']) + print(user_activities) + session["activities"] = get_all_user_activities(session['userid']) + + + + return render_template('home.html') + + @app.route('/post_user' , methods=['POST']) @@ -122,6 +182,8 @@ def post_user(): @app.route('/logout') def logout(): session["name"] = None + session["userid"] = None + session["activities"] = None return redirect(url_for('index')) diff --git a/flask_session/4047f535c2255800d72ebf8f8d9ab16d b/flask_session/4047f535c2255800d72ebf8f8d9ab16d index 27f253b2b4e379fdf5cd7eb9292842cb5105bae1..e70162a663090f9e56ce0477e51f9504aa0d3479 100644 GIT binary patch literal 289 zcmZXPu};G<5Qd?RC?%Aku(5dTfJhuvsm;cQ6tTdJDyu&5iC_oEu9N|(58&~5QJw%N zbmOMe>HhE2|C7z-KKY&>9}V+Gi;!sX0TfOjgl5mCHWW^L3l=3+lQ0!qhdXr8(hDv6 z_u1jnZT@oUqp=$G8?#_atLXUjLOXOFRpXFKXtx#{ zhb9IupQ2t^0uCn*I|NyjZJLgF{1q`wQZWVsZcg literal 38 pcmX^1LLjAqWvVy>1k_IHVaZF(O`X!inVg@Js*smjQ8J}i4*=yd3~c}a diff --git a/static/data/activity_tracker.db b/static/data/activity_tracker.db index 80c2d06c976c41934df25d932ce1039244e255c0..fd937e9ac0beb1f3820b81ba2bcb916727cab511 100644 GIT binary patch literal 12288 zcmeI2Piq@T6u`AoHnL-_6jO=_!T7~SBqoV0?P?o)OCgS8aP=`UMI-mfm{o=O`3<=%wfOjU;0yq{0|OFEg;aZ+7SX`^~K2jduUD zolsI}bI~UfoXpjXVPx(DWHOm0JaTv(Hxq?R#~r*Hr{w<U?~tn+ByE0}jz%asjAdLe`T-f%#o9u;KNp9W-g&Rj%{n_W6+5#J|1 z3d3m%)hp(Wm2%|)Ww1>dZ-p(&rj4)9n#<_mArZ0*&qzQ;pu}k^&Ww2zRX!%I76I9% z@FbOAsLnK{J9%>f<9b3ceID^HnHrUI*<86@uI!{edO|D0-ZU4Ec@Cx3OXl^u;x**V zr>*g2nwJlA=FN}Fl^FLDIK-ikJ1Q;3P^0bv2O#}<0(YhKyKZ+Ull6b+$64k`3$HTx)K{kb!^b3Dhr z7ek*yz_Q`wr8(Br!XpZ0|@wlf%5^@nF%JT62p?VSIzEX?tRMS z{_I(d+6~Wj&TcfA$uGLIUmMpp5MGorzx!5@wVKyh8-y5De+X?6QjAMgnt+^DT8ShA zGY|>*>aSi#04w-DPk@F=G|Wht{V%J+5R*l?9J)Mu-DO3ZVLvOtD0(M zorEIhSPUu}0`KEWAP_5MHKL8POaxEW8o+H70&QGMU7m`hn%y`I(KTno%V%@#tY5h6 zbracIE3?<%U|XLoaJ%L?4X@!mAsBtiU`*;EVLk#Qm-3Elb&T?UL}N@}BGP`Ma!W?o zP8qRX&tBh>I0p$5Xi<{Nu$@MbM3lx=*n%!PAkY!$0A#3M2sBD#o}0OiZ(z6^!Et03v0lz17z|yN>UCb`Q5f(pWhPqiFo@s}-Pr1hSh%1R>ur i^2@H_7}s{WU}*durt0gSyOvX?CTm13sEG9F#KgblSI8Xz delta 136 zcmZojXh@hKEhxgkz`zW|Fu*)f#~3K6XJEw(6k_7%W8h!R&$qE~8sEeK4vR)1CU$Xo zdB(=#lEkE()WqbH%(Bdq)M7Y;**VD7F~n6N#L>yeRRJzM*@a($4XCH2w0Lt4{|o^p M1_6+f8yiv>0o+p~%K!iX diff --git a/static/styles.css b/static/styles.css index 3a18bd4..e9bb010 100644 --- a/static/styles.css +++ b/static/styles.css @@ -12,12 +12,12 @@ body{ text-align: center; color:aliceblue; background-size: cover; - text-shadow: #000000 1px 1px 1px; + text-shadow: #000000 0px 0px 2px; } .main-container{ backdrop-filter: blur(8px); - height:100%; + height:inherit; margin:-10px; padding:20px; @@ -32,6 +32,20 @@ input{ width:300px; } +textarea{ + border-style:hidden; + border-radius:5px; + padding:5px; + +} +select{ + + width:200px; + height:30px; + border-style:hidden; + border-radius:5px; + padding:5px; +} .submit-btn{ @@ -63,4 +77,45 @@ input{ text-decoration: none; color:aliceblue; +} + +.add-activity-container{ + margin-top: 20px; +} +.activities-container{ + + margin-bottom: 20px; +} + +.activity-tile{ + + text-align: left; + padding: 10px; + background-color:rgba(250, 240, 250, 0.8); + height:fit-content; + margin-left:20%; + margin-right:20%; + margin-top:3px; + border-radius:2px; + +} + +.tile-item{ + + margin-bottom:-4px; + margin-top: -4px; + text-shadow: none; + color: #3b3a3b +} + +.activity-date{ + + font-size: x-small; + margin-top: 2px; + color:#555255; +} + +.add-activity-container{ + + } \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index f9c277b..d3a04bc 100644 --- a/templates/home.html +++ b/templates/home.html @@ -10,17 +10,47 @@
-

Logout

+

Logout

ACTIVITY TRACKER HOME

- -

Welcome {{ session.name }}!

+

Welcome {{ session.name }}! {{ session.userid }}

+ +
+
+ ​ +

+ ​ +

+ ​ +

+ ​ +

+ + +
+ +
- -

+
+

My activities

+ + + {% for item in session.activities %} +
+ +

{{ item.activity_name }}

+

{{ item.description }}

+

{{ item.date }}

+ +
+ {% endfor %} + + + +
diff --git a/templates/index.html b/templates/index.html index b577462..7edd913 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,16 +11,21 @@

Activity Tracker

+

Activity tracker is a demo app to illustrate how to store data using SQLite and + Flask. It also uses Flask sessions to keep track of users who log in. This version + allows users to sign up, log in and create activiites. Only the activities created by + a user will show up in their "My activities section". +

+

+ Next: How to delete and edit existing activities and how to send them via SMS. +


Log in existing user

- -

-

From 9382b6382653b3a8c62067f8bcbd4ca5be385800 Mon Sep 17 00:00:00 2001 From: paco Date: Sun, 12 Feb 2023 19:52:07 -0500 Subject: [PATCH 4/5] edit activity now available --- app.py | 101 ++++++++++++++++-- .../4047f535c2255800d72ebf8f8d9ab16d | Bin 289 -> 1641 bytes static/data/activity_tracker.db | Bin 12288 -> 12288 bytes static/styles.css | 15 ++- templates/edit.html | 49 +++++++++ templates/home.html | 41 +++++-- 6 files changed, 187 insertions(+), 19 deletions(-) create mode 100644 templates/edit.html diff --git a/app.py b/app.py index 320aa71..906bf7b 100644 --- a/app.py +++ b/app.py @@ -11,6 +11,8 @@ app.config["SESSION_TYPE"] = "filesystem" #store the session locally Session(app) + +####### User functions ####### def validate_user(email, password): print("validating user...") user = {} @@ -54,18 +56,21 @@ def get_all_users(): return all_users + +####### Activity functions ####### def get_all_user_activities(id): conn = sqlite3.connect('./static/data/activity_tracker.db') curs = conn.cursor() activities = [] # will store them in a list - result = curs.execute("SELECT * from activities WHERE user_id=(?)", (id,)) + result = curs.execute("SELECT rowid, * from activities WHERE user_id=(?)", (id,)) for row in result: activity = { - 'activity_name' : row[0], - 'date': row[1], - 'quantity': row[2], - 'description': row[3], - 'type': row[4] + 'rowid' : row[0], + 'activity_name' : row[1], + 'date': row[2], + 'quantity': row[3], + 'description': row[4], + 'type': row[5] } activities.append(activity) @@ -87,7 +92,49 @@ def store_activity(name, activity_type, desc, user, qty): conn.commit() conn.close() +def get_activity_by_id(id): + #returns the activity given a rowid + activity ={} + + conn = sqlite3.connect('./static/data/activity_tracker.db') + curs = conn.cursor() + + result = curs.execute("SELECT rowid, * FROM activities WHERE rowid=(?)", [id]) + for row in result: + #skip date and userid, those can't be edited. + activity = {'rowid': row[0], + 'activity_name': row[1], + 'quantity': row[3], + 'description':row[4], + 'type':row[6] + } + + conn.close() + print("Editing Activity >>> ") + print(activity) + + return activity + +def update_activity(id, activity): + + conn = sqlite3.connect('./static/data/activity_tracker.db') + curs = conn.cursor() + + result = curs.execute("UPDATE activities SET activity_name=(?), description=(?), quantity=(?), type=(?) WHERE rowid=(?)", + (activity["name"], activity["desc"] ,activity["qty"] , activity["type"] , id)) + conn.commit() + conn.close() + + print("result of updating>>>>>") + print(result) + + + + + + +####### APP ROUTES ####### @app.route('/') def index(): return render_template('index.html') @@ -102,7 +149,7 @@ def home(): if session.get("name"): #make sure we have the latest ones, after every new one is added - activities = get_all_user_activities(userid) + activities = get_all_user_activities(session["userid"]) session["activities"] = activities return render_template('home.html') else: @@ -179,6 +226,46 @@ def post_user(): return render_template('index.html', user=new_user) + + + + +@app.route('/edit-activity/', methods=["POST", "GET"]) +def edit_activity(id ): + #runs when user clicks on an activity to edit + data ={} + + #if the route sends a POST request (when updating): + if request.method == 'POST': + name= request.form["activity-name"] + desc = request.form["activity-description"] + activity_type = request.form["activity-type"] + qty = request.form["activity-qty"] + + updated_activity ={ + + "name": name, + "desc" : desc, + "type" :activity_type, + "qty" : qty + } + + update_activity(id, updated_activity) + + return redirect(url_for('home')) + + #if not updating, just get the user to the edit screen + activity = get_activity_by_id(id) + + if activity: + data={ + "activity": activity + } + + return render_template("edit.html", data=data) + + + @app.route('/logout') def logout(): session["name"] = None diff --git a/flask_session/4047f535c2255800d72ebf8f8d9ab16d b/flask_session/4047f535c2255800d72ebf8f8d9ab16d index e70162a663090f9e56ce0477e51f9504aa0d3479..3beab83c1dc2488670e72baed3b9409d6e9e21a8 100644 GIT binary patch literal 1641 zcmcIkTWi}e6z(N!o2D07N6Tm#r!S)qTk6=&NW7=+)|C(#?VvCiLy6@`M3FpMPVmEE zKfsUP|J{+3^pbY0h0RaK_4ZKwy!eyQ< zB{9`J$Xg3pnRE>wazo?%YkpuS)+b-mZ8pO`5kBvr0hYuI7>93J15&hy!mhD>1Bmx4A3ju0KH4wzNFFD&lSemU)?C>jxkF*+D z_w%>B?z|^jq(H8#*vIDqzUOCr*C!g=T+kR|Qw4%jZ2}{bf>Fh52e;9qh4v2V_Ny?H z%r@HHxs}e-Kc%yazwiAeooAEKw_A${y?I7S0H0CSN7d7uK@6m$5@R<|%)y8$U)+UO&{-t;}oh4JiVC#Nt%FVl4qt|Nu#$#zZScZz-?vPkxi&^BmX^iW|TAw(wh zq~jYZmhY+JsPR8lte}eWvBC40$S%7K{W6HU?>PQg!aN4i9C5>7kV2?AMfW1GhqLk#ysNh&~2qC*P^wUCb_S!JDpo|H7V_VkA%_ z3EnFdQXD6gQ5>4<46FBJ@Lb=u@fL-87()daDw7hm@cz8Zfam$1JuwCRn~CA#mcp8x v<5h4%mBw=)5#2A!6pl;TM?4G$b8RbuZR(LBg_#ns-G{$XT$cZspC;Ac_M8tq delta 58 zcmaFKvye&ulfF<&1Itt)Mg}mboubjhl9!m9I;DrhBQZ}QI6o(UN)KCUacWU!$`o(* KiAEooO7#EMP2g{eTlAk2XLrZAOQ*)X{1@4d%k<_-1F{v_i|CKTrF8@<)%AWsg!P& zS*@dJol;o5Fa9c`{!c&BC#Qc;9~SNkXNB_A&#C47ApcdnzBwsqz|`EgcD}DJY@whD zpeu=BoHGzH`;wg>e`}x8ePj@aup3YkK_shyl!EjL^f3X+AD=xDI359H4)oAIs=@~g zg%j}8S*_OAFXq+H2ZYHdbtJhUb)(iWYDV2?u0mtoG&*Lpu>(CGd%gsO@0?1^EJaGZ zm||7|Zgz)U7pa}~=n8(E3B5RhfWa=0U@M3SO{%%b=V2Hy?{sElddqAzU!oH)9h?5~ z9rU{KGCij0nAuCC(L0Zme + + + + + + EDIT + + + + +
+

Logout

+ +

EDIT ACTIVITY

+ + +

+ + {% if data %} + + +
+
+ ​ +

+
+ ​ +

+
+ ​ +

+
+ ​ +

+ + +
+ {% endif %} + + + +
+ + + + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index d3a04bc..565a5fd 100644 --- a/templates/home.html +++ b/templates/home.html @@ -17,8 +17,8 @@

ACTIVITY TRACKER HOME

Welcome {{ session.name }}! {{ session.userid }}

- -
+ +

@@ -28,7 +28,7 @@

ACTIVITY TRACKER HOME

- +
@@ -40,19 +40,40 @@

My activities

{% for item in session.activities %}
- -

{{ item.activity_name }}

-

{{ item.description }}

-

{{ item.date }}

- + + +

{{ item.rowid}} - {{ item.activity_name }}

+

{{ item.description }}

+

{{ item.date }}

+
{% endfor %} - +
- +
+ \ No newline at end of file From 9dc7a119502e9bbb97305378342f3c0f62fb99dc Mon Sep 17 00:00:00 2001 From: paco Date: Wed, 15 Feb 2023 14:23:46 -0500 Subject: [PATCH 5/5] now delete activity is available --- app.py | 30 ++++++++++++++++-- .../2029240f6d1128be89ddc32729463129 | Bin 9 -> 9 bytes .../314b48056d13da28ecdece8bcd11175e | Bin 0 -> 215 bytes .../4047f535c2255800d72ebf8f8d9ab16d | Bin 1641 -> 277 bytes static/data/activity_tracker.db | Bin 12288 -> 12288 bytes templates/edit.html | 17 +++++++++- 6 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 flask_session/314b48056d13da28ecdece8bcd11175e diff --git a/app.py b/app.py index 906bf7b..2d8addf 100644 --- a/app.py +++ b/app.py @@ -125,11 +125,24 @@ def update_activity(id, activity): conn.commit() conn.close() - print("result of updating>>>>>") - print(result) +def delete_from_table(table, id): + + #can be used on any table to delete by id + + conn = sqlite3.connect('./static/data/activity_tracker.db') + curs = conn.cursor() + + if table == "activity": + + curs.execute("DELETE FROM activities WHERE rowid=(?)", (id,)) + + conn.commit() + conn.close() + + @@ -228,6 +241,14 @@ def post_user(): +@app.route('/delete-activity/') +def delete_activity(id): + + delete_from_table("activity", id) #specify an activity to be deleted + + return redirect(url_for('home')) + + @app.route('/edit-activity/', methods=["POST", "GET"]) @@ -252,6 +273,8 @@ def edit_activity(id ): update_activity(id, updated_activity) + + return redirect(url_for('home')) #if not updating, just get the user to the edit screen @@ -259,7 +282,8 @@ def edit_activity(id ): if activity: data={ - "activity": activity + "activity": activity, + "rowid": id } return render_template("edit.html", data=data) diff --git a/flask_session/2029240f6d1128be89ddc32729463129 b/flask_session/2029240f6d1128be89ddc32729463129 index 0596e012514d13dab859a6f4b53c5613662c19a8..e3b22cefe3d3872b782ced76455f52b46130b1a7 100644 GIT binary patch literal 9 QcmZQzU|?uq@n+Hk00XQ600000 literal 9 QcmZQzU|?uq@n+Nm00XK3{{R30 diff --git a/flask_session/314b48056d13da28ecdece8bcd11175e b/flask_session/314b48056d13da28ecdece8bcd11175e new file mode 100644 index 0000000000000000000000000000000000000000..96bdeb63839cf7d235d150bbc339a78bc740af25 GIT binary patch literal 215 zcmXZWL5jja5Cu?$D2^fyD6^Dax)3!zy73Agz||mSy1>TRt(}URh2Q}SSLK~N)+FfP z{?Fq-dOzkKJzuqVZZhJ?!2yN85^qpBypnJ;&oEdct2(zKA$zuDF_S;3_Kn~#RoCb4 zrzz>% literal 0 HcmV?d00001 diff --git a/flask_session/4047f535c2255800d72ebf8f8d9ab16d b/flask_session/4047f535c2255800d72ebf8f8d9ab16d index 3beab83c1dc2488670e72baed3b9409d6e9e21a8..12253a17563e2c87ce4c5374b15a5e3e3ed342e3 100644 GIT binary patch delta 99 zcmaFKGnGl@eUng11Itu4Mg}mboubjhl9!m9I>oPtt+Y6`C^Kb>-$bKcVYVJ#$F!2v zqP+b4JcXjtyeSzRlRq#@uyT1bWpGb?FE7gL%~YD&!4ZKwy!eyQ< zB{9`J$Xg3pnRE>wazo?%YkpuS)+b-mZ8pO`5kBvr0hYuI7>93J15&hy!mhD>1Bmx4A3ju0KH4wzNFFD&lSemU)?C>jxkF*+D z_w%>B?z|^jq(H8#*vIDqzUOCr*C!g=T+kR|Qw4%jZ2}{bf>Fh52e;9qh4v2V_Ny?H z%r@HHxs}e-Kc%yazwiAeooAEKw_A${y?I7S0H0CSN7d7uK@6m$5@R<|%)y8$U)+UO&{-t;}oh4JiVC#Nt%FVl4qt|Nu#$#zZScZz-?vPkxi&^BmX^iW|TAw(wh zq~jYZmhY+JsPR8lte}eWvBC40$S%7K{W6HU?>PQg!aN4i9C5>7kV2?AMfW1GhqLk#ysNh&~2qC*P^wUCb_S!JDpo|H7V_VkA%_ z3EnFdQXD6gQ5>4<46FBJ@Lb=u@fL-87()daDw7hm@cz8Zfam$1JuwCRn~CA#mcp8x v<5h4%mBw=)5#2A!6pl;TM?4G$b8RbuZR(LBg_#ns-G{$XT$cZspC;Ac_M8tq diff --git a/static/data/activity_tracker.db b/static/data/activity_tracker.db index e279889ca2e542edb92b96910bb6bac71effa446..1ef3ac733d4786ee26c135afaa9347978d4cb6a9 100644 GIT binary patch delta 310 zcmZojXh@hK&1gJP#+lK0W5PmtZI0y({2b;C9OnE5eE<38@IK?s=4IvCz!S~=hP#$q zf>VWKH`j5l;~dL5mTxTN=9p}*QBcphkU@k24WtXP+ne$xGfHP9rYIyTKhpt8S5w*nphc_TNxW>q$;H6mnamJ7H3o{6z3~sDuA?? zR@1Cz;Y(yx+gPZ?80as|u4~Hc$tfA0npXnS znh4Zfl%JD>W}lIfm7!^QVor7{*n$$E)x{iOJb|P<@*vv^|+w`1dkc NPb@UwJV!5u5dhr-SEK*{ delta 209 zcmZojXh@hK&8R(5#+gxjW5PmtZT`IsLLBA{9OnE5eE<38@Fns-SOt&D(*CI@NyGgb3}Ma-;B46KYmBAX?&J(;a7S=r@Hc{Mqu9ZOOba!T`( yGYpLM4Gr~;42+C*6pRe4j7_Xej6D)l6w*rb6jBpQGV{`167!OQ)aE&QDU1L_-8UKl diff --git a/templates/edit.html b/templates/edit.html index 5625c2f..3df83f1 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -36,13 +36,28 @@

EDIT ACTIVITY

+ + {% endif %} + - +