create custom domain trash page
This commit is contained in:
parent
bad3c39921
commit
a3ff19dac4
|
@ -15,6 +15,11 @@
|
||||||
class="list-group-item list-group-item-action {{ 'active' if domain_detail_page == 'dns' }}">
|
class="list-group-item list-group-item-action {{ 'active' if domain_detail_page == 'dns' }}">
|
||||||
<span class="icon mr-3"><i class="fe fe-cloud"></i></span>DNS
|
<span class="icon mr-3"><i class="fe fe-cloud"></i></span>DNS
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a href="{{ url_for('dashboard.domain_detail_trash', custom_domain_id=custom_domain.id) }}"
|
||||||
|
class="list-group-item list-group-item-action {{ 'active' if domain_detail_page == 'trash' }}">
|
||||||
|
<span class="icon mr-3"><i class="fe fe-trash"></i></span>Deleted Alias
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
50
app/dashboard/templates/dashboard/domain_detail/trash.html
Normal file
50
app/dashboard/templates/dashboard/domain_detail/trash.html
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
{% extends 'dashboard/domain_detail/base.html' %}
|
||||||
|
|
||||||
|
{% set domain_detail_page = "trash" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ custom_domain.domain }} deleted aliases
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block domain_detail_content %}
|
||||||
|
<h1 class="h3"> {{ custom_domain.domain }} deleted alias (aka Trash)
|
||||||
|
<a class="ml-3 text-info" style="font-size: 12px" data-toggle="collapse" href="#howtouse" role="button"
|
||||||
|
aria-expanded="false" aria-controls="collapseExample">
|
||||||
|
How to use <i class="fe fe-chevrons-down"></i>
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div class="alert alert-primary collapse" id="howtouse" role="alert">
|
||||||
|
On this page you can view all aliases that have been deleted and belong to the domain
|
||||||
|
<b>{{ custom_domain.domain }}</b>. <br>
|
||||||
|
When an alias is in the trash, it cannot be re-created, either via the alias creation page or on-the-fly with the
|
||||||
|
domain catch-all option.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if domain_deleted_aliases | length > 0 %}
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="form-name" value="empty-all">
|
||||||
|
<button class="btn btn-outline-danger">Empty Trash</button>
|
||||||
|
<div class="small-text">
|
||||||
|
Remove all deleted aliases from the trash, allowing them to be re-created.
|
||||||
|
That operation is irreversible.
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
There's no deleted alias recorded for this domain.
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% for deleted_alias in domain_deleted_aliases %}
|
||||||
|
<hr>
|
||||||
|
<b>{{ deleted_alias.email }}</b> -
|
||||||
|
deleted {{ deleted_alias.created_at | dt }}
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="form-name" value="remove-single">
|
||||||
|
<input type="hidden" name="deleted-alias-id" value="{{ deleted_alias.id }}">
|
||||||
|
<button class="btn btn-sm btn-outline-warning">Remove from trash</button>
|
||||||
|
</form>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -10,7 +10,7 @@ from app.dns_utils import (
|
||||||
get_cname_record,
|
get_cname_record,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.models import CustomDomain, Alias
|
from app.models import CustomDomain, Alias, DomainDeletedAlias
|
||||||
|
|
||||||
|
|
||||||
@dashboard_bp.route("/domains/<int:custom_domain_id>/dns", methods=["GET", "POST"])
|
@dashboard_bp.route("/domains/<int:custom_domain_id>/dns", methods=["GET", "POST"])
|
||||||
|
@ -171,3 +171,57 @@ def domain_detail(custom_domain_id):
|
||||||
nb_alias = Alias.filter_by(custom_domain_id=custom_domain.id).count()
|
nb_alias = Alias.filter_by(custom_domain_id=custom_domain.id).count()
|
||||||
|
|
||||||
return render_template("dashboard/domain_detail/info.html", **locals())
|
return render_template("dashboard/domain_detail/info.html", **locals())
|
||||||
|
|
||||||
|
|
||||||
|
@dashboard_bp.route("/domains/<int:custom_domain_id>/trash", methods=["GET", "POST"])
|
||||||
|
@login_required
|
||||||
|
def domain_detail_trash(custom_domain_id):
|
||||||
|
custom_domain = CustomDomain.get(custom_domain_id)
|
||||||
|
if not custom_domain or custom_domain.user_id != current_user.id:
|
||||||
|
flash("You cannot see this page", "warning")
|
||||||
|
return redirect(url_for("dashboard.index"))
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
if request.form.get("form-name") == "empty-all":
|
||||||
|
DomainDeletedAlias.filter_by(domain_id=custom_domain.id).delete()
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
flash("All deleted aliases can now be re-created", "success")
|
||||||
|
return redirect(
|
||||||
|
url_for(
|
||||||
|
"dashboard.domain_detail_trash", custom_domain_id=custom_domain.id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
elif request.form.get("form-name") == "remove-single":
|
||||||
|
deleted_alias_id = request.form.get("deleted-alias-id")
|
||||||
|
deleted_alias = DomainDeletedAlias.get(deleted_alias_id)
|
||||||
|
if not deleted_alias or deleted_alias.domain_id != custom_domain.id:
|
||||||
|
flash("Unknown error, refresh the page", "warning")
|
||||||
|
return redirect(
|
||||||
|
url_for(
|
||||||
|
"dashboard.domain_detail_trash",
|
||||||
|
custom_domain_id=custom_domain.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
DomainDeletedAlias.delete(deleted_alias.id)
|
||||||
|
db.session.commit()
|
||||||
|
flash(
|
||||||
|
f"{deleted_alias.email} can now be re-created", "success",
|
||||||
|
)
|
||||||
|
|
||||||
|
return redirect(
|
||||||
|
url_for(
|
||||||
|
"dashboard.domain_detail_trash", custom_domain_id=custom_domain.id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
domain_deleted_aliases = DomainDeletedAlias.filter_by(
|
||||||
|
domain_id=custom_domain.id
|
||||||
|
).all()
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"dashboard/domain_detail/trash.html",
|
||||||
|
domain_deleted_aliases=domain_deleted_aliases,
|
||||||
|
custom_domain=custom_domain,
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue