Added a --full option to domain list

This commit is contained in:
theo@manjaro 2022-07-11 15:48:30 +02:00
parent 0b5c96e249
commit ba061a49e4
2 changed files with 10 additions and 19 deletions

View file

@ -446,6 +446,10 @@ domain:
--auto-push: --auto-push:
help: Only display domains that are pushed automatically help: Only display domains that are pushed automatically
action: store_true action: store_true
-f:
full: --full
action: store_true
help: Display more information
### domain_add() ### domain_add()
add: add:
@ -586,15 +590,6 @@ domain:
path: path:
help: The path to check (e.g. /coffee) help: The path to check (e.g. /coffee)
### domain_isdyndns()
isdyndns:
action_help: Check if a domain is a dyndns one
api: GET /domain/<domain>/isdyndns
arguments:
domain:
help: The domain to test (e.g. your.domain.tld)
extra:
pattern: *pattern_domain
subcategories: subcategories:
dyndns: dyndns:

View file

@ -52,7 +52,7 @@ DOMAIN_SETTINGS_DIR = "/etc/yunohost/domains"
domain_list_cache: Dict[str, Any] = {} domain_list_cache: Dict[str, Any] = {}
def domain_list(exclude_subdomains=False,auto_push=False): def domain_list(exclude_subdomains=False,auto_push=False,full=False):
""" """
List domains List domains
@ -97,6 +97,11 @@ def domain_list(exclude_subdomains=False,auto_push=False):
if exclude_subdomains: if exclude_subdomains:
return {"domains": result_list, "main": _get_maindomain()} return {"domains": result_list, "main": _get_maindomain()}
if full:
for i in range(len(result_list)):
domain = result_list[i]
result_list[i] = {'name':domain,'isdyndns': is_yunohost_dyndns_domain(domain)}
domain_list_cache = {"domains": result_list, "main": _get_maindomain()} domain_list_cache = {"domains": result_list, "main": _get_maindomain()}
return domain_list_cache return domain_list_cache
@ -458,15 +463,6 @@ def domain_url_available(domain, path):
return len(_get_conflicting_apps(domain, path)) == 0 return len(_get_conflicting_apps(domain, path)) == 0
def domain_isdyndns(domain):
"""
Returns if a domain is a DynDNS one ( used via the web API )
Arguments:
domain -- the domain to check
"""
return is_yunohost_dyndns_domain(domain)
def _get_maindomain(): def _get_maindomain():
with open("/etc/yunohost/current_host", "r") as f: with open("/etc/yunohost/current_host", "r") as f:
maindomain = f.readline().rstrip() maindomain = f.readline().rstrip()