Explorar o código

Add deleted alias page

Son NK %!s(int64=5) %!d(string=hai) anos
pai
achega
8f8857704a

+ 1 - 0
app/dashboard/__init__.py

@@ -15,4 +15,5 @@ from .views import (
     lifetime_licence,
     directory,
     mailbox,
+    deleted_alias,
 )

+ 25 - 0
app/dashboard/templates/dashboard/deleted_alias.html

@@ -0,0 +1,25 @@
+{% extends 'default.html' %}
+
+{% block title %}
+  Deleted Aliases
+{% endblock %}
+
+{% block head %}
+{% endblock %}
+
+{% block default_content %}
+  <div style="max-width: 60em; margin: auto">
+    <h1 class="h3 mb-5"> Deleted Aliases </h1>
+
+    {% for deleted_alias in deleted_aliases %}
+      <div class="my-4 p-4 card border-light">
+        {{ deleted_alias.email }}
+        <div class="small-text">
+          Deleted {{ deleted_alias.created_at | dt }}
+        </div>
+      </div>
+    {% endfor %}
+
+
+  </div>
+{% endblock %}

+ 20 - 4
app/dashboard/templates/dashboard/setting.html

@@ -135,10 +135,10 @@
         <form method="post">
           <input type="hidden" name="form-name" value="notification-preference">
           <div class="form-check">
-              <input type="checkbox" id="notification" name="notification" {% if current_user.notification %}
-                     checked {% endif %} class="form-check-input">
-              <label for="notification">I want to receive your newsletter</label>
-            </div>
+            <input type="checkbox" id="notification" name="notification" {% if current_user.notification %}
+                   checked {% endif %} class="form-check-input">
+            <label for="notification">I want to receive your newsletter</label>
+          </div>
           <button type="submit" class="btn btn-outline-primary">Submit</button>
         </form>
       </div>
@@ -160,6 +160,22 @@
       </div>
     {% endif %}
 
+    <div class="card">
+      <div class="card-body">
+        <div class="card-title">Deleted Aliases
+          <div class="small-text mt-1 mb-3" style="max-width: 40rem">
+            When an alias is deleted, all its activities are deleted and no emails can be sent to it. <br>
+            It is moved to another location and only used to check when new alias is created. <br>
+            This check is necessary to avoid someone else accidentally taking this alias. <br>
+            Because in this case, the other person might receive inadvertently information that belong to you. <br>
+          </div>
+        </div>
+        <a href="{{ url_for('dashboard.deleted_alias_route') }}" class="btn btn-outline-primary">
+          See deleted aliases
+        </a>
+      </div>
+    </div>
+
     <div class="card">
       <div class="card-body">
         <div class="card-title">Export Data

+ 13 - 0
app/dashboard/views/deleted_alias.py

@@ -0,0 +1,13 @@
+from flask import render_template
+from flask_login import login_required, current_user
+
+from app.dashboard.base import dashboard_bp
+from app.models import DeletedAlias
+
+
+@dashboard_bp.route("/deleted_alias", methods=["GET", "POST"])
+@login_required
+def deleted_alias_route():
+    deleted_aliases = DeletedAlias.query.filter_by(user_id=current_user.id)
+
+    return render_template("dashboard/deleted_alias.html", **locals())

+ 5 - 0
server.py

@@ -49,6 +49,7 @@ from app.models import (
     LifetimeCoupon,
     Directory,
     Mailbox,
+    DeletedAlias,
 )
 from app.monitor.base import monitor_bp
 from app.oauth.base import oauth_bp
@@ -184,6 +185,10 @@ def fake_data():
     Mailbox.create(user_id=user.id, email="ab@cd.ef", verified=True)
     db.session.commit()
 
+    DeletedAlias.create(user_id=user.id, email="d1@ab.cd")
+    DeletedAlias.create(user_id=user.id, email="d2@ab.cd")
+    db.session.commit()
+
 
 @login_manager.user_loader
 def load_user(user_id):