Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete ability #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ def tracklist():
flash("Sorry, No tracking records found! - Let's generate a one!")
return redirect(url_for('index'))

@app.route('/delete/<utm_id>', methods=['Delete','Get'])
@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()
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)

@app.route('/track')
def track():
Expand Down
5 changes: 5 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
name="description"
content="Oblivion-Inverse : A Simple E-Mail Tracker"
/>
<script src="https://kit.fontawesome.com/76b066ae7b.js" crossorigin="anonymous"></script>
<link rel="apple-touch-icon" href="{{ url_for('static', filename = 'logo192.png') }}" />
<link rel="manifest" href="{{ url_for('static', filename = 'manifest.json') }}" />
<link
Expand Down Expand Up @@ -50,9 +51,13 @@ <h1 class="title" style="margin: 5px 10px 2px;">Oblivion<sup>-1</sup></h1>
<span id="t-1" class="navbar-item" style="margin: 5px 0px 0px;"> Tracking List </span>
</a>
{% if current_user.is_authenticated %}
<a class="navbar-item" href="{{ url_for('index') }}">
<span id="t-1" class="navbar-item" style="margin: 5px 0px 0px;">Add E-Mail </span>
</a>
<a class="navbar-item" href="{{ url_for('logout') }}">
<span id="t-1" class="navbar-item" style="margin: 5px 0px 0px;"> Log out </span>
</a>

{% endif %}
</div>

Expand Down
22 changes: 21 additions & 1 deletion templates/track_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

<div class="container" style="margin-top: 15px;">
{% for item in trackingList %}
<a href="{{ url_for('tracking_data', utm_id=item.utmId) }}">

<div id="trackCards" class="card">
<header class="card-header">
<p class="card-header-title">
{{ item.emailTitle }}
</p>
<a href="{{ url_for('delete', utm_id = item.utmId )}}" class="delete-button" method="delete">
<i class="fa fa-light fa-circle-minus"></i>
</a>
</header>

<div class="card-body" style="padding: 15px;">
<a href="{{ url_for('tracking_data', utm_id=item.utmId) }}">
<h3>{{ item.utmId }}</h3>
<p style="text-decoration: underline;">Added on: </p>
<p>{{ item.generatedDate }}</p>
Expand Down Expand Up @@ -41,6 +44,23 @@ <h3>{{ item.utmId }}</h3>
#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;
}
</style>

{% endblock %}