Add/remove domain name in names module when domain name is configured in dynamicdns module

Signed-off-by: Hemanth Kumar Veeranki <hemanthveeranki@gmail.com>
This commit is contained in:
Hemanth Kumar Veeranki 2017-07-26 23:30:00 +05:30 committed by James Valleroy
parent d8849114ba
commit 1e19508b95
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 15 additions and 0 deletions

View File

@ -23,8 +23,10 @@ from django.utils.translation import ugettext_lazy as _
from plinth import cfg
from plinth.menu import main_menu
from plinth.signals import domain_added
from plinth.utils import format_lazy
from . import dynamicdns
version = 1
@ -56,6 +58,11 @@ def init():
"""Initialize the module."""
menu = main_menu.get('system')
menu.add_urlname(title, 'glyphicon-refresh', 'dynamicdns:index')
current_status = dynamicdns.get_status()
if current_status['enabled']:
domain_added.send_robust(
sender='dynamicdns', domain_type='dynamicdnsservice',
name=current_status['dynamicdns_domain'], description=_('Dynamic DNS Service'))
def setup(helper, old_version=None):

View File

@ -26,6 +26,7 @@ import logging
from plinth import actions
from plinth import cfg
from plinth.modules import dynamicdns
from plinth.signals import domain_added, domain_removed
from plinth.utils import format_lazy
logger = logging.getLogger(__name__)
@ -356,9 +357,16 @@ def _apply_changes(request, old_status, new_status):
input=new_status['dynamicdns_secret'].encode())
if old_status['enabled']:
domain_removed.send_robust(
sender='dynamicdns', domain_type='dynamicdnsservice',
name = old_status['dynamicdns_domain']
)
_run(['stop'])
if new_status['enabled']:
domain_added.send_robust(
sender='dynamicdns', domain_type='dynamicdnsservice',
name=new_status['dynamicdns_domain'], description=_('Dynamic DNS Service'))
_run(['start'])
messages.success(request, _('Configuration updated'))