Add deleted alias page

This commit is contained in:
Son NK 2020-02-15 21:47:27 +07:00
parent 8bbecb2cd1
commit 8f8857704a
5 changed files with 64 additions and 4 deletions

View File

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

View File

@ -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 %}

View File

@ -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

View File

@ -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())

View File

@ -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):