Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
[deps] Bump openwisp-utils and re-format code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloCastellano committed Jun 4, 2020
1 parent 9d6644f commit ff7065f
Show file tree
Hide file tree
Showing 69 changed files with 1,935 additions and 1,100 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Expand Up @@ -19,17 +19,13 @@ before_install:
- pip install -U pip wheel setuptools
- pip install --no-cache-dir -U -r requirements-test.txt
- npm install -g jslint
- jslint django_netjsonconfig/static/django-netjsonconfig/js/*.js

install:
- pip install $DJANGO
- python setup.py -q develop

script:
- |
openwisp-utils-qa-checks \
--migration-path ./django_netjsonconfig/migrations/ \
--migration-module django_netjsonconfig
- ./run-qa-checks
- coverage run --source=django_netjsonconfig runtests.py

after_success:
Expand Down
11 changes: 9 additions & 2 deletions django_netjsonconfig/admin.py
@@ -1,7 +1,14 @@
from django.contrib import admin

from .base.admin import (AbstractConfigForm, AbstractConfigInline, AbstractDeviceAdmin, AbstractTemplateAdmin,
AbstractVpnAdmin, AbstractVpnForm, BaseForm)
from .base.admin import (
AbstractConfigForm,
AbstractConfigInline,
AbstractDeviceAdmin,
AbstractTemplateAdmin,
AbstractVpnAdmin,
AbstractVpnForm,
BaseForm,
)
from .models import Config, Device, Template, Vpn


Expand Down
36 changes: 24 additions & 12 deletions django_netjsonconfig/apps.py
Expand Up @@ -17,6 +17,7 @@ def __setmodels__(self):
This method allows third party apps to set their own custom models
"""
from .models import Config, VpnClient

self.config_model = Config
self.vpnclient_model = VpnClient

Expand All @@ -26,20 +27,31 @@ def connect_signals(self):
* automatic vpn client management on m2m_changed
* automatic vpn client removal
"""
m2m_changed.connect(self.config_model.clean_templates,
sender=self.config_model.templates.through)
m2m_changed.connect(self.config_model.templates_changed,
sender=self.config_model.templates.through)
m2m_changed.connect(self.config_model.manage_vpn_clients,
sender=self.config_model.templates.through)
post_delete.connect(self.vpnclient_model.post_delete,
sender=self.vpnclient_model)
m2m_changed.connect(
self.config_model.clean_templates,
sender=self.config_model.templates.through,
)
m2m_changed.connect(
self.config_model.templates_changed,
sender=self.config_model.templates.through,
)
m2m_changed.connect(
self.config_model.manage_vpn_clients,
sender=self.config_model.templates.through,
)
post_delete.connect(
self.vpnclient_model.post_delete, sender=self.vpnclient_model
)

def check_settings(self):
if settings.DEBUG is False and REGISTRATION_ENABLED and not SHARED_SECRET: # pragma: nocover
raise ImproperlyConfigured('Security error: NETJSONCONFIG_SHARED_SECRET is not set. '
'Please set it or disable auto-registration by setting '
'NETJSONCONFIG_REGISTRATION_ENABLED to False')
if (
settings.DEBUG is False and REGISTRATION_ENABLED and not SHARED_SECRET
): # pragma: nocover
raise ImproperlyConfigured(
'Security error: NETJSONCONFIG_SHARED_SECRET is not set. '
'Please set it or disable auto-registration by setting '
'NETJSONCONFIG_REGISTRATION_ENABLED to False'
)

def ready(self):
self.__setmodels__()
Expand Down

0 comments on commit ff7065f

Please sign in to comment.