autodns: Improve handling of the subdomain case

This commit is contained in:
Alexandre Aubin 2021-09-18 23:10:17 +02:00
parent 5812c8f1ae
commit fa31d49bf9
2 changed files with 13 additions and 3 deletions

View file

@ -318,7 +318,8 @@
"domain_remove_confirm_apps_removal": "Removing this domain will remove those applications:\n{apps}\n\nAre you sure you want to do that? [{answers}]", "domain_remove_confirm_apps_removal": "Removing this domain will remove those applications:\n{apps}\n\nAre you sure you want to do that? [{answers}]",
"domain_uninstall_app_first": "Those applications are still installed on your domain:\n{apps}\n\nPlease uninstall them using 'yunohost app remove the_app_id' or move them to another domain using 'yunohost app change-url the_app_id' before proceeding to domain removal", "domain_uninstall_app_first": "Those applications are still installed on your domain:\n{apps}\n\nPlease uninstall them using 'yunohost app remove the_app_id' or move them to another domain using 'yunohost app change-url the_app_id' before proceeding to domain removal",
"domain_registrar_is_not_configured": "The registrar is not yet configured for domain {domain}.", "domain_registrar_is_not_configured": "The registrar is not yet configured for domain {domain}.",
"domain_dns_push_not_applicable": "The DNS push feature is not applicable to domain {domain}", "domain_dns_push_not_applicable": "The DNS push feature is not applicable to domain {domain}. You should manually configure your DNS records following the documentation at https://yunohost.org/dns_config.",
"domain_dns_push_managed_in_parent_domain": "The DNS push feature is managed in the parent domain {parent_domain}.",
"domain_dns_push_failed_to_authenticate": "Failed to authenticate on registrar's API. Most probably the credentials are incorrect? (Error: {error})", "domain_dns_push_failed_to_authenticate": "Failed to authenticate on registrar's API. Most probably the credentials are incorrect? (Error: {error})",
"domain_config_mail_in": "Incoming emails", "domain_config_mail_in": "Incoming emails",
"domain_config_mail_out": "Outgoing emails", "domain_config_mail_out": "Outgoing emails",

View file

@ -470,11 +470,17 @@ def _get_registrar_config_section(domain):
# If parent domain exists in yunohost # If parent domain exists in yunohost
parent_domain = domain.split(".", 1)[1] parent_domain = domain.split(".", 1)[1]
if parent_domain in domain_list()["domains"]: if parent_domain in domain_list()["domains"]:
if Moulinette.interface.type = "api":
parent_domain_link = "[{parent_domain}](#/domains/{parent_domain}/config)"
else:
parent_domain_link = parent_domain
registrar_infos["registrar"] = OrderedDict({ registrar_infos["registrar"] = OrderedDict({
"type": "alert", "type": "alert",
"style": "info", "style": "info",
"ask": f"This domain is a subdomain of {parent_domain}. DNS registrar configuration should be managed in {parent_domain}'s configuration panel.", # FIXME: i18n "ask": f"This domain is a subdomain of {parent_domain_link}. DNS registrar configuration should be managed in {parent_domain}'s configuration panel.", # FIXME: i18n
"value": None "value": "parent_domain"
}) })
return OrderedDict(registrar_infos) return OrderedDict(registrar_infos)
@ -544,6 +550,9 @@ def domain_dns_push(operation_logger, domain, dry_run=False, force=False, purge=
if not registrar or registrar in ["None", "yunohost"]: if not registrar or registrar in ["None", "yunohost"]:
raise YunohostValidationError("domain_dns_push_not_applicable", domain=domain) raise YunohostValidationError("domain_dns_push_not_applicable", domain=domain)
if registrar == "parent_domain":
raise YunohostValidationError("domain_dns_push_managed_in_parent_domain", domain=domain, parent_domain=registrar)
base_dns_zone = _get_dns_zone_for_domain(domain) base_dns_zone = _get_dns_zone_for_domain(domain)
registrar_credentials = settings registrar_credentials = settings