Repository: openwisp/openwisp-firmware-upgrader (language: python)

Issue:
[deps] Add support for django 3.2 and django 4.0 alpha
Let's make sure this module can run with Django 3.2 and Django 4.0 alpha.




Discussion / hints:
Blocked by 

- [ ] https://github.com/openwisp/openwisp-controller/issues/551
- [x] https://github.com/openwisp/django-loci/pull/99
- [x] https://github.com/openwisp/django-x509/pull/125

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 639ac64e..041e3d06 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,6 +24,12 @@ jobs:
         django-version:
           - django~=3.0.0
           - django~=3.1.0
+          - django~=3.2.0
+        include:
+          - django-version: django~=4.0.0
+            python-version: 3.9
+          - django-version: django~=4.0.0
+            python-version: 3.8
 
     steps:
       - uses: actions/checkout@v2
@@ -53,8 +59,8 @@ jobs:
       - name: Install python dependencies
         run: |
           pip install -U "pip==20.2.4" wheel setuptools
-          pip install ${{ matrix.django-version }}
           pip install -U -r requirements-test.txt
+          pip install ${{ matrix.django-version }}
 
       - name: Install openwisp-firmware-upgrader
         run: pip install -e .
diff --git a/README.rst b/README.rst
index 2cd41abc..bbd56f29 100644
--- a/README.rst
+++ b/README.rst
@@ -132,13 +132,12 @@ The root URLconf (``urls.py``) should look like the following example:
     from django.contrib.staticfiles.urls import staticfiles_urlpatterns
 
     urlpatterns = [
-        url(r'^admin/', include(admin.site.urls)),
-        url(r'', include('openwisp_controller.urls')),
-        url(r'', include('openwisp_firmware_upgrader.urls')),
-        # token auth API
-        url(r'^api/v1/', include((get_api_urls(), 'users'), namespace='users')),
-        # needed for API docs
-        url(r'^api/v1/', include('openwisp_utils.api.urls')),
+        path('admin/', admin.site.urls),
+        path('', include('openwisp_controller.urls')),
+        path('', redirect_view, name='index'),
+        path('', include('openwisp_firmware_upgrader.urls')),
+        path('api/v1/', include((get_api_urls(), 'users'), namespace='users')),
+        path('api/v1/', include('openwisp_utils.api.urls')),
     ]
 
     urlpatterns += staticfiles_urlpatterns()
@@ -1015,7 +1014,7 @@ Step 2: remove the following line from your root ``urls.py`` file:
 
 .. code-block:: python
 
-    url('^firmware/', include('openwisp_firmware_upgrader.private_storage.urls')),
+    path('firmware/', include('openwisp_firmware_upgrader.private_storage.urls')),
 
 Step 3: add an URL route pointing to your custom view in ``urls.py`` file:
 
@@ -1026,7 +1025,7 @@ Step 3: add an URL route pointing to your custom view in ``urls.py`` file:
 
     urlpatterns = [
         # ... other URLs
-        url(r'^(?P<path>.*)$', FirmwareImageDownloadView.as_view(), name='serve_private_file',),
+        path('<your-custom-path>', FirmwareImageDownloadView.as_view(), name='serve_private_file',),
     ]
 
 For more information regarding django views, please refer to the
diff --git a/openwisp_firmware_upgrader/apps.py b/openwisp_firmware_upgrader/apps.py
index f18dc405..70332bf8 100644
--- a/openwisp_firmware_upgrader/apps.py
+++ b/openwisp_firmware_upgrader/apps.py
@@ -13,6 +13,7 @@ class FirmwareUpdaterConfig(ApiAppConfig):
     name = 'openwisp_firmware_upgrader'
     label = 'firmware_upgrader'
     verbose_name = _('Firmware Management')
+    default_auto_field = 'django.db.models.AutoField'
 
     API_ENABLED = app_settings.FIRMWARE_UPGRADER_API
     REST_FRAMEWORK_SETTINGS = {
diff --git a/setup.py b/setup.py
index 5beeac83..f6174f3b 100755
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@
     install_requires=[
         f'openwisp-controller @ {controller}',
         f'openwisp-utils[rest] @ {utils}',
-        'django-private-storage~=2.2',
+        'django-private-storage~=3.0.0',
     ],
     classifiers=[
         'Development Status :: 3 - Alpha',


Test patch:
diff --git a/tests/openwisp2/sample_firmware_upgrader/apps.py b/tests/openwisp2/sample_firmware_upgrader/apps.py
index f495258a..d7ba2195 100644
--- a/tests/openwisp2/sample_firmware_upgrader/apps.py
+++ b/tests/openwisp2/sample_firmware_upgrader/apps.py
@@ -5,3 +5,4 @@ class SampleFirmwareUpgraderConfig(FirmwareUpdaterConfig):
     name = 'openwisp2.sample_firmware_upgrader'
     label = 'sample_firmware_upgrader'
     verbose_name = 'Firmware Upgrader (custom)'
+    default_auto_field = 'django.db.models.AutoField'
diff --git a/tests/openwisp2/urls.py b/tests/openwisp2/urls.py
index a458ad08..8697c785 100644
--- a/tests/openwisp2/urls.py
+++ b/tests/openwisp2/urls.py
@@ -1,9 +1,8 @@
 from django.conf import settings
-from django.conf.urls import include, url
 from django.conf.urls.static import static
 from django.contrib import admin
 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
-from django.urls import reverse_lazy
+from django.urls import include, path, reverse_lazy
 from django.views.generic import RedirectView
 
 from openwisp_users.api.urls import get_api_urls
@@ -11,14 +10,14 @@
 redirect_view = RedirectView.as_view(url=reverse_lazy('admin:index'))
 
 urlpatterns = [
-    url(r'^admin/', admin.site.urls),
-    url(r'', include('openwisp_controller.urls')),
-    url(r'^$', redirect_view, name='index'),
-    url(r'', include('openwisp_firmware_upgrader.urls')),
+    path('admin/', admin.site.urls),
+    path('', redirect_view, name='index'),
+    path('', include('openwisp_controller.urls')),
+    path('', include('openwisp_firmware_upgrader.urls')),
     # token auth API
-    url(r'^api/v1/', include((get_api_urls(), 'users'), namespace='users')),
+    path('api/v1/', include((get_api_urls(), 'users'), namespace='users')),
     # needed for API docs
-    url(r'^api/v1/', include('openwisp_utils.api.urls')),
+    path('api/v1/', include('openwisp_utils.api.urls')),
 ]
 
 urlpatterns += staticfiles_urlpatterns()
@@ -27,4 +26,4 @@
 if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS:
     import debug_toolbar
 
-    urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)))
+    urlpatterns.append(path('__debug__/', include(debug_toolbar.urls)))