Refactoring: better naming

This commit is contained in:
Son NK 2020-03-30 21:46:52 +02:00
parent 917009a803
commit ca5e3ac477
3 changed files with 14 additions and 16 deletions

View File

@ -22,18 +22,18 @@
</div>
{% if fels|length == 0 %}
{% if email_logs|length == 0 %}
<div class="my-4 p-4 card">
You don't have any emails in Quarantine.
</div>
{% endif %}
{% for fel in fels %}
{% set refused_email = fel.refused_email %}
{% set forward = fel.forward %}
{% for email_log in email_logs %}
{% set refused_email = email_log.refused_email %}
{% set forward = email_log.forward %}
{% set alias = forward.alias %}
<div class="card p-4 shadow-sm {% if fel.id == highlight_fel_id %} highlight-row {% endif %}">
<div class="card p-4 shadow-sm {% if email_log.id == highlight_id %} highlight-row {% endif %}">
<div class="small-text">
Sent {{ refused_email.created_at | dt }}
</div>

View File

@ -9,22 +9,22 @@ from app.models import EmailLog
@login_required
def refused_email_route():
# Highlight a refused email
highlight_fel_id = request.args.get("highlight_fel_id")
if highlight_fel_id:
highlight_fel_id = int(highlight_fel_id)
highlight_id = request.args.get("highlight_id")
if highlight_id:
highlight_id = int(highlight_id)
fels: [EmailLog] = EmailLog.query.filter(
email_logs: [EmailLog] = EmailLog.query.filter(
EmailLog.user_id == current_user.id, EmailLog.refused_email_id != None
).all()
).order_by(EmailLog.id.desc()).all()
# make sure the highlighted fel is the first fel
highlight_index = None
for ix, fel in enumerate(fels):
if fel.id == highlight_fel_id:
for ix, fel in enumerate(email_logs):
if fel.id == highlight_id:
highlight_index = ix
break
if highlight_index:
fels.insert(0, fels.pop(highlight_index))
email_logs.insert(0, email_logs.pop(highlight_index))
return render_template("dashboard/refused_email.html", **locals())

View File

@ -669,9 +669,7 @@ def handle_bounce(
LOG.d("Create refused email %s", refused_email)
refused_email_url = (
URL + f"/dashboard/refused_email?highlight_fel_id=" + str(fel.id)
)
refused_email_url = URL + f"/dashboard/refused_email?highlight_id=" + str(fel.id)
# inform user if this is the first bounced email
if nb_bounced == 1: