Skip to content

Commit

Permalink
[feature] Added notification widget from openwisp-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy authored Jul 19, 2020
1 parent 8581ee9 commit c2f6ae8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 35 deletions.
33 changes: 5 additions & 28 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,26 @@ Follow the setup instructions of `openwisp-controller
INSTALLED_APPS = [
# django apps
# openwisp2 admin theme (must be loaded here)
'openwisp_utils.admin_theme',
# all-auth
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'django_extensions',
'django_filters',
# openwisp2 modules
'openwisp_users',
'openwisp_controller.pki',
'openwisp_controller.config',
'openwisp_controller.connection',
# monitoring
'notifications',
'openwisp_monitoring.monitoring',
'openwisp_monitoring.device',
'openwisp_monitoring.check',
# notifications
'openwisp_notifications',
# openwisp2 admin theme (must be loaded here)
'openwisp_utils.admin_theme',
# admin
'django.contrib.admin',
'django.forms',
Expand Down Expand Up @@ -124,31 +126,6 @@ Follow the setup instructions of `openwisp-controller
urlpatterns += staticfiles_urlpatterns()
Add `apptemplates.Loader` to template loaders:

.. code-block:: python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(BASE_DIR), 'templates')],
'OPTIONS': {
'loaders': [
'apptemplates.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'openwisp_utils.loaders.DependencyLoader',
],
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
}
]
Configure caching (you may use a different cache storage if you want):

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion install-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pip install -U https://github.com/openwisp/openwisp-controller/tarball/master
# TODO: removed when openwisp-users 0.3.0 is released
pip install -U https://github.com/openwisp/openwisp-users/tarball/master
# TODO: remove when openwisp-notifications 0.1 is released
pip install -U https://github.com/openwisp/openwisp-notifications/tarball/master
pip install -U https://github.com/openwisp/openwisp-notifications/tarball/dev
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ openwisp-utils[qa]>=0.5.0
redis
django-redis
mock-ssh-server>=0.8.0,<0.9.0
channels_redis
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
openwisp-controller~=0.7.post1
influxdb>=5.2,<5.3
django-notifications-hq>=1.6,<1.7
django-apptemplates>=1.4,<2.0
django-celery-email>=3.0.0,<3.1
djangorestframework>=3.11,<3.12
mac-vendor-lookup~=0.1
Expand Down
7 changes: 7 additions & 0 deletions tests/openwisp2/routing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from openwisp_notifications.websockets.routing import get_routes

application = ProtocolTypeRouter(
{'websocket': AuthMiddlewareStack(URLRouter(get_routes()))}
)
23 changes: 18 additions & 5 deletions tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
# openwisp2 admin theme
# (must be loaded here)
'openwisp_utils.admin_theme',
# all-auth
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'django_extensions',
'django_filters',
# openwisp2 modules
'openwisp_controller.config',
'openwisp_controller.connection',
Expand All @@ -57,6 +55,9 @@
# notifications
'openwisp_notifications',
# admin
# openwisp2 admin theme
# (must be loaded here)
'openwisp_utils.admin_theme',
'django.contrib.admin',
'django.forms',
# other dependencies
Expand All @@ -76,7 +77,7 @@
]

AUTH_USER_MODEL = 'openwisp_users.User'
SITE_ID = '1'
SITE_ID = 1

STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
Expand Down Expand Up @@ -116,7 +117,6 @@
'DIRS': [os.path.join(os.path.dirname(BASE_DIR), 'templates')],
'OPTIONS': {
'loaders': [
'apptemplates.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'openwisp_utils.loaders.DependencyLoader',
Expand Down Expand Up @@ -200,6 +200,19 @@
},
}

ASGI_APPLICATION = 'openwisp2.routing.application'
if TESTING:
CHANNEL_LAYERS = {
'default': {'BACKEND': 'channels.layers.InMemoryChannelLayer'},
}
else:
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {'hosts': ['redis://localhost/7'],},
},
}

# avoid slowing down the test suite with mac vendor lookups
if TESTING:
OPENWISP_MONITORING_MAC_VENDOR_DETECTION = False
Expand Down
1 change: 1 addition & 0 deletions tests/openwisp2/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
url(r'^admin/', admin.site.urls),
url(r'', include('openwisp_controller.urls')),
url(r'', include('openwisp_monitoring.urls')),
url(r'', include('openwisp_notifications.urls')),
url(r'^$', redirect_view, name='index'),
]

Expand Down

0 comments on commit c2f6ae8

Please sign in to comment.