From 7e3bdfa49a3169d664235578aa4838e81dfeb624 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 17 Jan 2025 14:37:55 -0800 Subject: [PATCH] dynamicdns: List domains that have not had status update yet - This can happen if a domain is added while the app is disabled. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/dynamicdns/__init__.py | 14 ++++++++++++++ .../modules/dynamicdns/templates/dynamicdns.html | 10 +++++++++- plinth/modules/dynamicdns/views.py | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/plinth/modules/dynamicdns/__init__.py b/plinth/modules/dynamicdns/__init__.py index 033ac3d4f..4e3630b4c 100644 --- a/plinth/modules/dynamicdns/__init__.py +++ b/plinth/modules/dynamicdns/__init__.py @@ -240,6 +240,20 @@ def get_status(): status = kvstore.get_default('dynamicdns_status', '{}') status = json.loads(status) status.setdefault('domains', {}) + + domains = get_config()['domains'] + for domain in domains: + if domain not in status['domains']: + # No status available for newly configured domain + status['domains'][domain] = { + 'domain': domain, + 'result': False, + 'ip_address': None, + 'error_code': None, + 'error_message': None, + 'timestamp': 0, + } + return status diff --git a/plinth/modules/dynamicdns/templates/dynamicdns.html b/plinth/modules/dynamicdns/templates/dynamicdns.html index 55a498fba..79f494ece 100644 --- a/plinth/modules/dynamicdns/templates/dynamicdns.html +++ b/plinth/modules/dynamicdns/templates/dynamicdns.html @@ -40,12 +40,20 @@ {{ domain.domain }} - {{ domain.timestamp|timesince }} + + {% if domain.timestamp %} + {{ domain.timestamp|timesince }} + {% else %} + {% trans "Not yet" %} + {% endif %} + {% if domain.result %} {% trans "Success" %} + {% elif not domain.timestamp %} + - {% else %} {% trans "Failed" %} diff --git a/plinth/modules/dynamicdns/views.py b/plinth/modules/dynamicdns/views.py index 0e4e48d38..5d688a333 100644 --- a/plinth/modules/dynamicdns/views.py +++ b/plinth/modules/dynamicdns/views.py @@ -44,7 +44,7 @@ class DynamicDNSAppView(views.AppView): # Create naive datetime object in local timezone domain['timestamp'] = datetime.datetime.fromtimestamp( - domain['timestamp']) + domain['timestamp']) if domain['timestamp'] else None domains_status[domain_name] = domain if domain['error_code'] in self._error_messages: domain['error_message'] = self._error_messages[