From bcb2657de3a9c7d0c3a87d96c2b6659e5f53672f Mon Sep 17 00:00:00 2001
From: Son NK <>
Date: Tue, 24 Nov 2020 12:02:47 +0100
Subject: [PATCH] add remove button on custom domain name
---
.../dashboard/domain_detail/info.html | 5 ++++-
app/dashboard/views/domain_detail.py | 20 +++++++++++++------
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/app/dashboard/templates/dashboard/domain_detail/info.html b/app/dashboard/templates/dashboard/domain_detail/info.html
index bababf01..fa03e344 100644
--- a/app/dashboard/templates/dashboard/domain_detail/info.html
+++ b/app/dashboard/templates/dashboard/domain_detail/info.html
@@ -72,7 +72,10 @@
name="alias-name"
placeholder="Alias name">
-
+
+ {% if custom_domain.name %}
+
+ {% endif %}
diff --git a/app/dashboard/views/domain_detail.py b/app/dashboard/views/domain_detail.py
index a7c7d280..07732bab 100644
--- a/app/dashboard/views/domain_detail.py
+++ b/app/dashboard/views/domain_detail.py
@@ -154,12 +154,20 @@ def domain_detail(custom_domain_id):
url_for("dashboard.domain_detail", custom_domain_id=custom_domain.id)
)
elif request.form.get("form-name") == "set-name":
- custom_domain.name = request.form.get("alias-name").replace("\n", "")
- db.session.commit()
- flash(
- f"Default alias name for Domain {custom_domain.domain} has been set",
- "success",
- )
+ if request.form.get("action") == "save":
+ custom_domain.name = request.form.get("alias-name").replace("\n", "")
+ db.session.commit()
+ flash(
+ f"Default alias name for Domain {custom_domain.domain} has been set",
+ "success",
+ )
+ else:
+ custom_domain.name = None
+ db.session.commit()
+ flash(
+ f"Default alias name for Domain {custom_domain.domain} has been removed",
+ "info",
+ )
return redirect(
url_for("dashboard.domain_detail", custom_domain_id=custom_domain.id)