Do not return contact alias activity on the contact manager page

This commit is contained in:
Son Nguyen Kim 2021-07-13 19:27:45 +02:00
parent fb88654d84
commit 45891bed36
2 changed files with 54 additions and 30 deletions

View File

@ -92,39 +92,43 @@
</span>
</div>
<div class="mb-2 text-muted small-text">
{% if contact_info.latest_email_log != None %}
{% set email_log = contact_info.latest_email_log %}
{% if email_log.is_reply %}
<i class="fa fa-reply mr-2" data-toggle="tooltip" title="Email reply/sent from alias"></i>
{{ email_log.created_at | dt }}
{% elif email_log.bounced %}
<span class="text-danger">
<i class="fa fa-warning mr-2" data-toggle="tooltip"
title="Email bounced and cannot be forwarded to your mailbox"></i>
{{ email_log.created_at | dt }}
</span>
{% elif email_log.blocked %}
<i class="fa fa-ban mr-2 text-danger" data-toggle="tooltip" title="Email blocked"></i>
{{ email_log.created_at | dt }}
{% else %}
<i class="fa fa-paper-plane mr-2" data-toggle="tooltip" title="Email sent to alias"></i>
{{ email_log.created_at | dt }}
{% endif %}
<br>
Contact created {{ contact.created_at | dt }}
{% else %}
No Activity. Contact created {{ contact.created_at | dt }}
{% endif %}
<div>
<span class="alias-activity">{{ contact_info.nb_forward }}</span> forwards,
<span class="alias-activity">{{ contact_info.nb_reply }}</span> replies
</div>
Contact created {{ contact.created_at | dt }}
</div>
{# <div class="mb-2 text-muted small-text">#}
{# {% if contact_info.latest_email_log != None %}#}
{# {% set email_log = contact_info.latest_email_log %}#}
{##}
{# {% if email_log.is_reply %}#}
{# <i class="fa fa-reply mr-2" data-toggle="tooltip" title="Email reply/sent from alias"></i>#}
{# {{ email_log.created_at | dt }}#}
{# {% elif email_log.bounced %}#}
{# <span class="text-danger">#}
{# <i class="fa fa-warning mr-2" data-toggle="tooltip"#}
{# title="Email bounced and cannot be forwarded to your mailbox"></i>#}
{# {{ email_log.created_at | dt }}#}
{# </span>#}
{# {% elif email_log.blocked %}#}
{# <i class="fa fa-ban mr-2 text-danger" data-toggle="tooltip" title="Email blocked"></i>#}
{# {{ email_log.created_at | dt }}#}
{# {% else %}#}
{# <i class="fa fa-paper-plane mr-2" data-toggle="tooltip" title="Email sent to alias"></i>#}
{# {{ email_log.created_at | dt }}#}
{# {% endif %}#}
{# <br>#}
{# Contact created {{ contact.created_at | dt }}#}
{# {% else %}#}
{# No Activity. Contact created {{ contact.created_at | dt }}#}
{# {% endif %}#}
{##}
{# <div>#}
{# <span class="alias-activity">{{ contact_info.nb_forward }}</span> forwards,#}
{# <span class="alias-activity">{{ contact_info.nb_reply }}</span> replies#}
{# </div>#}
{# </div>#}
<a href="{{ url_for('dashboard.contact_detail_route', contact_id=contact.id) }}">Edit ➡</a>
<form method="post">

View File

@ -61,6 +61,26 @@ class ContactInfo(object):
def get_contact_infos(alias: Alias, page=0, contact_id=None) -> [ContactInfo]:
q = db.session.query(
Contact,
)
if contact_id:
q = q.filter(Contact.id == contact_id)
q = q.order_by(Contact.id.desc()).limit(PAGE_LIMIT).offset(page * PAGE_LIMIT)
ret = []
for contact in q:
contact_info = ContactInfo(
contact=contact, nb_forward=0, nb_reply=0, latest_email_log=None
)
ret.append(contact_info)
return ret
def get_contact_infos2(alias: Alias, page=0, contact_id=None) -> [ContactInfo]:
"""if contact_id is set, only return the contact info for this contact"""
sub = (
db.session.query(