Skip to content

Commit

Permalink
[feature] Added all ow-controller modules
Browse files Browse the repository at this point in the history
  • Loading branch information
NoumbissiValere committed Dec 16, 2020
1 parent 5b3565e commit e27a573
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 44 deletions.
29 changes: 22 additions & 7 deletions .travis.yml
Expand Up @@ -3,25 +3,40 @@ cache: pip
dist: focal

python:
- "3.6"
- "3.7"
- "3.8"

env:
- DJANGO="django~=2.2"
- DJANGO="django~=3.0"
- DJANGO="django~=3.1"

addons:
apt:
packages:
- sqlite3
- fping
- gdal-bin
- libproj-dev
- libgeos-dev
- libspatialite-dev
- spatialite-bin
- libsqlite3-mod-spatialite


services:
- redis-server

branches:
only:
- master

install:
before_install:
- pip install -U "pip==20.2.4" wheel setuptools
- pip install $DJANGO
- python setup.py -q develop
- pip install -r requirements-test.txt

install:
- pip install -e .

script:
- openwisp-utils-qa-checks --skip-checkmigrations
- coverage run --source=owm_legacy runtests.py

after_success:
Expand Down
43 changes: 31 additions & 12 deletions README.rst
Expand Up @@ -3,17 +3,31 @@ django-owm-legacy

.. image:: https://travis-ci.org/openwisp/django-owm-legacy.svg
:target: https://travis-ci.org/openwisp/django-owm-legacy
:alt: CI build status

.. image:: https://coveralls.io/repos/openwisp/django-owm-legacy/badge.svg
:target: https://coveralls.io/r/openwisp/django-owm-legacy
:alt: Test Coverage

.. image:: https://requires.io/github/openwisp/django-owm-legacy/requirements.svg?branch=master
:target: https://requires.io/github/openwisp/django-owm-legacy/requirements/?branch=master
:alt: Requirements Status

.. image:: https://img.shields.io/gitter/room/nwjs/nw.js.svg
:target: https://gitter.im/openwisp/general
:alt: Chat

.. image:: https://badge.fury.io/py/django-owm-legacy.svg
:target: http://badge.fury.io/py/django-owm-legacy

.. image:: https://pepy.tech/badge/django-own-legacy
:target: https://pepy.tech/project/django-own-legacy
:alt: Downloads

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://pypi.org/project/black/
:alt: code style: black

------------

Legacy features of OpenWISP Manager reimplemented in django for `OpenWISP2
Expand Down Expand Up @@ -64,26 +78,32 @@ Add ``openwisp_controller`` and ``owm_legacy`` to ``INSTALLED_APPS`` as follow:
# allauth
'allauth',
'allauth.account',
'django_extensions',
# openwisp2 modules
'openwisp_controller.config',
'openwisp_controller.pki',
'openwisp_controller.geo',
'openwisp_controller.connection',
'openwisp_users',
# openwisp2 admin theme
# (must be loaded here)
'openwisp_utils.admin_theme',
'django.contrib.admin',
'django.forms',
# other dependencies
'sortedm2m',
'reversion',
'leaflet',
'flat_json_widget',
'owm_legacy',
'django.contrib.admin',
# ...
]
Other settings needed in ``settings.py``:

.. code-block:: python
EXTENDED_APPS = ('django_x509',)
EXTENDED_APPS = ('django_x509', 'django_loci')
AUTH_USER_MODEL = 'openwisp_users.User'
SITE_ID = 1
Expand Down Expand Up @@ -114,7 +134,8 @@ Install sqlite:

.. code-block:: shell
sudo apt-get install sqlite3 libsqlite3-dev
sudo apt install -y sqlite3 libsqlite3-dev openssl libssl-dev
sudo apt install -y gdal-bin libproj-dev libgeos-dev libspatialite-dev libsqlite3-mod-spatialite
Launch Redis:

Expand Down Expand Up @@ -144,6 +165,12 @@ Create database:
./manage.py migrate
./manage.py createsuperuser
Launch celery worker (for background jobs):

.. code-block:: shell
celery -A openwisp2 worker -l info
Launch development server:

.. code-block:: shell
Expand Down Expand Up @@ -176,15 +203,7 @@ checksums and download configuration archives.
Contributing
------------

1. Announce your intentions in the `OpenWISP Mailing List <https://groups.google.com/d/forum/openwisp>`_
2. Fork this repo and install it
3. Follow `PEP8, Style Guide for Python Code`_
4. Write code
5. Write tests for your code
6. Ensure all tests pass
7. Ensure test coverage is not under 90%
8. Document your changes
9. Send pull request
Please refer to the `OpenWISP contributing guidelines <http://openwisp.io/docs/developer/contributing.html>`_.

.. _PEP8, Style Guide for Python Code: http://www.python.org/dev/peps/pep-0008/

Expand Down
6 changes: 1 addition & 5 deletions owm_legacy/urls.py
Expand Up @@ -10,9 +10,5 @@
views.get_config_md5,
name='get_config_md5',
),
url(
r'^get_config/(?P<mac_address>[^/^.]+)$',
views.get_config,
name='get_config'
),
url(r'^get_config/(?P<mac_address>[^/^.]+)$', views.get_config, name='get_config'),
]
3 changes: 1 addition & 2 deletions requirements.txt
@@ -1,2 +1 @@
openwisp-controller~=0.8
django-model-utils<4.1.0,>=4.0.0
openwisp-controller~=0.8
2 changes: 1 addition & 1 deletion runtests.py
Expand Up @@ -5,7 +5,7 @@
import sys

sys.path.insert(0, "tests")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "openwisp2.settings")

if __name__ == "__main__":
from django.core.management import execute_from_command_line
Expand Down
2 changes: 1 addition & 1 deletion tests/manage.py
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'openwisp2.settings')

from django.core.management import execute_from_command_line

Expand Down
3 changes: 3 additions & 0 deletions tests/openwisp2/__init__.py
@@ -0,0 +1,3 @@
from .celery import app as celery_app

__all__ = ['celery_app']
11 changes: 11 additions & 0 deletions tests/openwisp2/celery.py
@@ -0,0 +1,11 @@
import os

from celery import Celery

# Replace 'openwisp2.settings' with path to your settings.py should be relative
# from the location where celery command is executed.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'openwisp2.settings')

app = Celery('openwisp2')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
39 changes: 24 additions & 15 deletions tests/settings.py → tests/openwisp2/settings.py
Expand Up @@ -7,7 +7,10 @@
ALLOWED_HOSTS = []

DATABASES = {
'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'owm-legacy.db',}
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': 'owm-legacy.db',
}
}

SECRET_KEY = 'fn)t*+$)ugeyip6-#txyy$5wf2ervc0d2n#h)qb)y5@ly$t*@w'
Expand All @@ -18,6 +21,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'django.contrib.sites',
# allauth
'allauth',
Expand All @@ -26,26 +30,32 @@
# openwisp2 modules
'openwisp_controller.config',
'openwisp_controller.pki',
'openwisp_controller.geo',
'openwisp_controller.connection',
'openwisp_users',
# openwisp2 admin theme
# (must be loaded here)
'openwisp_utils.admin_theme',
'django.contrib.admin',
'django.forms',
# other dependencies
'sortedm2m',
'reversion',
'leaflet',
'flat_json_widget',
'owm_legacy',
'django.contrib.admin',
]


EXTENDED_APPS = ('django_x509',)
EXTENDED_APPS = ('django_x509', 'django_loci')

AUTH_USER_MODEL = 'openwisp_users.User'
SITE_ID = 1

STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'openwisp_utils.staticfiles.DependencyFinder',
]

MIDDLEWARE = [
Expand All @@ -58,7 +68,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'urls'
ROOT_URLCONF = 'openwisp2.urls'

TIME_ZONE = 'Europe/Rome'
LANGUAGE_CODE = 'en-gb'
Expand All @@ -68,6 +78,13 @@
STATIC_URL = '/static/'
CORS_ORIGIN_ALLOW_ALL = True


ASGI_APPLICATION = 'openwisp_controller.geo.channels.routing.channel_routing'
CHANNEL_LAYERS = {
# in production you should use another channel layer backend
'default': {'BACKEND': 'channels.layers.InMemoryChannelLayer'},
}

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand All @@ -83,9 +100,11 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'openwisp_utils.admin_theme.context_processor.menu_items',
'openwisp_notifications.context_processors.notification_api_settings',
],
},
},
}
]

FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
Expand All @@ -109,16 +128,6 @@
'max_retries': 10,
}

# during development only
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

EMAIL_PORT = '1025' # for testing purposes
LOGIN_REDIRECT_URL = 'admin:index'
ACCOUNT_LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
OPENWISP_ORGANIZATION_USER_ADMIN = True

OPENWISP_CONTROLLER_CONTEXT = {'vpnserver1': 'vpn.testdomain.com'}


# local settings must be imported before test runner
# otherwise they'll be ignored
Expand Down
2 changes: 1 addition & 1 deletion tests/urls.py → tests/openwisp2/urls.py
Expand Up @@ -7,8 +7,8 @@

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('owm_legacy.urls', namespace='owm_legacy')),
url(r'', include('openwisp_controller.urls')),
url(r'^', include('owm_legacy.urls', namespace='owm_legacy')),
]

urlpatterns += staticfiles_urlpatterns()

0 comments on commit e27a573

Please sign in to comment.