Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Feb 19, 2018
2 parents d7ead06 + b050af8 commit 48f4a2c
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 12 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ python:
- "3.4"
- "2.7"

env:
- DJANGO="django>=1.11,<1.12"
- DJANGO="django>=2.0,<2.1"

matrix:
exclude:
- python: "2.7"
env: DJANGO="django>=2.0,<2.1"

branches:
only:
- master
Expand All @@ -26,6 +35,11 @@ before_install:
- ./runisort

install:
- pip install $DJANGO
- pip install https://github.com/openwisp/django-netjsonconfig/tarball/master
- pip install https://github.com/openwisp/django-loci/tarball/master
- pip install https://github.com/openwisp/django-x509/tarball/master
- pip install https://github.com/openwisp/openwisp-users/tarball/master
- python setup.py -q develop
- if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then pip install git+git://github.com/tinio/pysqlite.git@extension-enabled#egg=pysqlite; fi

Expand Down
1 change: 1 addition & 0 deletions openwisp_controller/config/controller/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

from . import views

app_name = 'openwisp_controller'
urlpatterns = get_controller_urls(views)
15 changes: 10 additions & 5 deletions openwisp_controller/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Config(OrgMixin, TemplatesVpnMixin, AbstractConfig):
"""
Concrete Config model
"""
device = models.OneToOneField('config.Device')
device = models.OneToOneField('config.Device', on_delete=models.CASCADE)
templates = SortedManyToManyField('config.Template',
related_name='config_relations',
verbose_name=_('templates'),
Expand Down Expand Up @@ -132,7 +132,8 @@ class Template(ShareableOrgMixin, AbstractTemplate):
vpn = models.ForeignKey('config.Vpn',
verbose_name=_('VPN'),
blank=True,
null=True)
null=True,
on_delete=models.CASCADE)

class Meta(AbstractTemplate.Meta):
abstract = False
Expand All @@ -146,12 +147,15 @@ class Vpn(ShareableOrgMixin, AbstractVpn):
"""
openwisp-controller VPN model
"""
ca = models.ForeignKey('pki.Ca', verbose_name=_('Certification Authority'))
ca = models.ForeignKey('pki.Ca',
verbose_name=_('Certification Authority'),
on_delete=models.CASCADE)
cert = models.ForeignKey('pki.Cert',
verbose_name=_('x509 Certificate'),
help_text=_('leave blank to create automatically'),
blank=True,
null=True)
null=True,
on_delete=models.CASCADE)

class Meta(AbstractVpn.Meta):
abstract = False
Expand Down Expand Up @@ -201,7 +205,8 @@ class OrganizationConfigSettings(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
organization = models.OneToOneField('openwisp_users.Organization',
verbose_name=_('organization'),
related_name='config_settings')
related_name='config_settings',
on_delete=models.CASCADE)
registration_enabled = models.BooleanField(_('auto-registration enabled'),
default=True,
help_text=_('Whether automatic registration of '
Expand Down
2 changes: 2 additions & 0 deletions openwisp_controller/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from . import views

app_name = 'openwisp_controller'

urlpatterns = [
url(r'^config/get-default-templates/(?P<organization_id>[^/]+)/$',
views.get_default_templates,
Expand Down
5 changes: 4 additions & 1 deletion openwisp_controller/config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ def get_default_templates(request, organization_id):
returns default templates of specified organization
"""
user = request.user
if not user.is_authenticated() and not user.is_staff:
authenticated = user.is_authenticated
if callable(authenticated):
authenticated = authenticated()
if not authenticated and not user.is_staff:
return HttpResponse(status=403)
org = get_object_or_404(Organization, pk=organization_id, is_active=True)
templates = get_default_templates_queryset(org.pk, model=Template).only('id')
Expand Down
2 changes: 2 additions & 0 deletions openwisp_controller/geo/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from . import views

app_name = 'openwisp_controller'

urlpatterns = [
url(r'^api/device-location/(?P<pk>[^/]+)/$',
views.device_location,
Expand Down
4 changes: 2 additions & 2 deletions openwisp_controller/geo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Meta(AbstractLocation.Meta):


class FloorPlan(OrgMixin, AbstractFloorPlan):
location = models.ForeignKey(Location)
location = models.ForeignKey(Location, models.CASCADE)

class Meta(AbstractFloorPlan.Meta):
abstract = False
Expand All @@ -28,7 +28,7 @@ class DeviceLocation(ValidateOrgMixin, AbstractObjectLocation):
content_type = None
object_id = None
# reuse the same generic attribute name used in django-loci
content_object = models.OneToOneField('config.Device')
content_object = models.OneToOneField('config.Device', models.CASCADE)
# override parent foreign key targets
location = models.ForeignKey(Location, models.PROTECT,
blank=True, null=True)
Expand Down
2 changes: 1 addition & 1 deletion openwisp_controller/pki/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Cert(ShareableOrgMixin, AbstractCert):
"""
openwisp-controller cert model
"""
ca = models.ForeignKey(Ca, verbose_name=_('CA'))
ca = models.ForeignKey(Ca, verbose_name=_('CA'), on_delete=models.CASCADE)

class Meta(AbstractCert.Meta):
abstract = False
Expand Down
2 changes: 2 additions & 0 deletions openwisp_controller/pki/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from . import views

app_name = 'openwisp_controller'

urlpatterns = [
url(r'^x509/ca/(?P<pk>[^/]+).crl$', views.crl, name='crl'),
]
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
'openwisp_utils.staticfiles.DependencyFinder',
]

MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand Down
4 changes: 2 additions & 2 deletions tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.core.urlresolvers import reverse_lazy
from django.urls import reverse_lazy
from django.views.generic import RedirectView

from openwisp_utils.admin_theme.admin import admin, openwisp_admin
Expand All @@ -12,7 +12,7 @@
redirect_view = RedirectView.as_view(url=reverse_lazy('admin:index'))

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
url(r'', include('openwisp_controller.urls')),
url(r'^$', redirect_view, name='index')
]
Expand Down

0 comments on commit 48f4a2c

Please sign in to comment.