From 530d2fe1f68fc27712d958c213e2a6c84a08752a Mon Sep 17 00:00:00 2001 From: Jaskaran2 Date: Sat, 15 Oct 2022 17:04:17 +0530 Subject: [PATCH 1/2] Add delete functionality --- routes.py | 11 +++++++++++ templates/base.html | 5 +++++ templates/track_list.html | 22 +++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/routes.py b/routes.py index 40541de..19b7e99 100644 --- a/routes.py +++ b/routes.py @@ -44,6 +44,17 @@ def tracklist(): flash("Sorry, No tracking records found! - Let's generate a one!") return redirect(url_for('index')) +@app.route('/delete/', methods=['Delete','Get']) +@login_required +def delete(utm_id): + """ Delet particular track list """ + dataDeleted = TrackData.query.filter_by(utmId = utm_id).delete() + trackingList = TrackData.query.all() + if dataDeleted: + db.session.commit() + else: + abort(400) + return render_template('track_list.html', trackingList=trackingList) @app.route('/track') def track(): diff --git a/templates/base.html b/templates/base.html index f399d82..824e69c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,6 +9,7 @@ name="description" content="Oblivion-Inverse : A Simple E-Mail Tracker" /> + Oblivion-1 Tracking List {% if current_user.is_authenticated %} + + Add E-Mail + Log out + {% endif %} diff --git a/templates/track_list.html b/templates/track_list.html index 0fe5caf..dd30512 100644 --- a/templates/track_list.html +++ b/templates/track_list.html @@ -4,16 +4,19 @@
{% for item in trackingList %} -

{{ item.emailTitle }}

+
+ +
+

{{ item.utmId }}

Added on:

{{ item.generatedDate }}

@@ -41,6 +44,23 @@

{{ item.utmId }}

#trackCards:hover{ box-shadow: 0px 0px 15px 5px rgba(8, 17, 6, 0.26); } + + .card-header{ + display: flex; + } + .delete-button{ + margin-top: 0.7em; + margin-right: 0.7em; + } + + .delete-button:hover{ + color: red; + cursor: pointer; + } + a{ + color: black; + text-decoration: none; + } {% endblock %} \ No newline at end of file From ad645ec00d4d3af4f4fdd91b51de29060bbd45fd Mon Sep 17 00:00:00 2001 From: Jaskaran2 Date: Sat, 15 Oct 2022 19:45:54 +0530 Subject: [PATCH 2/2] Delete enteries and redirect to index --- routes.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/routes.py b/routes.py index 19b7e99..47987ee 100644 --- a/routes.py +++ b/routes.py @@ -48,13 +48,21 @@ def tracklist(): @login_required def delete(utm_id): """ Delet particular track list """ + # Delete enteries from track_data dataDeleted = TrackData.query.filter_by(utmId = utm_id).delete() + # Delete enteries from link_hits + LinkHits.query.filter_by(utmId = utm_id).delete() trackingList = TrackData.query.all() - if dataDeleted: + count_tracking_list = TrackData.query.count() + if dataDeleted and count_tracking_list > 0: db.session.commit() + return render_template('track_list.html', trackingList=trackingList) + elif dataDeleted and count_tracking_list == 0: + db.session.commit() + return redirect('/index/') else: abort(400) - return render_template('track_list.html', trackingList=trackingList) + return render_template('track_list.html', trackingList=trackingList) @app.route('/track') def track():