Skip to content

Commit bf1e8d0

Browse files
pandafynepython
authored andcommitted
[feature] Added notification widget from openwisp-notifications
1 parent 067b594 commit bf1e8d0

7 files changed

Lines changed: 33 additions & 35 deletions

File tree

README.rst

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,26 @@ Follow the setup instructions of `openwisp-controller
6969
7070
INSTALLED_APPS = [
7171
# django apps
72-
# openwisp2 admin theme (must be loaded here)
73-
'openwisp_utils.admin_theme',
7472
# all-auth
7573
'django.contrib.sites',
7674
'allauth',
7775
'allauth.account',
7876
'allauth.socialaccount',
7977
'django_extensions',
78+
'django_filters',
8079
# openwisp2 modules
8180
'openwisp_users',
8281
'openwisp_controller.pki',
8382
'openwisp_controller.config',
8483
'openwisp_controller.connection',
8584
# monitoring
86-
'notifications',
8785
'openwisp_monitoring.monitoring',
8886
'openwisp_monitoring.device',
8987
'openwisp_monitoring.check',
88+
# notifications
89+
'openwisp_notifications',
90+
# openwisp2 admin theme (must be loaded here)
91+
'openwisp_utils.admin_theme',
9092
# admin
9193
'django.contrib.admin',
9294
'django.forms',
@@ -124,31 +126,6 @@ Follow the setup instructions of `openwisp-controller
124126
125127
urlpatterns += staticfiles_urlpatterns()
126128
127-
Add `apptemplates.Loader` to template loaders:
128-
129-
.. code-block:: python
130-
131-
TEMPLATES = [
132-
{
133-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
134-
'DIRS': [os.path.join(os.path.dirname(BASE_DIR), 'templates')],
135-
'OPTIONS': {
136-
'loaders': [
137-
'apptemplates.Loader',
138-
'django.template.loaders.filesystem.Loader',
139-
'django.template.loaders.app_directories.Loader',
140-
'openwisp_utils.loaders.DependencyLoader',
141-
],
142-
'context_processors': [
143-
'django.template.context_processors.debug',
144-
'django.template.context_processors.request',
145-
'django.contrib.auth.context_processors.auth',
146-
'django.contrib.messages.context_processors.messages',
147-
],
148-
},
149-
}
150-
]
151-
152129
Configure caching (you may use a different cache storage if you want):
153130

154131
.. code-block:: python

install-dev.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ pip install -U https://github.com/openwisp/openwisp-controller/tarball/master
55
# TODO: removed when openwisp-users 0.3.0 is released
66
pip install -U https://github.com/openwisp/openwisp-users/tarball/master
77
# TODO: remove when openwisp-notifications 0.1 is released
8-
pip install -U https://github.com/openwisp/openwisp-notifications/tarball/master
8+
pip install -U https://github.com/openwisp/openwisp-notifications/tarball/dev

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ openwisp-utils[qa]>=0.5.0
22
redis
33
django-redis
44
mock-ssh-server>=0.8.0,<0.9.0
5+
channels_redis

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
openwisp-controller~=0.7.post1
22
influxdb>=5.2,<5.3
33
django-notifications-hq>=1.6,<1.7
4-
django-apptemplates>=1.4,<2.0
54
django-celery-email>=3.0.0,<3.1
65
djangorestframework>=3.11,<3.12
76
mac-vendor-lookup~=0.1

tests/openwisp2/routing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from channels.auth import AuthMiddlewareStack
2+
from channels.routing import ProtocolTypeRouter, URLRouter
3+
from openwisp_notifications.websockets.routing import get_routes
4+
5+
application = ProtocolTypeRouter(
6+
{'websocket': AuthMiddlewareStack(URLRouter(get_routes()))}
7+
)

tests/openwisp2/settings.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@
3434
'django.contrib.messages',
3535
'django.contrib.staticfiles',
3636
'django.contrib.gis',
37-
# openwisp2 admin theme
38-
# (must be loaded here)
39-
'openwisp_utils.admin_theme',
4037
# all-auth
4138
'django.contrib.sites',
4239
'allauth',
4340
'allauth.account',
4441
'allauth.socialaccount',
4542
'django_extensions',
43+
'django_filters',
4644
# openwisp2 modules
4745
'openwisp_controller.config',
4846
'openwisp_controller.connection',
@@ -57,6 +55,9 @@
5755
# notifications
5856
'openwisp_notifications',
5957
# admin
58+
# openwisp2 admin theme
59+
# (must be loaded here)
60+
'openwisp_utils.admin_theme',
6061
'django.contrib.admin',
6162
'django.forms',
6263
# other dependencies
@@ -76,7 +77,7 @@
7677
]
7778

7879
AUTH_USER_MODEL = 'openwisp_users.User'
79-
SITE_ID = '1'
80+
SITE_ID = 1
8081

8182
STATICFILES_FINDERS = [
8283
'django.contrib.staticfiles.finders.FileSystemFinder',
@@ -116,7 +117,6 @@
116117
'DIRS': [os.path.join(os.path.dirname(BASE_DIR), 'templates')],
117118
'OPTIONS': {
118119
'loaders': [
119-
'apptemplates.Loader',
120120
'django.template.loaders.filesystem.Loader',
121121
'django.template.loaders.app_directories.Loader',
122122
'openwisp_utils.loaders.DependencyLoader',
@@ -200,6 +200,19 @@
200200
},
201201
}
202202

203+
ASGI_APPLICATION = 'openwisp2.routing.application'
204+
if TESTING:
205+
CHANNEL_LAYERS = {
206+
'default': {'BACKEND': 'channels.layers.InMemoryChannelLayer'},
207+
}
208+
else:
209+
CHANNEL_LAYERS = {
210+
'default': {
211+
'BACKEND': 'channels_redis.core.RedisChannelLayer',
212+
'CONFIG': {'hosts': ['redis://localhost/7'],},
213+
},
214+
}
215+
203216
# avoid slowing down the test suite with mac vendor lookups
204217
if TESTING:
205218
OPENWISP_MONITORING_MAC_VENDOR_DETECTION = False

tests/openwisp2/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
url(r'^admin/', admin.site.urls),
1313
url(r'', include('openwisp_controller.urls')),
1414
url(r'', include('openwisp_monitoring.urls')),
15+
url(r'', include('openwisp_notifications.urls')),
1516
url(r'^$', redirect_view, name='index'),
1617
]
1718

0 commit comments

Comments
 (0)