From 5af974fc5d4681e92319c58e00867008890c32f9 Mon Sep 17 00:00:00 2001 From: doanguyen Date: Sun, 5 Jan 2020 22:49:48 +0100 Subject: [PATCH] alias log dashboard --- app/config.py | 4 +- .../templates/dashboard/alias_log.html | 93 ++++++++++++++++++- app/dashboard/views/alias_log.py | 9 ++ 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/app/config.py b/app/config.py index 11608748..6da3176c 100644 --- a/app/config.py +++ b/app/config.py @@ -31,7 +31,7 @@ COLOR_LOG = "COLOR_LOG" in os.environ PROMO_CODE = "SIMPLEISBETTER" # Debug mode -DEBUG = os.environ['DEBUG'] +DEBUG = os.environ["DEBUG"] # Server url URL = os.environ["URL"] print(">>> URL:", URL) @@ -45,7 +45,7 @@ SUPPORT_EMAIL = os.environ["SUPPORT_EMAIL"] ADMIN_EMAIL = os.environ.get("ADMIN_EMAIL") MAX_NB_EMAIL_FREE_PLAN = int(os.environ["MAX_NB_EMAIL_FREE_PLAN"]) # allow to override postfix server locally -POSTFIX_SERVER = os.environ.get("POSTFIX_SERVER", "1.1.1.1") +POSTFIX_SERVER = os.environ.get("POSTFIX_SERVER", "0.0.0.0") # list of (priority, email server) EMAIL_SERVERS_WITH_PRIORITY = eval( diff --git a/app/dashboard/templates/dashboard/alias_log.html b/app/dashboard/templates/dashboard/alias_log.html index 59c40d06..2382d3c1 100644 --- a/app/dashboard/templates/dashboard/alias_log.html +++ b/app/dashboard/templates/dashboard/alias_log.html @@ -1,7 +1,68 @@ {% extends 'default.html' %} {% set active_page = "dashboard" %} +{% block head %} + +{% endblock %} {% block title %} Alias Activity {% endblock %} @@ -12,7 +73,37 @@ {{ alias }} - +
+
+
+ + {{ total }} + Email Handled +
+
+
+
+ + {{ email_forwarded }} + Email Forwarded +
+
+
+
+ + {{ email_replied }} + Email Replied +
+
+
+
+ + {{ email_forwarded }} + Email Blocked +
+
+
+

Activities

{% for log in logs %}
diff --git a/app/dashboard/views/alias_log.py b/app/dashboard/views/alias_log.py index d7ec6388..afc790f2 100644 --- a/app/dashboard/views/alias_log.py +++ b/app/dashboard/views/alias_log.py @@ -38,6 +38,15 @@ def alias_log(alias, page_id): return redirect(url_for("dashboard.index")) logs = get_alias_log(gen_email, page_id) + base = ( + db.session.query(ForwardEmail, ForwardEmailLog) + .filter(ForwardEmail.id == ForwardEmailLog.forward_id) + .filter(ForwardEmail.gen_email_id == gen_email.id) + ) + total = base.count() + email_forwarded = base.filter(ForwardEmailLog.is_reply == False).count() + email_replied = base.filter(ForwardEmailLog.is_reply == True).count() + email_blocked = base.filter(ForwardEmailLog.blocked == True).count() last_page = ( len(logs) < _LIMIT ) # lightweight pagination without counting all objects