From 4b6717d8dd83603ef24a0a92e71dbea19797e091 Mon Sep 17 00:00:00 2001 From: Son NK Date: Mon, 30 Dec 2019 17:52:08 +0100 Subject: [PATCH] Split domain detail into Info and DNS page --- .../dashboard/domain_detail/base.html | 35 +++++++++++++++++++ .../dns.html} | 11 +++--- .../dashboard/domain_detail/info.html | 23 ++++++++++++ app/dashboard/views/custom_domain.py | 2 +- app/dashboard/views/domain_detail.py | 28 ++++++++++++--- 5 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 app/dashboard/templates/dashboard/domain_detail/base.html rename app/dashboard/templates/dashboard/{domain_detail.html => domain_detail/dns.html} (97%) create mode 100644 app/dashboard/templates/dashboard/domain_detail/info.html diff --git a/app/dashboard/templates/dashboard/domain_detail/base.html b/app/dashboard/templates/dashboard/domain_detail/base.html new file mode 100644 index 00000000..81484eaa --- /dev/null +++ b/app/dashboard/templates/dashboard/domain_detail/base.html @@ -0,0 +1,35 @@ +{% extends 'default.html' %} + +{% set active_page = "custom_domain" %} + +{% block default_content %} +
+ + +
+
+
+
+ {% block domain_detail_content %} + {% endblock %} +
+
+
+
+
+ +{% endblock %} + + diff --git a/app/dashboard/templates/dashboard/domain_detail.html b/app/dashboard/templates/dashboard/domain_detail/dns.html similarity index 97% rename from app/dashboard/templates/dashboard/domain_detail.html rename to app/dashboard/templates/dashboard/domain_detail/dns.html index 4a0cbe03..dfb18a77 100644 --- a/app/dashboard/templates/dashboard/domain_detail.html +++ b/app/dashboard/templates/dashboard/domain_detail/dns.html @@ -1,14 +1,13 @@ -{% extends 'default.html' %} -{% set active_page = "custom_domain" %} +{% extends 'dashboard/domain_detail/base.html' %} + +{% set domain_detail_page = "dns" %} {% block title %} - {{ custom_domain.domain }} + {{ custom_domain.domain }} DNS {% endblock %} -{% block head %} -{% endblock %} -{% block default_content %} +{% block domain_detail_content %}

{{ custom_domain.domain }}

Please follow the steps below to set up your domain.
diff --git a/app/dashboard/templates/dashboard/domain_detail/info.html b/app/dashboard/templates/dashboard/domain_detail/info.html new file mode 100644 index 00000000..2bc85544 --- /dev/null +++ b/app/dashboard/templates/dashboard/domain_detail/info.html @@ -0,0 +1,23 @@ +{% extends 'dashboard/domain_detail/base.html' %} + +{% set domain_detail_page = "info" %} + +{% block title %} + {{ custom_domain.domain }} Info +{% endblock %} + +{% block domain_detail_content %} +

{{ custom_domain.domain }} + {% if custom_domain.verified %} + + {% else %} + 🚫 + {% endif %} +

+ +
Created {{ custom_domain.created_at | dt }}
+ + {{ nb_alias }} aliases + +{% endblock %} + diff --git a/app/dashboard/views/custom_domain.py b/app/dashboard/views/custom_domain.py index a894d9b6..be4cc1f5 100644 --- a/app/dashboard/views/custom_domain.py +++ b/app/dashboard/views/custom_domain.py @@ -40,7 +40,7 @@ def custom_domain(): return redirect( url_for( - "dashboard.domain_detail", custom_domain_id=new_custom_domain.id + "dashboard.domain_detail_dns", custom_domain_id=new_custom_domain.id ) ) diff --git a/app/dashboard/views/domain_detail.py b/app/dashboard/views/domain_detail.py index 69a7ffa0..d6ffc44c 100644 --- a/app/dashboard/views/domain_detail.py +++ b/app/dashboard/views/domain_detail.py @@ -10,12 +10,12 @@ from app.dns_utils import ( get_txt_record, ) from app.extensions import db -from app.models import CustomDomain +from app.models import CustomDomain, GenEmail -@dashboard_bp.route("/domains/", methods=["GET", "POST"]) +@dashboard_bp.route("/domains//dns", methods=["GET", "POST"]) @login_required -def domain_detail(custom_domain_id): +def domain_detail_dns(custom_domain_id): # only premium user can see custom domain if not current_user.is_premium(): flash("Only premium user can add custom domains", "warning") @@ -91,7 +91,7 @@ def domain_detail(custom_domain_id): name = custom_domain.domain CustomDomain.delete(custom_domain_id) db.session.commit() - flash(f"Domain {name} has been deleted successfully", "success") + flash(f"Domain {name} has been deleted", "success") return redirect(url_for("dashboard.custom_domain")) @@ -103,4 +103,22 @@ def domain_detail(custom_domain_id): dkim_record = f"v=DKIM1; k=rsa; p={DKIM_DNS_VALUE}" - return render_template("dashboard/domain_detail.html", **locals()) + return render_template("dashboard/domain_detail/dns.html", **locals()) + + +@dashboard_bp.route("/domains//info", methods=["GET", "POST"]) +@login_required +def domain_detail(custom_domain_id): + # only premium user can see custom domain + if not current_user.is_premium(): + flash("Only premium user can add custom domains", "warning") + return redirect(url_for("dashboard.index")) + + 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")) + + nb_alias = GenEmail.filter_by(custom_domain_id=custom_domain.id).count() + + return render_template("dashboard/domain_detail/info.html", **locals())