From 0930548640aa60d2d9c54c5b794dc162aa1d8551 Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 7 Oct 2022 18:03:51 +0200 Subject: [PATCH 1/3] add title to DNS registrar section --- share/config_domain.toml | 4 +--- src/dns.py | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/config_domain.toml b/share/config_domain.toml index 0a3ba96cc..88714525d 100644 --- a/share/config_domain.toml +++ b/share/config_domain.toml @@ -50,9 +50,7 @@ name = "Features" name = "DNS" [dns.registrar] - optional = true - - # This part is automatically generated in DomainConfigPanel + # This part is automatically generated in DomainConfigPanel # [dns.advanced] # diff --git a/src/dns.py b/src/dns.py index 1d0b4486f..d96041e75 100644 --- a/src/dns.py +++ b/src/dns.py @@ -512,7 +512,9 @@ def _get_registrar_config_section(domain): from lexicon.providers.auto import _relevant_provider_for_domain - registrar_infos = {} + registrar_infos = { + "name": "Registrar infos", + } dns_zone = _get_dns_zone_for_domain(domain) From 5cfbcd4c494e161e77f6382bdd313fcf3ebc1877 Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 7 Oct 2022 18:08:25 +0200 Subject: [PATCH 2/3] domaindns: update _get_parent_domain_of defaults and calls to --- src/dns.py | 15 ++++++++------- src/domain.py | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/dns.py b/src/dns.py index d96041e75..795e056ea 100644 --- a/src/dns.py +++ b/src/dns.py @@ -41,6 +41,7 @@ from yunohost.domain import ( _get_domain_settings, _set_domain_settings, _list_subdomains_of, + _get_parent_domain_of, ) from yunohost.utils.dns import dig, is_yunohost_dyndns_domain, is_special_use_tld from yunohost.utils.error import YunohostValidationError, YunohostError @@ -446,8 +447,8 @@ def _get_dns_zone_for_domain(domain): # This is another strick to try to prevent this function from being # a bottleneck on system with 1 main domain + 10ish subdomains # when building the dns conf for the main domain (which will call domain_config_get, etc...) - parent_domain = domain.split(".", 1)[1] - if parent_domain in domain_list()["domains"]: + parent_domain = _get_parent_domain_of(domain) + if parent_domain: parent_cache_file = f"{cache_folder}/{parent_domain}" if ( os.path.exists(parent_cache_file) @@ -519,12 +520,12 @@ def _get_registrar_config_section(domain): dns_zone = _get_dns_zone_for_domain(domain) # If parent domain exists in yunohost - parent_domain = domain.split(".", 1)[1] - if parent_domain in domain_list()["domains"]: + parent_domain = _get_parent_domain_of(domain, topest=True) + if parent_domain: # Dirty hack to have a link on the webadmin if Moulinette.interface.type == "api": - parent_domain_link = f"[{parent_domain}](#/domains/{parent_domain}/config)" + parent_domain_link = f"[{parent_domain}](#/domains/{parent_domain}/dns)" else: parent_domain_link = parent_domain @@ -534,7 +535,7 @@ def _get_registrar_config_section(domain): "style": "info", "ask": m18n.n( "domain_dns_registrar_managed_in_parent_domain", - parent_domain=domain, + parent_domain=parent_domain, parent_domain_link=parent_domain_link, ), "value": "parent_domain", @@ -649,7 +650,7 @@ def domain_dns_push(operation_logger, domain, dry_run=False, force=False, purge= return {} if registrar == "parent_domain": - parent_domain = domain.split(".", 1)[1] + parent_domain = _get_parent_domain_of(domain, topest=True) registar, registrar_credentials = _get_registar_settings(parent_domain) if any(registrar_credentials.values()): raise YunohostValidationError( diff --git a/src/domain.py b/src/domain.py index 650b5e20f..0b904b70d 100644 --- a/src/domain.py +++ b/src/domain.py @@ -95,7 +95,7 @@ def _get_domains(exclude_subdomains=False): return [ domain for domain in domain_list_cache - if not _get_parent_domain_of(domain, return_self=False) + if not _get_parent_domain_of(domain) ] return domain_list_cache @@ -167,7 +167,7 @@ def domain_info(domain): "registrar": registrar, "apps": apps, "main": _get_maindomain() == domain, - "topest_parent": _get_parent_domain_of(domain, return_self=True, topest=True), + "topest_parent": _get_parent_domain_of(domain, topest=True), # TODO : add parent / child domains ? } @@ -189,7 +189,7 @@ def _list_subdomains_of(parent_domain): return out -def _get_parent_domain_of(domain, return_self=True, topest=False): +def _get_parent_domain_of(domain, return_self=False, topest=False): _assert_domain_exists(domain) From 1fe507651b1ab5646878aa797a85af88abed2055 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 7 Oct 2022 17:03:07 +0200 Subject: [PATCH 3/3] domain: i18n for config panel section --- src/dns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dns.py b/src/dns.py index 795e056ea..318a5fcde 100644 --- a/src/dns.py +++ b/src/dns.py @@ -514,7 +514,7 @@ def _get_registrar_config_section(domain): from lexicon.providers.auto import _relevant_provider_for_domain registrar_infos = { - "name": "Registrar infos", + "name": m18n.n('registrar_infos'), # This is meant to name the config panel section, for proper display in the webadmin } dns_zone = _get_dns_zone_for_domain(domain)