Home Information - Your home, your data, organized.
Python
Update Django Version (4.2 LTS → 5.2 LTS) (#332)
Tony Cec3f8ca457a0
diff --git a/src/hi/apps/alert/tests/ui/urls.py b/src/hi/apps/alert/tests/ui/urls.pyindex 7aabfabd..8a6e763f 100644--- a/src/hi/apps/alert/tests/ui/urls.py+++ b/src/hi/apps/alert/tests/ui/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,9 +6,9 @@ from . import viewsurlpatterns = [- re_path( r'^$',- views.TestUiAlertHomeView.as_view(),- name='alert_tests_ui'),+ path( '',+ views.TestUiAlertHomeView.as_view(),+ name='alert_tests_ui'),re_path( r'^details/(?P<alert_type>\w+)$',views.TestUiAlertDetailsView.as_view(),diff --git a/src/hi/apps/alert/urls.py b/src/hi/apps/alert/urls.pyindex c7c712de..3d3d111f 100644--- a/src/hi/apps/alert/urls.py+++ b/src/hi/apps/alert/urls.py@@ -1,15 +1,15 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^acknowledge/(?P<alert_id>.+)$',- views.AlertAcknowledgeView.as_view(),- name='alert_acknowledge'),+ path( 'acknowledge/<path:alert_id>',+ views.AlertAcknowledgeView.as_view(),+ name='alert_acknowledge'),- re_path( r'^details/(?P<alert_id>.+)$',- views.AlertDetailsView.as_view(),- name='alert_details'),+ path( 'details/<path:alert_id>',+ views.AlertDetailsView.as_view(),+ name='alert_details'),]diff --git a/src/hi/apps/api/urls.py b/src/hi/apps/api/urls.pyindex 537195fb..0b2ab97f 100644--- a/src/hi/apps/api/urls.py+++ b/src/hi/apps/api/urls.py@@ -1,12 +1,12 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^status$',- views.StatusView.as_view(),- name='api_status'),+ path( 'status',+ views.StatusView.as_view(),+ name='api_status'),]diff --git a/src/hi/apps/audio/urls.py b/src/hi/apps/audio/urls.pyindex dce3d509..ed8a4037 100644--- a/src/hi/apps/audio/urls.py+++ b/src/hi/apps/audio/urls.py@@ -1,11 +1,11 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^permission-guidance$',- views.AudioPermissionGuidanceView.as_view(),- name='audio_permission_guidance' ),+ path( 'permission-guidance',+ views.AudioPermissionGuidanceView.as_view(),+ name='audio_permission_guidance' ),]diff --git a/src/hi/apps/collection/edit/urls.py b/src/hi/apps/collection/edit/urls.pyindex a4c04fec..593cb5a4 100644--- a/src/hi/apps/collection/edit/urls.py+++ b/src/hi/apps/collection/edit/urls.py@@ -1,36 +1,36 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^add$',- views.CollectionAddView.as_view(),- name='collection_add' ),+ path( 'add',+ views.CollectionAddView.as_view(),+ name='collection_add' ),- re_path( r'^edit-mode/(?P<collection_id>\d+)$',- views.CollectionEditModeView.as_view(),- name='collection_edit_mode'),+ path( 'edit-mode/<int:collection_id>',+ views.CollectionEditModeView.as_view(),+ name='collection_edit_mode'),- re_path( r'^properties/(?P<collection_id>\d+)$',- views.CollectionPropertiesEditView.as_view(),- name='collection_properties_edit'),+ path( 'properties/<int:collection_id>',+ views.CollectionPropertiesEditView.as_view(),+ name='collection_properties_edit'),- re_path( r'^delete/(?P<collection_id>\d+)$',- views.CollectionDeleteView.as_view(),- name='collection_edit_collection_delete' ),+ path( 'delete/<int:collection_id>',+ views.CollectionDeleteView.as_view(),+ name='collection_edit_collection_delete' ),- re_path( r'^position/(?P<collection_id>\d+)$',- views.CollectionPositionEditView.as_view(),- name='collection_position_edit' ),+ path( 'position/<int:collection_id>',+ views.CollectionPositionEditView.as_view(),+ name='collection_position_edit' ),- re_path( r'^manage-item$',- views.CollectionManageItemsView.as_view(),- name='collection_edit_collection_manage_items' ),+ path( 'manage-item',+ views.CollectionManageItemsView.as_view(),+ name='collection_edit_collection_manage_items' ),- re_path( r'^entity/toggle/(?P<collection_id>\d+)/(?P<entity_id>\d+)$',- views.CollectionEntityToggleView.as_view(),- name='collection_edit_collection_entity_toggle' ),+ path( 'entity/toggle/<int:collection_id>/<int:entity_id>',+ views.CollectionEntityToggleView.as_view(),+ name='collection_edit_collection_entity_toggle' ),]diff --git a/src/hi/apps/collection/tests/test_models.py b/src/hi/apps/collection/tests/test_models.pyindex b0b92476..a55a1072 100644--- a/src/hi/apps/collection/tests/test_models.py+++ b/src/hi/apps/collection/tests/test_models.py@@ -1,10 +1,10 @@import loggingfrom django.db import IntegrityError-from hi.apps.collection.models import Collection, CollectionEntity, CollectionPosition, CollectionPath, CollectionView+from hi.apps.collection.models import Collection, CollectionEntity, CollectionPosition, CollectionPathfrom hi.apps.collection.enums import CollectionType, CollectionViewTypefrom hi.apps.entity.models import Entity-from hi.apps.location.models import Location, LocationView+from hi.apps.location.models import Locationfrom hi.enums import ItemTypefrom hi.testing.base_test_case import BaseTestCase@@ -139,58 +139,6 @@ class TestCollectionEntity(BaseTestCase):reloaded_names = [ce.entity.name for ce in reloaded_entities]self.assertEqual(reloaded_names, entity_names)- def test_collection_entity_cascade_deletion_from_collection(self):- """Test cascade deletion from collection - critical for data integrity."""- collection = Collection.objects.create(- name='Test Collection',- collection_type_str='OTHER',- collection_view_type_str='GRID'- )-- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )-- collection_entity = CollectionEntity.objects.create(- collection=collection,- entity=entity- )-- ce_id = collection_entity.id-- # Delete collection should cascade to collection entities- collection.delete()-- self.assertFalse(CollectionEntity.objects.filter(id=ce_id).exists())- return-- def test_collection_entity_cascade_deletion_from_entity(self):- """Test cascade deletion from entity - critical for data integrity."""- collection = Collection.objects.create(- name='Test Collection',- collection_type_str='OTHER',- collection_view_type_str='GRID'- )-- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )-- collection_entity = CollectionEntity.objects.create(- collection=collection,- entity=entity- )-- ce_id = collection_entity.id-- # Delete entity should cascade to collection entities- entity.delete()-- self.assertFalse(CollectionEntity.objects.filter(id=ce_id).exists())- return-def test_collection_entity_efficient_membership_queries(self):"""Test CollectionEntity query optimization - supports fast membership checks."""cameras = Collection.objects.create(@@ -388,76 +336,3 @@ class TestCollectionPath(BaseTestCase):self.assertTrue(zone_path.svg_path.endswith('Z')) # Closed path-class TestCollectionView(BaseTestCase):-- def test_collection_view_cascade_deletion_from_collection(self):- """Test cascade deletion from collection - critical for data integrity."""- location = Location.objects.create(- name='Test Location',- svg_fragment_filename='test.svg',- svg_view_box_str='0 0 100 100'- )-- location_view = LocationView.objects.create(- location=location,- location_view_type_str='DEFAULT',- name='Test View',- svg_view_box_str='0 0 50 50',- svg_rotate=0,- svg_style_name_str='COLOR'- )-- collection = Collection.objects.create(- name='Test Collection',- collection_type_str='OTHER',- collection_view_type_str='GRID'- )-- collection_view = CollectionView.objects.create(- collection=collection,- location_view=location_view- )-- cv_id = collection_view.id-- # Delete collection should cascade to collection view- collection.delete()-- self.assertFalse(CollectionView.objects.filter(id=cv_id).exists())- return-- def test_collection_view_cascade_deletion_from_location_view(self):- """Test cascade deletion from location view - critical for data integrity."""- location = Location.objects.create(- name='Test Location',- svg_fragment_filename='test.svg',- svg_view_box_str='0 0 100 100'- )-- location_view = LocationView.objects.create(- location=location,- location_view_type_str='DEFAULT',- name='Test View',- svg_view_box_str='0 0 50 50',- svg_rotate=0,- svg_style_name_str='COLOR'- )-- collection = Collection.objects.create(- name='Test Collection',- collection_type_str='OTHER',- collection_view_type_str='GRID'- )-- collection_view = CollectionView.objects.create(- collection=collection,- location_view=location_view- )-- cv_id = collection_view.id-- # Delete location view should cascade to collection view- location_view.delete()-- self.assertFalse(CollectionView.objects.filter(id=cv_id).exists())- returndiff --git a/src/hi/apps/collection/urls.py b/src/hi/apps/collection/urls.pyindex caab8584..b88bb0a2 100644--- a/src/hi/apps/collection/urls.py+++ b/src/hi/apps/collection/urls.py@@ -1,18 +1,19 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^view/(?P<collection_id>\d+)$',- views.CollectionViewView.as_view(),- name='collection_view'),+ path( 'view/<int:collection_id>',+ views.CollectionViewView.as_view(),+ name='collection_view'),- re_path( r'^view$',- views.CollectionViewDefaultView.as_view(),- name='collection_view_default'),+ path( 'view',+ views.CollectionViewDefaultView.as_view(),+ name='collection_view_default'),- re_path( r'^edit/', include('hi.apps.collection.edit.urls' )),+ path( 'edit/', include('hi.apps.collection.edit.urls' )),]diff --git a/src/hi/apps/common/tests/ui/urls.py b/src/hi/apps/common/tests/ui/urls.pyindex f71d4efd..8db908fa 100644--- a/src/hi/apps/common/tests/ui/urls.py+++ b/src/hi/apps/common/tests/ui/urls.py@@ -1,14 +1,14 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path(r'^$',- views.TestUiCommonHomeView.as_view(),- name='common_tests_ui'),+ path('',+ views.TestUiCommonHomeView.as_view(),+ name='common_tests_ui'),- re_path(r'^icons$',- views.TestUiIconBrowserView.as_view(),- name='common_tests_ui_icons'),+ path('icons',+ views.TestUiIconBrowserView.as_view(),+ name='common_tests_ui_icons'),]diff --git a/src/hi/apps/config/tests/test_models.py b/src/hi/apps/config/tests/test_models.pyindex 8f67fe0a..3c31b2e2 100644--- a/src/hi/apps/config/tests/test_models.py+++ b/src/hi/apps/config/tests/test_models.py@@ -73,24 +73,6 @@ class TestSubsystemAttribute(BaseTestCase):)return- def test_subsystem_attribute_cascade_delete(self):- """Test cascade deletion behavior - critical for data integrity."""- attribute = SubsystemAttribute.objects.create(- subsystem=self.subsystem,- setting_key='test.setting.key',- value_type=AttributeValueType.TEXT,- value='test_value',- )-- attribute_id = attribute.id- self.assertTrue(SubsystemAttribute.objects.filter(id=attribute_id).exists())-- # Delete subsystem should cascade to attributes- self.subsystem.delete()-- self.assertFalse(SubsystemAttribute.objects.filter(id=attribute_id).exists())- return-def test_attribute_value_storage_and_retrieval(self):"""Test attribute values are stored and retrieved correctly across different types."""test_cases = [diff --git a/src/hi/apps/config/urls.py b/src/hi/apps/config/urls.pyindex 88714a5e..5e07056b 100644--- a/src/hi/apps/config/urls.py+++ b/src/hi/apps/config/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,36 +6,36 @@ from . import viewsurlpatterns = [- re_path( r'^$',- views.ConfigHomeView.as_view(),- name='config_home' ),+ path( '',+ views.ConfigHomeView.as_view(),+ name='config_home' ),re_path( r'^settings(?:/(?P<subsystem_id>\d+))?$',views.ConfigSettingsView.as_view(),name='config_settings' ),- re_path( r'^attribute/history/(?P<subsystem_id>\d+)/(?P<attribute_id>\d+)/$',- views.SubsystemAttributeHistoryInlineView.as_view(),- name='subsystem_attribute_history_inline'),+ path( 'attribute/history/<int:subsystem_id>/<int:attribute_id>/',+ views.SubsystemAttributeHistoryInlineView.as_view(),+ name='subsystem_attribute_history_inline'),- re_path( r'^attribute/restore/(?P<subsystem_id>\d+)/(?P<attribute_id>\d+)/(?P<history_id>\d+)/$',- views.SubsystemAttributeRestoreInlineView.as_view(),- name='subsystem_attribute_restore_inline'),+ path( 'attribute/restore/<int:subsystem_id>/<int:attribute_id>/<int:history_id>/',+ views.SubsystemAttributeRestoreInlineView.as_view(),+ name='subsystem_attribute_restore_inline'),- re_path( r'^attribute/restore/default/subsystem/confirm/(?P<subsystem_id>\d+)/$',- views.SubsystemAttributeRestoreSubsystemConfirmModalView.as_view(),- name='subsystem_attribute_restore_subsystem_confirm_modal' ),+ path( 'attribute/restore/default/subsystem/confirm/<int:subsystem_id>/',+ views.SubsystemAttributeRestoreSubsystemConfirmModalView.as_view(),+ name='subsystem_attribute_restore_subsystem_confirm_modal' ),- re_path( r'^attribute/restore/default/subsystem/(?P<subsystem_id>\d+)/$',- views.SubsystemAttributeRestoreSubsystemInlineView.as_view(),- name='subsystem_attribute_restore_subsystem_inline' ),+ path( 'attribute/restore/default/subsystem/<int:subsystem_id>/',+ views.SubsystemAttributeRestoreSubsystemInlineView.as_view(),+ name='subsystem_attribute_restore_subsystem_inline' ),- re_path( r'^attribute/restore/default/all/confirm/(?P<subsystem_id>\d+)/$',- views.SubsystemAttributeRestoreAllConfirmModalView.as_view(),- name='subsystem_attribute_restore_all_confirm_modal' ),+ path( 'attribute/restore/default/all/confirm/<int:subsystem_id>/',+ views.SubsystemAttributeRestoreAllConfirmModalView.as_view(),+ name='subsystem_attribute_restore_all_confirm_modal' ),- re_path( r'^attribute/restore/default/all/(?P<subsystem_id>\d+)/$',- views.SubsystemAttributeRestoreAllInlineView.as_view(),- name='subsystem_attribute_restore_all_inline' ),+ path( 'attribute/restore/default/all/<int:subsystem_id>/',+ views.SubsystemAttributeRestoreAllInlineView.as_view(),+ name='subsystem_attribute_restore_all_inline' ),]diff --git a/src/hi/apps/console/tests/test_video_stream_browsing_helper.py b/src/hi/apps/console/tests/test_video_stream_browsing_helper.pyindex 284186ea..3f801bc9 100644--- a/src/hi/apps/console/tests/test_video_stream_browsing_helper.py+++ b/src/hi/apps/console/tests/test_video_stream_browsing_helper.py@@ -585,7 +585,7 @@ class TestVideoStreamBrowsingHelper(TransactionTestCase):SensorHistory.objects.create(sensor=self.video_sensor,value='extreme_past',- response_datetime=timezone.datetime(1970, 1, 1, tzinfo=timezone.utc),+ response_datetime=datetime(1970, 1, 1, tzinfo=UTC),has_video_stream=True)diff --git a/src/hi/apps/console/urls.py b/src/hi/apps/console/urls.pyindex 215e9824..b6d175ae 100644--- a/src/hi/apps/console/urls.py+++ b/src/hi/apps/console/urls.py@@ -1,54 +1,53 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^entity/video-stream-dispatch/(?P<entity_id>\d+)$',- views.EntityVideoStreamDispatchView.as_view(),- name='console_entity_video_stream_dispatch'),+ path( 'entity/video-stream-dispatch/<int:entity_id>',+ views.EntityVideoStreamDispatchView.as_view(),+ name='console_entity_video_stream_dispatch'),- re_path( r'^entity/video-stream/(?P<entity_id>\d+)$',- views.EntityVideoStreamView.as_view(),- name='console_entity_video_stream'),+ path( 'entity/video-stream/<int:entity_id>',+ views.EntityVideoStreamView.as_view(),+ name='console_entity_video_stream'),- re_path( r'^entity/video-history/(?P<entity_id>\d+)$',- views.EntityVideoHistoryView.as_view(),- name='console_entity_sendor_video_history_default'),+ path( 'entity/video-history/<int:entity_id>',+ views.EntityVideoHistoryView.as_view(),+ name='console_entity_sendor_video_history_default'),- re_path( r'^entity/video-sensor-history/(?P<entity_id>\d+)/(?P<sensor_id>\d+)/$',- views.EntityVideoSensorHistoryView.as_view(),- name='console_entity_video_sensor_history'),+ path( 'entity/video-sensor-history/<int:entity_id>/<int:sensor_id>/',+ views.EntityVideoSensorHistoryView.as_view(),+ name='console_entity_video_sensor_history'),- re_path(- r'^entity/video-sensor-history/(?P<entity_id>\d+)/(?P<sensor_id>\d+)/(?P<sensor_history_id>\d+)/$',+ path(+ 'entity/video-sensor-history/<int:entity_id>/<int:sensor_id>/<int:sensor_history_id>/',views.EntityVideoSensorHistoryView.as_view(),name='console_entity_video_sensor_history_detail'),- re_path(- r'^entity/video-sensor-history/(?P<entity_id>\d+)/(?P<sensor_id>\d+)/(?P<sensor_history_id>\d+)/'- r'(?P<window_start>\d+)/(?P<window_end>\d+)/$',+ path(+ 'entity/video-sensor-history/<int:entity_id>/<int:sensor_id>/<int:sensor_history_id>/<int:window_start>/<int:window_end>/',views.EntityVideoSensorHistoryView.as_view(),name='console_entity_video_sensor_history_detail_with_context'),- re_path(r'^entity/video-sensor-history/(?P<entity_id>\d+)/(?P<sensor_id>\d+)/earlier/(?P<timestamp>\d+)/$',- views.EntityVideoSensorHistoryEarlierView.as_view(),- name='console_entity_video_sensor_history_earlier'),+ path('entity/video-sensor-history/<int:entity_id>/<int:sensor_id>/earlier/<int:timestamp>/',+ views.EntityVideoSensorHistoryEarlierView.as_view(),+ name='console_entity_video_sensor_history_earlier'),- re_path(r'^entity/video-sensor-history/(?P<entity_id>\d+)/(?P<sensor_id>\d+)/later/(?P<timestamp>\d+)/$',- views.EntityVideoSensorHistoryLaterView.as_view(),- name='console_entity_video_sensor_history_later'),+ path('entity/video-sensor-history/<int:entity_id>/<int:sensor_id>/later/<int:timestamp>/',+ views.EntityVideoSensorHistoryLaterView.as_view(),+ name='console_entity_video_sensor_history_later'),- re_path( r'^lock$',- views.ConsoleLockView.as_view(),- name='console_lock'),+ path( 'lock',+ views.ConsoleLockView.as_view(),+ name='console_lock'),- re_path( r'^set-lock-password$',- views.SetLockPasswordView.as_view(),- name='console_set_lock_password'),+ path( 'set-lock-password',+ views.SetLockPasswordView.as_view(),+ name='console_set_lock_password'),- re_path( r'^unlock$',- views.ConsoleUnlockView.as_view(),- name='console_unlock'),+ path( 'unlock',+ views.ConsoleUnlockView.as_view(),+ name='console_unlock'),]diff --git a/src/hi/apps/console/views.py b/src/hi/apps/console/views.pyindex 20d8bca2..20158f2e 100644--- a/src/hi/apps/console/views.py+++ b/src/hi/apps/console/views.py@@ -33,7 +33,7 @@ class EntityVideoStreamDispatchView( View, EntityViewMixin ):entity = self.get_entity( request, *args, **kwargs )# Get video dispatch decision based on referrer context- referrer_url = request.META.get('HTTP_REFERER', '')+ referrer_url = request.headers.get('referer', '')dispatch_result = VideoStreamBrowsingHelper.get_video_dispatch_result(entity = entity,referrer_url = referrer_url,diff --git a/src/hi/apps/control/tests/test_models.py b/src/hi/apps/control/tests/test_models.pyindex 31446b16..d6a0fc08 100644--- a/src/hi/apps/control/tests/test_models.py+++ b/src/hi/apps/control/tests/test_models.py@@ -94,33 +94,6 @@ class TestController(BaseTestCase):# EntityState should provide choices based on entity_state_typereturn- def test_controller_cascade_deletion_from_entity_state(self):- """Test cascade deletion from entity state - critical for data integrity."""- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- controller = Controller.objects.create(- name='Test Controller',- entity_state=entity_state,- controller_type_str='DEFAULT',- integration_id='test_id',- integration_name='test_integration'- )-- controller_id = controller.id-- # Delete entity state should cascade to controller- entity_state.delete()-- self.assertFalse(Controller.objects.filter(id=controller_id).exists())- return-def test_controller_string_representation(self):"""Test __str__ method format - important for debugging and admin."""entity = Entity.objects.create(@@ -190,38 +163,6 @@ class TestControllerHistory(BaseTestCase):self.assertEqual(history_list[2], history1) # Oldestreturn- def test_controller_history_cascade_deletion_from_controller(self):- """Test cascade deletion from controller - critical for data integrity."""- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- controller = Controller.objects.create(- name='Test Controller',- entity_state=entity_state,- controller_type_str='DEFAULT',- integration_id='test_id',- integration_name='test_integration'- )-- history = ControllerHistory.objects.create(- controller=controller,- value='on'- )-- history_id = history.id-- # Delete controller should cascade to history- controller.delete()-- self.assertFalse(ControllerHistory.objects.filter(id=history_id).exists())- return-def test_controller_history_created_datetime_indexing(self):"""Test created_datetime field indexing - critical for query performance."""entity = Entity.objects.create(diff --git a/src/hi/apps/control/urls.py b/src/hi/apps/control/urls.pyindex 04eea420..e8b5bed7 100644--- a/src/hi/apps/control/urls.py+++ b/src/hi/apps/control/urls.py@@ -1,11 +1,11 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^controller/(?P<controller_id>\d+)$',- views.ControllerView.as_view(),- name='control_controller'),+ path( 'controller/<int:controller_id>',+ views.ControllerView.as_view(),+ name='control_controller'),]diff --git a/src/hi/apps/edit/tests/test_views.py b/src/hi/apps/edit/tests/test_views.pyindex 93a95169..223a92f9 100644--- a/src/hi/apps/edit/tests/test_views.py+++ b/src/hi/apps/edit/tests/test_views.py@@ -43,7 +43,7 @@ class TestEditStartView(SyncViewTestCase):self.setSessionViewType(ViewType.LOCATION_VIEW)url = reverse('edit_start')- response = self.client.get(url, HTTP_REFERER='/test/page/')+ response = self.client.get(url, headers={"referer": '/test/page/'})# Should redirect to refererself.assertEqual(response.status_code, 302)@@ -75,7 +75,7 @@ class TestEditStartView(SyncViewTestCase):self.setSessionViewType(ViewType.CONFIGURATION)url = reverse('edit_start')- response = self.client.get(url, HTTP_REFERER='/config/page/')+ response = self.client.get(url, headers={"referer": '/config/page/'})# Should redirect to home instead of refererhome_url = reverse('home')@@ -106,7 +106,7 @@ class TestEditEndView(SyncViewTestCase):url = reverse('edit_end')referer_url = '/location/view/1?details=/item/details/123'- response = self.client.get(url, HTTP_REFERER=referer_url)+ response = self.client.get(url, headers={"referer": referer_url})# Should redirect and clear sidebar parameterself.assertEqual(response.status_code, 302)@@ -140,7 +140,7 @@ class TestEditEndView(SyncViewTestCase):url = reverse('edit_end')referer_url = '/location/view/1?page=2&details=/item/details/123&sort=name'- response = self.client.get(url, HTTP_REFERER=referer_url)+ response = self.client.get(url, headers={"referer": referer_url})# Should redirect and preserve other params while clearing detailsself.assertEqual(response.status_code, 302)diff --git a/src/hi/apps/edit/urls.py b/src/hi/apps/edit/urls.pyindex 227594e3..03c6f06a 100644--- a/src/hi/apps/edit/urls.py+++ b/src/hi/apps/edit/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,21 +6,21 @@ from . import viewsurlpatterns = [- re_path( r'^start$',- views.EditStartView.as_view(),- name='edit_start' ),+ path( 'start',+ views.EditStartView.as_view(),+ name='edit_start' ),- re_path( r'^end$',- views.EditEndView.as_view(),- name='edit_end' ),+ path( 'end',+ views.EditEndView.as_view(),+ name='edit_end' ),- re_path( r'^item/reorder$',- views.ReorderItemsView.as_view(),- name='edit_reorder_items' ),+ path( 'item/reorder',+ views.ReorderItemsView.as_view(),+ name='edit_reorder_items' ),- re_path( r'^item/details/close$',- views.ItemDetailsCloseView.as_view(),- name='edit_item_details_close' ),+ path( 'item/details/close',+ views.ItemDetailsCloseView.as_view(),+ name='edit_item_details_close' ),re_path( r'^entity/state/values/(?P<instance_name>\w+)/(?P<instance_id>\d+)$',views.EntityStateValueChoicesView.as_view(),diff --git a/src/hi/apps/edit/views.py b/src/hi/apps/edit/views.pyindex 7af8b484..d92705d1 100644--- a/src/hi/apps/edit/views.py+++ b/src/hi/apps/edit/views.py@@ -39,7 +39,7 @@ class EditStartView( View ):# state mode.if request.view_parameters.view_type.allows_edit_mode:- redirect_url = request.META.get('HTTP_REFERER')+ redirect_url = request.headers.get('referer')else:redirect_url = Noneif not redirect_url:@@ -66,7 +66,7 @@ class EditEndView( View ):request.view_parameters.to_session( request )# Do a page refresh, but remove any side bar url set during editing.- referrer_url = request.META.get('HTTP_REFERER')+ referrer_url = request.headers.get('referer')if referrer_url:parsed_url = urllib.parse.urlparse( referrer_url )query_params = urllib.parse.parse_qs( parsed_url.query )diff --git a/src/hi/apps/entity/edit/urls.py b/src/hi/apps/entity/edit/urls.pyindex 876f9c3d..4c3e3710 100644--- a/src/hi/apps/entity/edit/urls.py+++ b/src/hi/apps/entity/edit/urls.py@@ -1,43 +1,43 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^add$',- views.EntityAddView.as_view(),- name='entity_edit_entity_add' ),+ path( 'add',+ views.EntityAddView.as_view(),+ name='entity_edit_entity_add' ),- re_path( r'^delete/(?P<entity_id>\d+)$',- views.EntityDeleteView.as_view(),- name='entity_edit_entity_delete' ),+ path( 'delete/<int:entity_id>',+ views.EntityDeleteView.as_view(),+ name='entity_edit_entity_delete' ),- re_path( r'^position/(?P<entity_id>\d+)$',- views.EntityPositionEditView.as_view(),- name='entity_position_edit' ),+ path( 'position/<int:entity_id>',+ views.EntityPositionEditView.as_view(),+ name='entity_position_edit' ),- re_path( r'^principal/manage/(?P<entity_id>\d+)$',- views.ManagePairingsView.as_view(),- name='entity_edit_manage_pairings' ),+ path( 'principal/manage/<int:entity_id>',+ views.ManagePairingsView.as_view(),+ name='entity_edit_manage_pairings' ),- re_path( r'^edit-mode/(?P<entity_id>\d+)$',- views.EntityEditModeView.as_view(),- name='entity_edit_mode' ),+ path( 'edit-mode/<int:entity_id>',+ views.EntityEditModeView.as_view(),+ name='entity_edit_mode' ),- re_path( r'^properties/edit/(?P<entity_id>\d+)$',- views.EntityPropertiesEditView.as_view(),- name='entity_properties_edit'),+ path( 'properties/edit/<int:entity_id>',+ views.EntityPropertiesEditView.as_view(),+ name='entity_properties_edit'),- re_path( r'^archive/(?P<entity_id>\d+)$',- views.EntityArchiveView.as_view(),- name='entity_edit_entity_archive' ),+ path( 'archive/<int:entity_id>',+ views.EntityArchiveView.as_view(),+ name='entity_edit_entity_archive' ),- re_path( r'^archive-list/$',- views.EntityArchiveListView.as_view(),- name='entity_edit_archive_list' ),+ path( 'archive-list/',+ views.EntityArchiveListView.as_view(),+ name='entity_edit_archive_list' ),- re_path( r'^archive-detail/(?P<archived_entity_id>\d+)$',- views.EntityArchiveDetailView.as_view(),- name='entity_edit_archive_detail' ),+ path( 'archive-detail/<int:archived_entity_id>',+ views.EntityArchiveDetailView.as_view(),+ name='entity_edit_archive_detail' ),]diff --git a/src/hi/apps/entity/tests/test_attribute_history.py b/src/hi/apps/entity/tests/test_attribute_history.pyindex bd91451d..cc3f0ade 100644--- a/src/hi/apps/entity/tests/test_attribute_history.py+++ b/src/hi/apps/entity/tests/test_attribute_history.py@@ -111,40 +111,6 @@ class EntityAttributeHistoryTestCase(BaseTestCase):self.assertEqual(entity_attr._get_history_model_class(), EntityAttributeHistory)return- def test_attribute_history_cascade_deletion(self):- """Test that history records are deleted when attribute is hard-deleted - database constraint behavior."""- # Create entity and attribute with history- entity = Entity.objects.create(- name='Test Entity',- entity_type_str=str(EntityType.OTHER),- integration_id='test.entity',- integration_name='test_integration'- )-- attr = EntityAttribute.objects.create(- entity=entity,- name='test_attr',- value='test_value',- value_type_str=str(AttributeValueType.TEXT),- attribute_type_str=str(AttributeType.CUSTOM)- )-- # Update to create multiple history records- attr.value = 'updated_value'- attr.save()-- # Verify history records exist- history_count = EntityAttributeHistory.objects.filter(attribute=attr).count()- self.assertEqual(history_count, 2)-- # Hard-delete the attribute to trigger FK cascade.- attr.delete(hard_delete=True)-- # Verify all history records are deleted (cascade)- history_count = EntityAttributeHistory.objects.filter(attribute=attr).count()- self.assertEqual(history_count, 0)- return-def test_attribute_history_preserved_on_soft_delete(self):"""Test that soft delete keeps history records because row is not physically removed."""entity = Entity.objects.create(diff --git a/src/hi/apps/entity/tests/test_models.py b/src/hi/apps/entity/tests/test_models.pyindex 4943e540..93064408 100644--- a/src/hi/apps/entity/tests/test_models.py+++ b/src/hi/apps/entity/tests/test_models.py@@ -153,39 +153,6 @@ class TestEntity(BaseTestCase):self.assertEqual(len(empty_map), 0)return- def test_cascade_deletion_behavior(self):- """Test cascade deletion - critical for data integrity."""- entity = Entity.objects.create(- name='Test Entity',- entity_type_str=str(EntityType.OTHER),- integration_id='test_entity_001',- integration_name='test_integration',- )-- # Create related objects- attribute = EntityAttribute.objects.create(- entity=entity,- name='test_attribute',- value_type=AttributeValueType.TEXT,- value='test_value',- )-- state = EntityState.objects.create(- entity=entity,- entity_state_type_str=str(EntityStateType.ON_OFF),- name='Power State',- )-- attribute_id = attribute.id- state_id = state.id-- # Delete entity should cascade- entity.delete()-- self.assertFalse(EntityAttribute.objects.filter(id=attribute_id).exists())- self.assertFalse(EntityState.objects.filter(id=state_id).exists())- return-class TestEntityState(BaseTestCase):@@ -432,71 +399,6 @@ class TestEntityState(BaseTestCase):return- def test_cascade_deletion_maintains_data_integrity(self):- """Test cascade deletion - ensures related data is properly cleaned up."""- # Create entity with related objects- entity = Entity.objects.create(- name='Multi-State Device',- entity_type_str=str(EntityType.HVAC_FURNACE),- integration_id='furnace_001',- integration_name='hvac_system',- )-- # Create related attributes- config_attribute = EntityAttribute.objects.create(- entity=entity,- name='max_temperature',- value_type=AttributeValueType.TEXT,- value='85',- )-- specs_attribute = EntityAttribute.objects.create(- entity=entity,- name='manufacturer',- value_type=AttributeValueType.TEXT,- value='Carrier',- )-- # Create related states- power_state = EntityState.objects.create(- entity=entity,- entity_state_type_str=str(EntityStateType.ON_OFF),- name='Power State',- )-- temp_state = EntityState.objects.create(- entity=entity,- entity_state_type_str=str(EntityStateType.TEMPERATURE),- name='Current Temperature',- units='°F',- )-- # Record IDs for verification- entity_id = entity.id- config_attr_id = config_attribute.id- specs_attr_id = specs_attribute.id- power_state_id = power_state.id- temp_state_id = temp_state.id-- # Verify all objects exist- self.assertTrue(Entity.objects.filter(id=entity_id).exists())- self.assertTrue(EntityAttribute.objects.filter(id=config_attr_id).exists())- self.assertTrue(EntityAttribute.objects.filter(id=specs_attr_id).exists())- self.assertTrue(EntityState.objects.filter(id=power_state_id).exists())- self.assertTrue(EntityState.objects.filter(id=temp_state_id).exists())-- # Delete entity should cascade to all related objects- entity.delete()-- # Verify cascade deletion worked- self.assertFalse(Entity.objects.filter(id=entity_id).exists())- self.assertFalse(EntityAttribute.objects.filter(id=config_attr_id).exists())- self.assertFalse(EntityAttribute.objects.filter(id=specs_attr_id).exists())- self.assertFalse(EntityState.objects.filter(id=power_state_id).exists())- self.assertFalse(EntityState.objects.filter(id=temp_state_id).exists())-- return-class TestEntityStateChoices(BaseTestCase):"""``EntityState.choices()`` derives labels for the discretediff --git a/src/hi/apps/entity/tests/ui/urls.py b/src/hi/apps/entity/tests/ui/urls.pyindex 36124ca3..c2cc7f61 100644--- a/src/hi/apps/entity/tests/ui/urls.py+++ b/src/hi/apps/entity/tests/ui/urls.py@@ -1,12 +1,12 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path(r'^$',- views.TestUiEntityHomeView.as_view(),- name='entity_tests_ui'),+ path('',+ views.TestUiEntityHomeView.as_view(),+ name='entity_tests_ui'),- re_path(r'^visual-browser/$',- views.TestUiEntityTypeVisualBrowserView.as_view(),- name='test_entity_type_visual_browser'),+ path('visual-browser/',+ views.TestUiEntityTypeVisualBrowserView.as_view(),+ name='test_entity_type_visual_browser'),]diff --git a/src/hi/apps/entity/urls.py b/src/hi/apps/entity/urls.pyindex 9fc967f5..7e2355b4 100644--- a/src/hi/apps/entity/urls.py+++ b/src/hi/apps/entity/urls.py@@ -1,42 +1,43 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^entity/edit/(?P<entity_id>\d+)$',- views.EntityEditView.as_view(),- name='entity_edit'),+ path( 'entity/edit/<int:entity_id>',+ views.EntityEditView.as_view(),+ name='entity_edit'),- re_path( r'^status/(?P<entity_id>\d+)$',- views.EntityStatusView.as_view(),- name='entity_status' ),+ path( 'status/<int:entity_id>',+ views.EntityStatusView.as_view(),+ name='entity_status' ),- re_path( r'^history/(?P<entity_id>\d+)$',- views.EntityHistoryView.as_view(),- name='entity_history' ),+ path( 'history/<int:entity_id>',+ views.EntityHistoryView.as_view(),+ name='entity_history' ),- re_path( r'^state/(?P<entity_state_id>\d+)/history$',- views.EntityStateHistoryView.as_view(),- name='entity_state_history' ),+ path( 'state/<int:entity_state_id>/history',+ views.EntityStateHistoryView.as_view(),+ name='entity_state_history' ),- re_path( r'^attribute/upload/(?P<entity_id>\d+)$',- views.EntityAttributeUploadView.as_view(),- name='entity_attribute_upload' ),+ path( 'attribute/upload/<int:entity_id>',+ views.EntityAttributeUploadView.as_view(),+ name='entity_attribute_upload' ),- re_path( r'^attribute/history/(?P<entity_id>\d+)/(?P<attribute_id>\d+)/$',- views.EntityAttributeHistoryInlineView.as_view(),- name='entity_attribute_history_inline' ),+ path( 'attribute/history/<int:entity_id>/<int:attribute_id>/',+ views.EntityAttributeHistoryInlineView.as_view(),+ name='entity_attribute_history_inline' ),- re_path( r'^attribute/restore/(?P<entity_id>\d+)/(?P<attribute_id>\d+)/(?P<history_id>\d+)/$',- views.EntityAttributeRestoreInlineView.as_view(),- name='entity_attribute_restore_inline' ),+ path( 'attribute/restore/<int:entity_id>/<int:attribute_id>/<int:history_id>/',+ views.EntityAttributeRestoreInlineView.as_view(),+ name='entity_attribute_restore_inline' ),- re_path( r'^attribute/restore-deleted/(?P<entity_id>\d+)/(?P<attribute_id>\d+)/$',- views.EntityAttributeRestoreDeletedInlineView.as_view(),- name='entity_attribute_restore_deleted_inline' ),+ path( 'attribute/restore-deleted/<int:entity_id>/<int:attribute_id>/',+ views.EntityAttributeRestoreDeletedInlineView.as_view(),+ name='entity_attribute_restore_deleted_inline' ),- re_path( r'^edit/', include('hi.apps.entity.edit.urls' )),+ path( 'edit/', include('hi.apps.entity.edit.urls' )),]diff --git a/src/hi/apps/event/edit/urls.py b/src/hi/apps/event/edit/urls.pyindex 90ec3448..c7611530 100644--- a/src/hi/apps/event/edit/urls.py+++ b/src/hi/apps/event/edit/urls.py@@ -1,20 +1,20 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^definition/add$',- views.EventDefinitionAddView.as_view(),- name='event_definition_add'),+ path( 'definition/add',+ views.EventDefinitionAddView.as_view(),+ name='event_definition_add'),- re_path( r'^definition/edit/(?P<id>\d+)$',- views.EventDefinitionEditView.as_view(),- name='event_definition_edit'),+ path( 'definition/edit/<int:id>',+ views.EventDefinitionEditView.as_view(),+ name='event_definition_edit'),- re_path( r'^definition/delete/(?P<id>\d+)$',- views.EventDefinitionDeleteView.as_view(),- name='event_definition_delete'),+ path( 'definition/delete/<int:id>',+ views.EventDefinitionDeleteView.as_view(),+ name='event_definition_delete'),]diff --git a/src/hi/apps/event/tests/test_models.py b/src/hi/apps/event/tests/test_models.pyindex 7d403243..796cde34 100644--- a/src/hi/apps/event/tests/test_models.py+++ b/src/hi/apps/event/tests/test_models.py@@ -83,77 +83,6 @@ class TestEventDefinition(BaseTestCase):return-class TestEventClause(BaseTestCase):-- def test_event_clause_cascade_deletion_from_event_definition(self):- """Test cascade deletion from event definition - critical for data integrity."""- event_def = EventDefinition.objects.create(- name='Test Event',- event_type_str='SECURITY',- event_window_secs=60,- dedupe_window_secs=300,- integration_id='test_id',- integration_name='test_integration'- )-- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- event_clause = EventClause.objects.create(- event_definition=event_def,- entity_state=entity_state,- value='on'- )-- clause_id = event_clause.id-- # Delete event definition should cascade to clauses- event_def.delete()-- self.assertFalse(EventClause.objects.filter(id=clause_id).exists())- return-- def test_event_clause_cascade_deletion_from_entity_state(self):- """Test cascade deletion from entity state - critical for data integrity."""- event_def = EventDefinition.objects.create(- name='Test Event',- event_type_str='SECURITY',- event_window_secs=60,- dedupe_window_secs=300,- integration_id='test_id',- integration_name='test_integration'- )-- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- event_clause = EventClause.objects.create(- event_definition=event_def,- entity_state=entity_state,- value='on'- )-- clause_id = event_clause.id-- # Delete entity state should cascade to clauses- entity_state.delete()-- self.assertFalse(EventClause.objects.filter(id=clause_id).exists())- return--class TestAlarmAction(BaseTestCase):def test_alarm_action_enum_property_conversions(self):@@ -215,119 +144,6 @@ class TestAlarmAction(BaseTestCase):self.assertEqual(timed_alarm.alarm_lifetime_secs, 1800)return- def test_alarm_action_cascade_deletion_from_event_definition(self):- """Test cascade deletion from event definition - critical for data integrity."""- event_def = EventDefinition.objects.create(- name='Test Event',- event_type_str='SECURITY',- event_window_secs=60,- dedupe_window_secs=300,- integration_id='test_id',- integration_name='test_integration'- )-- alarm_action = AlarmAction.objects.create(- event_definition=event_def,- security_level_str='HIGH',- alarm_level_str='CRITICAL',- alarm_lifetime_secs=3600- )-- action_id = alarm_action.id-- # Delete event definition should cascade to alarm actions- event_def.delete()-- self.assertFalse(AlarmAction.objects.filter(id=action_id).exists())- return---class TestControlAction(BaseTestCase):-- def test_control_action_cascade_deletion_from_event_definition(self):- """Test cascade deletion from event definition - critical for data integrity."""- event_def = EventDefinition.objects.create(- name='Test Event',- event_type_str='AUTOMATION',- event_window_secs=60,- dedupe_window_secs=300,- integration_id='test_id',- integration_name='test_integration'- )-- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- controller = Controller.objects.create(- name='Test Controller',- entity_state=entity_state,- controller_type_str='DEFAULT',- integration_id='ctrl_id',- integration_name='ctrl_integration'- )-- control_action = ControlAction.objects.create(- event_definition=event_def,- controller=controller,- value='on'- )-- action_id = control_action.id-- # Delete event definition should cascade to control actions- event_def.delete()-- self.assertFalse(ControlAction.objects.filter(id=action_id).exists())- return-- def test_control_action_cascade_deletion_from_controller(self):- """Test cascade deletion from controller - critical for data integrity."""- event_def = EventDefinition.objects.create(- name='Test Event',- event_type_str='AUTOMATION',- event_window_secs=60,- dedupe_window_secs=300,- integration_id='test_id',- integration_name='test_integration'- )-- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- controller = Controller.objects.create(- name='Test Controller',- entity_state=entity_state,- controller_type_str='DEFAULT',- integration_id='ctrl_id',- integration_name='ctrl_integration'- )-- control_action = ControlAction.objects.create(- event_definition=event_def,- controller=controller,- value='on'- )-- action_id = control_action.id-- # Delete controller should cascade to control actions- controller.delete()-- self.assertFalse(ControlAction.objects.filter(id=action_id).exists())- return-class TestEventHistory(BaseTestCase):@@ -392,32 +208,6 @@ class TestEventHistory(BaseTestCase):self.assertIn(history, recent_history)return- def test_event_history_cascade_deletion_from_event_definition(self):- """Test cascade deletion from event definition - critical for data integrity."""- event_def = EventDefinition.objects.create(- name='Test Event',- event_type_str='SECURITY',- event_window_secs=60,- dedupe_window_secs=300,- integration_id='test_id',- integration_name='test_integration'- )-- from django.utils import timezone-- history = EventHistory.objects.create(- event_definition=event_def,- event_datetime=timezone.now()- )-- history_id = history.id-- # Delete event definition should cascade to history- event_def.delete()-- self.assertFalse(EventHistory.objects.filter(id=history_id).exists())- return-class TestEventDefinitionAdvanced(BaseTestCase):"""Advanced EventDefinition tests for edge cases and business logic."""diff --git a/src/hi/apps/event/urls.py b/src/hi/apps/event/urls.pyindex a33e29f2..117bbcfa 100644--- a/src/hi/apps/event/urls.py+++ b/src/hi/apps/event/urls.py@@ -1,18 +1,19 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^definitions$',- views.EventDefinitionsView.as_view(),- name='event_definitions'),+ path( 'definitions',+ views.EventDefinitionsView.as_view(),+ name='event_definitions'),- re_path( r'^history$',- views.EventHistoryView.as_view(),- name='event_history'),+ path( 'history',+ views.EventHistoryView.as_view(),+ name='event_history'),- re_path( r'^edit/', include('hi.apps.event.edit.urls' )),+ path( 'edit/', include('hi.apps.event.edit.urls' )),]diff --git a/src/hi/apps/location/edit/urls.py b/src/hi/apps/location/edit/urls.pyindex 1e367127..38b066ae 100644--- a/src/hi/apps/location/edit/urls.py+++ b/src/hi/apps/location/edit/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,61 +6,61 @@ from . import viewsurlpatterns = [- re_path( r'^add$',- views.LocationAddView.as_view(),- name='location_edit_location_add'),+ path( 'add',+ views.LocationAddView.as_view(),+ name='location_edit_location_add'),- re_path( r'^add-first$',- views.LocationAddFirstView.as_view(),- name='location_edit_location_add_first'),+ path( 'add-first',+ views.LocationAddFirstView.as_view(),+ name='location_edit_location_add_first'),- re_path( r'^edit-mode/(?P<location_id>\d+)$',- views.LocationEditModeView.as_view(),- name='location_edit_mode' ),+ path( 'edit-mode/<int:location_id>',+ views.LocationEditModeView.as_view(),+ name='location_edit_mode' ),- re_path( r'^view/edit-mode/(?P<location_view_id>\d+)$',- views.LocationViewEditModeView.as_view(),- name='location_view_edit_mode' ),+ path( 'view/edit-mode/<int:location_view_id>',+ views.LocationViewEditModeView.as_view(),+ name='location_view_edit_mode' ),re_path( r'^item/edit-mode/(?P<html_id>[\w\-]+)$',views.LocationItemEditModeView.as_view(),name='location_item_edit_mode' ),- re_path( r'^location/properties/edit/(?P<location_id>\d+)$',- views.LocationPropertiesEditView.as_view(),- name='location_properties_edit'),+ path( 'location/properties/edit/<int:location_id>',+ views.LocationPropertiesEditView.as_view(),+ name='location_properties_edit'),- re_path( r'^svg/replace/(?P<location_id>\d+)$',- views.LocationSvgReplaceView.as_view(),- name='location_edit_svg_replace'),+ path( 'svg/replace/<int:location_id>',+ views.LocationSvgReplaceView.as_view(),+ name='location_edit_svg_replace'),- re_path( r'^delete/(?P<location_id>\d+)$',- views.LocationDeleteView.as_view(),- name='location_edit_location_delete' ),+ path( 'delete/<int:location_id>',+ views.LocationDeleteView.as_view(),+ name='location_edit_location_delete' ),- re_path( r'^view/add$',- views.LocationViewAddView.as_view(),- name='location_edit_location_view_add' ),+ path( 'view/add',+ views.LocationViewAddView.as_view(),+ name='location_edit_location_view_add' ),- re_path( r'^view/geometry/(?P<location_view_id>\d+)$',- views.LocationViewGeometryView.as_view(),- name='location_edit_location_view_geometry' ),+ path( 'view/geometry/<int:location_view_id>',+ views.LocationViewGeometryView.as_view(),+ name='location_edit_location_view_geometry' ),- re_path( r'^view/delete/(?P<location_view_id>\d+)$',- views.LocationViewDeleteView.as_view(),- name='location_edit_location_view_delete' ),+ path( 'view/delete/<int:location_view_id>',+ views.LocationViewDeleteView.as_view(),+ name='location_edit_location_view_delete' ),- re_path( r'^view/manage-item$',- views.LocationViewManageItemsView.as_view(),- name='location_edit_location_view_manage_items' ),+ path( 'view/manage-item',+ views.LocationViewManageItemsView.as_view(),+ name='location_edit_location_view_manage_items' ),- re_path( r'^view/entity/toggle/(?P<location_view_id>\d+)/(?P<entity_id>\d+)$',- views.LocationViewEntityToggleView.as_view(),- name='location_edit_location_view_entity_toggle' ),+ path( 'view/entity/toggle/<int:location_view_id>/<int:entity_id>',+ views.LocationViewEntityToggleView.as_view(),+ name='location_edit_location_view_entity_toggle' ),- re_path( r'^view/collection/toggle/(?P<location_view_id>\d+)/(?P<collection_id>\d+)$',- views.LocationViewCollectionToggleView.as_view(),- name='location_edit_location_view_collection_toggle' ),+ path( 'view/collection/toggle/<int:location_view_id>/<int:collection_id>',+ views.LocationViewCollectionToggleView.as_view(),+ name='location_edit_location_view_collection_toggle' ),re_path( r'^item/position/(?P<html_id>[\w\-]+)$',views.LocationItemPositionView.as_view(),@@ -69,44 +70,44 @@ urlpatterns = [views.LocationItemPathView.as_view(),name='location_edit_location_item_path' ),- re_path( r'^svg/background/(?P<location_id>\d+)$',- views.LocationSvgBackgroundView.as_view(),- name='location_svg_background'),+ path( 'svg/background/<int:location_id>',+ views.LocationSvgBackgroundView.as_view(),+ name='location_svg_background'),- re_path( r'^svg/template/(?P<location_id>\d+)$',- views.LocationSvgTemplateSelectView.as_view(),- name='location_svg_template_select'),+ path( 'svg/template/<int:location_id>',+ views.LocationSvgTemplateSelectView.as_view(),+ name='location_svg_template_select'),- re_path( r'^svg/edit/(?P<location_id>\d+)$',- views.LocationSvgEditView.as_view(),- name='location_edit_svg_edit'),+ path( 'svg/edit/<int:location_id>',+ views.LocationSvgEditView.as_view(),+ name='location_edit_svg_edit'),- re_path( r'^svg/edit/cancel/(?P<location_id>\d+)$',- views.LocationSvgEditCancelView.as_view(),- name='location_svg_edit_cancel'),+ path( 'svg/edit/cancel/<int:location_id>',+ views.LocationSvgEditCancelView.as_view(),+ name='location_svg_edit_cancel'),- re_path( r'^svg/edit/exit/(?P<location_id>\d+)$',- views.LocationSvgEditExitView.as_view(),- name='location_svg_edit_exit'),+ path( 'svg/edit/exit/<int:location_id>',+ views.LocationSvgEditExitView.as_view(),+ name='location_svg_edit_exit'),- re_path( r'^svg/edit/viewbox/(?P<location_id>\d+)$',- views.LocationSvgEditViewBoxView.as_view(),- name='location_svg_edit_viewbox'),+ path( 'svg/edit/viewbox/<int:location_id>',+ views.LocationSvgEditViewBoxView.as_view(),+ name='location_svg_edit_viewbox'),- re_path( r'^svg/edit/revert/(?P<location_id>\d+)$',- views.LocationSvgEditRevertView.as_view(),- name='location_svg_edit_revert'),+ path( 'svg/edit/revert/<int:location_id>',+ views.LocationSvgEditRevertView.as_view(),+ name='location_svg_edit_revert'),- re_path( r'^svg/edit/save/(?P<location_id>\d+)$',- views.LocationSvgEditSaveView.as_view(),- name='location_svg_edit_save'),+ path( 'svg/edit/save/<int:location_id>',+ views.LocationSvgEditSaveView.as_view(),+ name='location_svg_edit_save'),- re_path( r'^svg/edit/export/(?P<location_id>\d+)$',- views.LocationSvgEditExportView.as_view(),- name='location_svg_edit_export'),+ path( 'svg/edit/export/<int:location_id>',+ views.LocationSvgEditExportView.as_view(),+ name='location_svg_edit_export'),- re_path( r'^svg/edit/help$',- views.LocationSvgEditHelpView.as_view(),- name='location_svg_edit_help'),+ path( 'svg/edit/help',+ views.LocationSvgEditHelpView.as_view(),+ name='location_svg_edit_help'),]diff --git a/src/hi/apps/location/tests/test_models.py b/src/hi/apps/location/tests/test_models.pyindex 093e60cd..a24c66b8 100644--- a/src/hi/apps/location/tests/test_models.py+++ b/src/hi/apps/location/tests/test_models.py@@ -238,31 +238,6 @@ class TestLocationView(BaseTestCase):self.assertEqual(location_view.svg_style_name_str, 'color')return- def test_location_view_cascade_deletion_from_location(self):- """Test cascade deletion from location - critical for data integrity."""- location = Location.objects.create(- name='Test Location',- svg_fragment_filename='test.svg',- svg_view_box_str='0 0 100 100'- )-- location_view = LocationView.objects.create(- location=location,- location_view_type_str='DEFAULT',- name='Test View',- svg_view_box_str='0 0 50 50',- svg_rotate=0,- svg_style_name_str='COLOR'- )-- view_id = location_view.id-- # Delete location should cascade to views- location.delete()-- self.assertFalse(LocationView.objects.filter(id=view_id).exists())- return-class TestLocationAttribute(BaseTestCase):diff --git a/src/hi/apps/location/urls.py b/src/hi/apps/location/urls.pyindex a5cdc31b..508f34c0 100644--- a/src/hi/apps/location/urls.py+++ b/src/hi/apps/location/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import include, re_pathfrom . import views@@ -5,42 +6,42 @@ from . import viewsurlpatterns = [- re_path( r'^switch/(?P<location_id>\d+)$',- views.LocationSwitchView.as_view(),- name='location_switch'),+ path( 'switch/<int:location_id>',+ views.LocationSwitchView.as_view(),+ name='location_switch'),- re_path( r'^edit/(?P<location_id>\d+)$',- views.LocationEditView.as_view(),- name='location_edit_location_edit'),+ path( 'edit/<int:location_id>',+ views.LocationEditView.as_view(),+ name='location_edit_location_edit'),- re_path( r'^view/(?P<location_view_id>\d+)$',- views.LocationViewView.as_view(),- name='location_view'),+ path( 'view/<int:location_view_id>',+ views.LocationViewView.as_view(),+ name='location_view'),- re_path( r'^view$',- views.LocationViewDefaultView.as_view(),- name='location_view_default'),+ path( 'view',+ views.LocationViewDefaultView.as_view(),+ name='location_view_default'),re_path( r'^item/status/(?P<html_id>[\w\-]+)$',views.LocationItemStatusView.as_view(),name='location_item_status' ),- re_path( r'^attribute/upload/(?P<location_id>\d+)$',- views.LocationAttributeUploadView.as_view(),- name='location_attribute_upload'),+ path( 'attribute/upload/<int:location_id>',+ views.LocationAttributeUploadView.as_view(),+ name='location_attribute_upload'),- re_path( r'^attribute/history/(?P<location_id>\d+)/(?P<attribute_id>\d+)$',- views.LocationAttributeHistoryInlineView.as_view(),- name='location_attribute_history_inline'),+ path( 'attribute/history/<int:location_id>/<int:attribute_id>',+ views.LocationAttributeHistoryInlineView.as_view(),+ name='location_attribute_history_inline'),- re_path( r'^attribute/restore/(?P<location_id>\d+)/(?P<attribute_id>\d+)/(?P<history_id>\d+)$',- views.LocationAttributeRestoreInlineView.as_view(),- name='location_attribute_restore_inline'),+ path( 'attribute/restore/<int:location_id>/<int:attribute_id>/<int:history_id>',+ views.LocationAttributeRestoreInlineView.as_view(),+ name='location_attribute_restore_inline'),- re_path( r'^attribute/restore-deleted/(?P<location_id>\d+)/(?P<attribute_id>\d+)/$',- views.LocationAttributeRestoreDeletedInlineView.as_view(),- name='location_attribute_restore_deleted_inline'),+ path( 'attribute/restore-deleted/<int:location_id>/<int:attribute_id>/',+ views.LocationAttributeRestoreDeletedInlineView.as_view(),+ name='location_attribute_restore_deleted_inline'),- re_path( r'^edit/', include('hi.apps.location.edit.urls' )),+ path( 'edit/', include('hi.apps.location.edit.urls' )),]diff --git a/src/hi/apps/notify/tests/ui/urls.py b/src/hi/apps/notify/tests/ui/urls.pyindex 843de374..2abf79fd 100644--- a/src/hi/apps/notify/tests/ui/urls.py+++ b/src/hi/apps/notify/tests/ui/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,9 +6,9 @@ from . import viewsurlpatterns = [- re_path( r'^$',- views.TestUiNotifyHomeView.as_view(),- name='notify_tests_ui'),+ path( '',+ views.TestUiNotifyHomeView.as_view(),+ name='notify_tests_ui'),re_path( r'^email/view/(?P<email_type>\w+)$',views.TestUiViewEmailView.as_view(),diff --git a/src/hi/apps/profiles/tests/devtools/urls.py b/src/hi/apps/profiles/tests/devtools/urls.pyindex c2c6c318..de1fd110 100644--- a/src/hi/apps/profiles/tests/devtools/urls.py+++ b/src/hi/apps/profiles/tests/devtools/urls.py@@ -1,15 +1,15 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^$',- views.ProfileDevtoolsHomeView.as_view(),- name='profiles_devtools'),+ path( '',+ views.ProfileDevtoolsHomeView.as_view(),+ name='profiles_devtools'),- re_path(r'^snapshot$',- views.ProfileDevtoolsSnapshotView.as_view(),- name='profiles_devtools_snapshot'),+ path('snapshot',+ views.ProfileDevtoolsSnapshotView.as_view(),+ name='profiles_devtools_snapshot'),]diff --git a/src/hi/apps/profiles/urls.py b/src/hi/apps/profiles/urls.pyindex 766372b4..2c492b32 100644--- a/src/hi/apps/profiles/urls.py+++ b/src/hi/apps/profiles/urls.py@@ -1,26 +1,27 @@+from django.urls import pathfrom django.urls import re_pathfrom . import viewsurlpatterns = [- re_path( r'^initialize/custom$',- views.InitializeCustomView.as_view(),- name='profiles_initialize_custom'),+ path( 'initialize/custom',+ views.InitializeCustomView.as_view(),+ name='profiles_initialize_custom'),re_path( r'^initialize/prefined/(?P<profile_type>\w+)/$',views.InitializePredefinedView.as_view(),name='profiles_initialize_predefined'),- re_path( r'^view-reference-help$',- views.ViewReferenceHelpView.as_view(),- name='profiles_view_reference_help'),+ path( 'view-reference-help',+ views.ViewReferenceHelpView.as_view(),+ name='profiles_view_reference_help'),- re_path( r'^edit-reference-help$',- views.EditReferenceHelpView.as_view(),- name='profiles_edit_reference_help'),+ path( 'edit-reference-help',+ views.EditReferenceHelpView.as_view(),+ name='profiles_edit_reference_help'),- re_path( r'^dismiss-view-intro-help$',- views.DismissViewIntroHelpView.as_view(),- name='profiles_dismiss_view_intro_help'),+ path( 'dismiss-view-intro-help',+ views.DismissViewIntroHelpView.as_view(),+ name='profiles_dismiss_view_intro_help'),]diff --git a/src/hi/apps/security/urls.py b/src/hi/apps/security/urls.pyindex 20289dbd..477cebe4 100644--- a/src/hi/apps/security/urls.py+++ b/src/hi/apps/security/urls.py@@ -1,11 +1,11 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^state/action/(?P<action>.+)$',- views.SecurityStateActionView.as_view(),- name='security_state_action'),+ path( 'state/action/<path:action>',+ views.SecurityStateActionView.as_view(),+ name='security_state_action'),]diff --git a/src/hi/apps/sense/tests/test_models.py b/src/hi/apps/sense/tests/test_models.pyindex c61c15c4..d814a6dc 100644--- a/src/hi/apps/sense/tests/test_models.py+++ b/src/hi/apps/sense/tests/test_models.py@@ -16,32 +16,6 @@ logging.disable(logging.CRITICAL)class TestSensor(BaseTestCase):- def test_sensor_cascade_deletion_from_entity_state(self):- """Test cascade deletion from entity state - critical for data integrity."""- entity = Entity.objects.create(- name='Test Entity',- entity_type_str='CAMERA'- )- entity_state = EntityState.objects.create(- entity=entity,- entity_state_type_str='ON_OFF'- )-- sensor = Sensor.objects.create(- name='Test Sensor',- entity_state=entity_state,- sensor_type_str='DEFAULT',- integration_id='test_id',- integration_name='test_integration'- )-- sensor_id = sensor.id-- # Delete entity state should cascade to sensor- entity_state.delete()-- self.assertFalse(Sensor.objects.filter(id=sensor_id).exists())-def test_sensor_sensor_type_property_conversion(self):"""Test sensor_type property enum conversion - custom business logic."""entity = Entity.objects.create(@@ -188,21 +162,6 @@ class TestSensorHistory(TransactionTestCase):integration_name='test_integration')- def test_sensor_history_cascade_deletion_from_sensor(self):- """Test cascade deletion from sensor - critical for data integrity."""- history = SensorHistory.objects.create(- sensor=self.sensor,- value='test_value',- response_datetime=timezone.now()- )-- history_id = history.id-- # Delete sensor should cascade to history- self.sensor.delete()-- self.assertFalse(SensorHistory.objects.filter(id=history_id).exists())-def test_sensor_history_ordering_by_timestamp(self):"""Test default ordering by response_datetime descending."""from django.utils import timezonediff --git a/src/hi/apps/sense/urls.py b/src/hi/apps/sense/urls.pyindex edd1d33b..7544bff4 100644--- a/src/hi/apps/sense/urls.py+++ b/src/hi/apps/sense/urls.py@@ -1,11 +1,11 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^sensor/response/details/(?P<sensor_history_id>\d+)$',- views.SensorHistoryDetailsView.as_view(),- name='sense_sensor_history_details'),+ path( 'sensor/response/details/<int:sensor_history_id>',+ views.SensorHistoryDetailsView.as_view(),+ name='sense_sensor_history_details'),]diff --git a/src/hi/apps/system/tests/ui/urls.py b/src/hi/apps/system/tests/ui/urls.pyindex 457f05da..3023ab42 100644--- a/src/hi/apps/system/tests/ui/urls.py+++ b/src/hi/apps/system/tests/ui/urls.py@@ -1,10 +1,11 @@+from django.urls import pathfrom django.urls import re_pathfrom . import viewsurlpatterns = [- re_path(r'^$',- views.SystemTestUiHomeView.as_view(),- name='system_test_ui'),+ path('',+ views.SystemTestUiHomeView.as_view(),+ name='system_test_ui'),re_path(r'^health/(?P<status_type>[\w-]+)/(?P<api_flag>[\w-]+)/$',views.SystemTestUiHealthStatusView.as_view(),diff --git a/src/hi/apps/system/urls.py b/src/hi/apps/system/urls.pyindex 65f24e41..3cd810a5 100644--- a/src/hi/apps/system/urls.py+++ b/src/hi/apps/system/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,9 +6,9 @@ from . import viewsurlpatterns = [- re_path( r'^info$',- views.SystemInfoView.as_view(),- name = 'system_info' ),+ path( 'info',+ views.SystemInfoView.as_view(),+ name = 'system_info' ),re_path( r'^health/(?P<provider_id>[\w\.\-]+)$',views.SystemHealthStatusView.as_view(),@@ -17,7 +18,7 @@ urlpatterns = [views.SystemApiHealthStatusView.as_view(),name = 'system_api_health_status' ),- re_path( r'^background-tasks/details$',- views.BackgroundTaskDetailsView.as_view(),- name = 'background_task_details' ),+ path( 'background-tasks/details',+ views.BackgroundTaskDetailsView.as_view(),+ name = 'background_task_details' ),]diff --git a/src/hi/apps/user/middleware.py b/src/hi/apps/user/middleware.pyindex b69b3e08..afc5e215 100644--- a/src/hi/apps/user/middleware.py+++ b/src/hi/apps/user/middleware.py@@ -4,7 +4,7 @@ from django.urls import resolvefrom .views import UserSigninView-class AuthenticationMiddleware(object):+class AuthenticationMiddleware:EXEMPT_VIEW_URL_NAMES = {'admin',diff --git a/src/hi/apps/user/tests/ui/urls.py b/src/hi/apps/user/tests/ui/urls.pyindex 7ed884e0..b6470c31 100644--- a/src/hi/apps/user/tests/ui/urls.py+++ b/src/hi/apps/user/tests/ui/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,9 +6,9 @@ from . import viewsurlpatterns = [- re_path( r'^$',- views.TestUiUserHomeView.as_view(),- name='user_tests_ui'),+ path( '',+ views.TestUiUserHomeView.as_view(),+ name='user_tests_ui'),re_path( r'^email/signin/view/(?P<email_type>\w+)$',views.TestUiViewSigninEmailView.as_view(),diff --git a/src/hi/apps/user/urls.py b/src/hi/apps/user/urls.pyindex 83c5a6c9..f91b3d3c 100644--- a/src/hi/apps/user/urls.py+++ b/src/hi/apps/user/urls.py@@ -1,3 +1,4 @@+from django.urls import pathfrom django.urls import re_pathfrom . import views@@ -5,13 +6,13 @@ from . import viewsurlpatterns = [- re_path( r'^signin$',- views.UserSigninView.as_view(),- name='user_signin'),+ path( 'signin',+ views.UserSigninView.as_view(),+ name='user_signin'),- re_path( r"^signin/magic/code$",- views.SigninMagicCodeView.as_view(),- name="user_signin_magic_code"),+ path( "signin/magic/code",+ views.SigninMagicCodeView.as_view(),+ name="user_signin_magic_code"),re_path( r"^signin/magic/link/(?P<token>[\w\-]+)/(?P<email>.+)$",views.SigninMagicLinkView.as_view(),diff --git a/src/hi/apps/weather/tests/test_weather_alert_alarm_mapper.py b/src/hi/apps/weather/tests/test_weather_alert_alarm_mapper.pyindex 783a1d9c..6793e87c 100644--- a/src/hi/apps/weather/tests/test_weather_alert_alarm_mapper.py+++ b/src/hi/apps/weather/tests/test_weather_alert_alarm_mapper.py@@ -3,7 +3,7 @@ Tests for WeatherAlertAlarmMapper - converting weather alerts to system alarms."""import loggingfrom unittest.mock import patch-from datetime import datetime, timedelta+from datetime import datetime, timedelta, UTCfrom django.utils import timezone@@ -30,7 +30,7 @@ class TestWeatherAlertAlarmMapper(BaseTestCase):def setUp(self):self.mapper = WeatherAlertAlarmMapper()# Use timezone-aware datetime like real NWS data- self.base_datetime = timezone.make_aware(datetime(2024, 3, 15, 20, 0, 0), timezone.utc)+ self.base_datetime = timezone.make_aware(datetime(2024, 3, 15, 20, 0, 0), UTC)def create_test_weather_alert(self,event_type: WeatherEventType = WeatherEventType.TORNADO,diff --git a/src/hi/apps/weather/tests/test_weather_alert_integration.py b/src/hi/apps/weather/tests/test_weather_alert_integration.pyindex b342065f..c4686977 100644--- a/src/hi/apps/weather/tests/test_weather_alert_integration.py+++ b/src/hi/apps/weather/tests/test_weather_alert_integration.py@@ -217,10 +217,10 @@ class TestWeatherAlertIntegration(AsyncTaskTestCase):"""Helper to create test weather alerts."""from hi.apps.weather.transient_models import WeatherAlertfrom hi.apps.weather.enums import AlertCategory, AlertStatus, AlertUrgency, AlertCertainty- from datetime import datetime+ from datetime import datetime, UTCfrom django.utils import timezone-- base_time = timezone.make_aware(datetime(2024, 3, 15, 20, 0, 0), timezone.utc)++ base_time = timezone.make_aware(datetime(2024, 3, 15, 20, 0, 0), UTC)return WeatherAlert(event_type=event_type,diff --git a/src/hi/apps/weather/tests/ui/urls.py b/src/hi/apps/weather/tests/ui/urls.pyindex 38976983..c43636fe 100644--- a/src/hi/apps/weather/tests/ui/urls.py+++ b/src/hi/apps/weather/tests/ui/urls.py@@ -1,29 +1,29 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^$',- views.TestUiWeatherHomeView.as_view(),- name='weather_tests_ui'),+ path( '',+ views.TestUiWeatherHomeView.as_view(),+ name='weather_tests_ui'),- re_path( r'^conditions/details$',- views.TestUiConditionsDetailsView.as_view(),- name='weather_tests_ui_conditions_details'),+ path( 'conditions/details',+ views.TestUiConditionsDetailsView.as_view(),+ name='weather_tests_ui_conditions_details'),- re_path( r'^astronomical/details$',- views.TestUiAstronomicalDetailsView.as_view(),- name='weather_tests_ui_astronomical_details'),+ path( 'astronomical/details',+ views.TestUiAstronomicalDetailsView.as_view(),+ name='weather_tests_ui_astronomical_details'),- re_path( r'^forecast$',- views.TestUiForecastView.as_view(),- name='weather_tests_ui_forecast'),+ path( 'forecast',+ views.TestUiForecastView.as_view(),+ name='weather_tests_ui_forecast'),- re_path( r'^history$',- views.TestUiHistoryView.as_view(),- name='weather_tests_ui_history'),+ path( 'history',+ views.TestUiHistoryView.as_view(),+ name='weather_tests_ui_history'),]diff --git a/src/hi/apps/weather/urls.py b/src/hi/apps/weather/urls.pyindex a9425068..c71f1be0 100644--- a/src/hi/apps/weather/urls.py+++ b/src/hi/apps/weather/urls.py@@ -1,23 +1,23 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^current-conditions/details$',- views.CurrentConditionsDetailsView.as_view(),- name='weather_current_conditions_details'),+ path( 'current-conditions/details',+ views.CurrentConditionsDetailsView.as_view(),+ name='weather_current_conditions_details'),- re_path( r'^todays-astronomical/details$',- views.TodaysAstronomicalDetailsView.as_view(),- name='weather_todays_astronomical_details'),+ path( 'todays-astronomical/details',+ views.TodaysAstronomicalDetailsView.as_view(),+ name='weather_todays_astronomical_details'),- re_path( r'^forecast$',- views.ForecastView.as_view(),- name='weather_forecast'),+ path( 'forecast',+ views.ForecastView.as_view(),+ name='weather_forecast'),- re_path( r'^history$',- views.HistoryView.as_view(),- name='weather_history'),+ path( 'history',+ views.HistoryView.as_view(),+ name='weather_history'),]diff --git a/src/hi/environment/tests/test_views.py b/src/hi/environment/tests/test_views.pyindex 1e479e3e..2c7cad15 100644--- a/src/hi/environment/tests/test_views.py+++ b/src/hi/environment/tests/test_views.py@@ -37,20 +37,33 @@ class TestEnvironmentHomeView(SyncViewTestCase):'EMAIL_USE_TLS','EMAIL_USE_SSL','CORS_ALLOWED_ORIGINS',- 'CSP_DEFAULT_SRC',- 'CSP_CONNECT_SRC',- 'CSP_FRAME_SRC',- 'CSP_SCRIPT_SRC',- 'CSP_STYLE_SRC',- 'CSP_MEDIA_SRC',- 'CSP_IMG_SRC',- 'CSP_CHILD_SRC',- 'CSP_FONT_SRC',+ 'CONTENT_SECURITY_POLICY',]-+for key in expected_keys:self.assertIn(key, data, f"Expected key '{key}' not found in config data")+ # django-csp 4.x dict shape — every active directive should be+ # present under DIRECTIVES.+ csp_directives = data['CONTENT_SECURITY_POLICY']['DIRECTIVES']+ expected_directives = [+ 'default-src',+ 'connect-src',+ 'frame-src',+ 'script-src',+ 'style-src',+ 'media-src',+ 'img-src',+ 'child-src',+ 'font-src',+ 'worker-src',+ ]+ for directive in expected_directives:+ self.assertIn(+ directive, csp_directives,+ f"Expected CSP directive '{directive}' not found",+ )+def test_post_not_allowed(self):"""Test that POST requests are not allowed."""url = reverse('env_home')@@ -77,15 +90,11 @@ class TestEnvironmentHomeView(SyncViewTestCase):mock_settings.EMAIL_USE_TLS = Truemock_settings.EMAIL_USE_SSL = Falsemock_settings.CORS_ALLOWED_ORIGINS = ['http://test.com']- mock_settings.CSP_DEFAULT_SRC = ["'self'"]- mock_settings.CSP_CONNECT_SRC = ["'self'"]- mock_settings.CSP_FRAME_SRC = ["'self'"]- mock_settings.CSP_SCRIPT_SRC = ["'self'"]- mock_settings.CSP_STYLE_SRC = ["'self'"]- mock_settings.CSP_MEDIA_SRC = ["'self'"]- mock_settings.CSP_IMG_SRC = ["'self'"]- mock_settings.CSP_CHILD_SRC = ["'self'"]- mock_settings.CSP_FONT_SRC = ["'self'"]+ mock_settings.CONTENT_SECURITY_POLICY = {+ 'DIRECTIVES': {+ 'default-src': ["'self'"],+ },+ }url = reverse('env_home')response = self.client.get(url)diff --git a/src/hi/environment/urls.py b/src/hi/environment/urls.pyindex 4d1988ec..31343277 100644--- a/src/hi/environment/urls.py+++ b/src/hi/environment/urls.py@@ -1,10 +1,10 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path(r'^$',- views.EnvironmentHomeView.as_view(),- name='env_home'),+ path('',+ views.EnvironmentHomeView.as_view(),+ name='env_home'),]diff --git a/src/hi/environment/views.py b/src/hi/environment/views.pyindex a9b24dc0..5cfa10a1 100644--- a/src/hi/environment/views.py+++ b/src/hi/environment/views.py@@ -25,15 +25,7 @@ class EnvironmentHomeView(View):'EMAIL_USE_TLS': settings.EMAIL_USE_TLS,'EMAIL_USE_SSL': settings.EMAIL_USE_SSL,'CORS_ALLOWED_ORIGINS': settings.CORS_ALLOWED_ORIGINS,- 'CSP_DEFAULT_SRC': settings.CSP_DEFAULT_SRC,- 'CSP_CONNECT_SRC': settings.CSP_CONNECT_SRC,- 'CSP_FRAME_SRC': settings.CSP_FRAME_SRC,- 'CSP_SCRIPT_SRC': settings.CSP_SCRIPT_SRC,- 'CSP_STYLE_SRC': settings.CSP_STYLE_SRC,- 'CSP_MEDIA_SRC': settings.CSP_MEDIA_SRC,- 'CSP_IMG_SRC': settings.CSP_IMG_SRC,- 'CSP_CHILD_SRC': settings.CSP_CHILD_SRC,- 'CSP_FONT_SRC': settings.CSP_FONT_SRC,+ 'CONTENT_SECURITY_POLICY': settings.CONTENT_SECURITY_POLICY,}def get(self, request, *args, **kwargs):diff --git a/src/hi/hi_async_view.py b/src/hi/hi_async_view.pyindex 92119507..a0d64029 100644--- a/src/hi/hi_async_view.py+++ b/src/hi/hi_async_view.py@@ -86,7 +86,7 @@ class HiSideView( HiAsyncView ):def get_push_url( self, request ):- referrer_url_str = request.META.get('HTTP_REFERER', '')+ referrer_url_str = request.headers.get('referer', '')if not referrer_url_str:return Nonediff --git a/src/hi/hi_grid_view.py b/src/hi/hi_grid_view.pyindex e5e65003..ef676108 100644--- a/src/hi/hi_grid_view.py+++ b/src/hi/hi_grid_view.py@@ -165,7 +165,7 @@ class HiGridView( View ):return template.render( context, request = request )def get_push_url( self, request ):- referrer_url = request.META.get('HTTP_REFERER', '')+ referrer_url = request.headers.get('referer', '')if referrer_url:parsed_url = urllib.parse.urlparse( referrer_url )query_params = urllib.parse.parse_qs( parsed_url.query )diff --git a/src/hi/integrations/urls.py b/src/hi/integrations/urls.pyindex fd038a49..ab71e87d 100644--- a/src/hi/integrations/urls.py+++ b/src/hi/integrations/urls.py@@ -1,4 +1,5 @@from django.apps import apps+from django.urls import pathfrom django.urls import re_path, includefrom hi.apps.common.module_utils import import_module_safe@@ -7,13 +8,13 @@ from . import viewsurlpatterns = [- re_path( r'^$',- views.IntegrationHomeView.as_view(),- name='integrations_home' ),+ path( '',+ views.IntegrationHomeView.as_view(),+ name='integrations_home' ),- re_path( r'^select$',- views.IntegrationSelectView.as_view(),- name='integrations_select' ),+ path( 'select',+ views.IntegrationSelectView.as_view(),+ name='integrations_select' ),re_path( r'^enable/(?P<integration_id>[\w\-]+)$',views.IntegrationEnableView.as_view(),@@ -47,21 +48,21 @@ urlpatterns = [views.IntegrationPlacementView.as_view(),name='integrations_placement' ),- re_path( r'^refine/(?P<location_view_id>\d+)$',- views.IntegrationRefineView.as_view(),- name='integrations_refine' ),+ path( 'refine/<int:location_view_id>',+ views.IntegrationRefineView.as_view(),+ name='integrations_refine' ),re_path( r'^manage/(?P<integration_id>[\w\-]*)$',views.IntegrationManageView.as_view(),name='integrations_manage' ),- re_path( r'^attribute/history/(?P<integration_id>\d+)/(?P<attribute_id>\d+)/$',- views.IntegrationAttributeHistoryInlineView.as_view(),- name='integration_attribute_history_inline'),+ path( 'attribute/history/<int:integration_id>/<int:attribute_id>/',+ views.IntegrationAttributeHistoryInlineView.as_view(),+ name='integration_attribute_history_inline'),- re_path( r'^attribute/restore/(?P<integration_id>\d+)/(?P<attribute_id>\d+)/(?P<history_id>\d+)/$',- views.IntegrationAttributeRestoreInlineView.as_view(),- name='integration_attribute_restore_inline'),+ path( 'attribute/restore/<int:integration_id>/<int:attribute_id>/<int:history_id>/',+ views.IntegrationAttributeRestoreInlineView.as_view(),+ name='integration_attribute_restore_inline'),]diff --git a/src/hi/middleware.py b/src/hi/middleware.pyindex c044827c..b5f8815c 100644--- a/src/hi/middleware.py+++ b/src/hi/middleware.py@@ -38,7 +38,7 @@ class ViewMiddleware:return-class ExceptionMiddleware(object):+class ExceptionMiddleware:def __init__(self, get_response):self.get_response = get_response@@ -55,7 +55,7 @@ class ExceptionMiddleware(object):return Nonedef process_exception( self, request, exception ):- ip_address = request.META.get( 'HTTP_X_FORWARDED_FOR' ) # nginx forwarded+ ip_address = request.headers.get( 'x-forwarded-for' ) # nginx forwardedlogger.warning( f'Exception caught in middleware [{ip_address}]: {exception}' )if isinstance( exception, BadRequest ):diff --git a/src/hi/requirements/base.txt b/src/hi/requirements/base.txtindex 01caf017..9ea25040 100644--- a/src/hi/requirements/base.txt+++ b/src/hi/requirements/base.txt@@ -4,11 +4,10 @@ cachetools==5.5.0certifi==2025.8.3charset-normalizer==3.4.3dateparser==1.2.2-Django==4.2.30-django-constance==3.1.0-django-csp==3.8-django-picklefield==3.3-django-pipeline==4.0.0+Django==5.2.14+django-constance==4.3.5+django-csp==4.0+django-pipeline==4.1.0frozenlist==1.4.1gunicorn==23.0.0idna==3.10diff --git a/src/hi/settings/base.py b/src/hi/settings/base.pyindex 0a06421c..b368256d 100644--- a/src/hi/settings/base.py+++ b/src/hi/settings/base.py@@ -33,60 +33,58 @@ ALLOWED_HOSTS = ENV.ALLOWED_HOSTSCORS_ALLOWED_ORIGINS = ENV.CORS_ALLOWED_ORIGINS-CSP_DEFAULT_SRC = (- "'self'",- 'data:',-) + ENV.EXTRA_CSP_URLS--CSP_CONNECT_SRC = (- "'self'",-) + ENV.EXTRA_CSP_URLS--CSP_FRAME_SRC = (- "'self'",-) + ENV.EXTRA_CSP_URLS--CSP_SCRIPT_SRC = (- "'self'",- "'unsafe-inline'",- "'unsafe-eval'",-) + ENV.EXTRA_CSP_URLS--CSP_STYLE_SRC = (- "'self'",- "'unsafe-inline'",- "'unsafe-eval'",-) + ENV.EXTRA_CSP_URLS--CSP_MEDIA_SRC = (- "'self'",- "'unsafe-inline'",- "'unsafe-eval'",- 'data:',-) + ENV.EXTRA_CSP_URLS--CSP_IMG_SRC = (- "'self'",- 'data:',-) + ENV.EXTRA_CSP_URLS--CSP_CHILD_SRC = (- "'self'",-) + ENV.EXTRA_CSP_URLS--CSP_FONT_SRC = (- "'self'",- 'data:',-) + ENV.EXTRA_CSP_URLS--CSP_WORKER_SRC = (- "'self'",-) + ENV.EXTRA_CSP_URLS+# django-csp 4.x dict-based config. Directive keys are kebab-case+# without the ``CSP_`` prefix (see django-csp migration guide). Each+# value concatenates with ENV.EXTRA_CSP_URLS so deployments can extend+# the allow-lists without editing source.+CONTENT_SECURITY_POLICY = {+ 'DIRECTIVES': {+ 'default-src': (+ "'self'",+ 'data:',+ ) + ENV.EXTRA_CSP_URLS,+ 'connect-src': (+ "'self'",+ ) + ENV.EXTRA_CSP_URLS,+ 'frame-src': (+ "'self'",+ ) + ENV.EXTRA_CSP_URLS,+ 'script-src': (+ "'self'",+ "'unsafe-inline'",+ "'unsafe-eval'",+ ) + ENV.EXTRA_CSP_URLS,+ 'style-src': (+ "'self'",+ "'unsafe-inline'",+ "'unsafe-eval'",+ ) + ENV.EXTRA_CSP_URLS,+ 'media-src': (+ "'self'",+ "'unsafe-inline'",+ "'unsafe-eval'",+ 'data:',+ ) + ENV.EXTRA_CSP_URLS,+ 'img-src': (+ "'self'",+ 'data:',+ ) + ENV.EXTRA_CSP_URLS,+ 'child-src': (+ "'self'",+ ) + ENV.EXTRA_CSP_URLS,+ 'font-src': (+ "'self'",+ 'data:',+ ) + ENV.EXTRA_CSP_URLS,+ 'worker-src': (+ "'self'",+ ) + ENV.EXTRA_CSP_URLS,+ },+}LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = True-USE_L10N = TrueUSE_TZ = Truediff --git a/src/hi/settings/local.py b/src/hi/settings/local.pyindex 790873a4..a6afbbf7 100644--- a/src/hi/settings/local.py+++ b/src/hi/settings/local.py@@ -2,7 +2,14 @@ from .base import *DEBUG = False-STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'+STORAGES = {+ "default": {+ "BACKEND": "django.core.files.storage.FileSystemStorage",+ },+ "staticfiles": {+ "BACKEND": 'pipeline.storage.PipelineManifestStorage',+ },+}STATIC_ROOT = '/src/static'LOGGING = {diff --git a/src/hi/settings/production.py b/src/hi/settings/production.pyindex 2f304a39..7caed1ed 100644--- a/src/hi/settings/production.py+++ b/src/hi/settings/production.py@@ -4,7 +4,14 @@ from .base import *# SECURITY WARNING: don't run with debug turned on in production!DEBUG = False-STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'+STORAGES = {+ "default": {+ "BACKEND": "django.core.files.storage.FileSystemStorage",+ },+ "staticfiles": {+ "BACKEND": 'pipeline.storage.PipelineManifestStorage',+ },+}STATIC_ROOT = '/src/static'LOGGING = {diff --git a/src/hi/settings/staging.py b/src/hi/settings/staging.pyindex af3ad4a5..93089c4b 100644--- a/src/hi/settings/staging.py+++ b/src/hi/settings/staging.py@@ -4,7 +4,14 @@ from .base import *# SECURITY WARNING: don't run with debug turned on in production!DEBUG = False-STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'+STORAGES = {+ "default": {+ "BACKEND": "django.core.files.storage.FileSystemStorage",+ },+ "staticfiles": {+ "BACKEND": 'pipeline.storage.PipelineManifestStorage',+ },+}STATIC_ROOT = '/src/static'LOGGING = {diff --git a/src/hi/simulator/services/hass/api/urls.py b/src/hi/simulator/services/hass/api/urls.pyindex dae6b48c..061df53e 100644--- a/src/hi/simulator/services/hass/api/urls.py+++ b/src/hi/simulator/services/hass/api/urls.py@@ -1,16 +1,17 @@+from django.urls import pathfrom django.urls import re_pathfrom . import viewsurlpatterns = [- re_path( r'^$',- views.PingView.as_view(),- name = 'hass_api_ping' ),+ path( '',+ views.PingView.as_view(),+ name = 'hass_api_ping' ),- re_path( r'^states$',- views.AllStatesView.as_view(),- name = 'hass_api_states' ),+ path( 'states',+ views.AllStatesView.as_view(),+ name = 'hass_api_states' ),re_path( r'^states/(?P<entity_id>[\w\._\-]+)$',views.StateView.as_view(),diff --git a/src/hi/simulator/services/hass/urls.py b/src/hi/simulator/services/hass/urls.pyindex db784363..353effaa 100644--- a/src/hi/simulator/services/hass/urls.py+++ b/src/hi/simulator/services/hass/urls.py@@ -1,12 +1,13 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^$',- views.HomeView.as_view(),- name = 'hass_home' ),+ path( '',+ views.HomeView.as_view(),+ name = 'hass_home' ),- re_path( r'^api/', include('hi.simulator.services.hass.api.urls' )),+ path( 'api/', include('hi.simulator.services.hass.api.urls' )),]diff --git a/src/hi/simulator/services/homebox/api/urls.py b/src/hi/simulator/services/homebox/api/urls.pyindex 953174e5..df1dbde4 100644--- a/src/hi/simulator/services/homebox/api/urls.py+++ b/src/hi/simulator/services/homebox/api/urls.py@@ -1,16 +1,17 @@+from django.urls import pathfrom django.urls import re_pathfrom . import viewsurlpatterns = [- re_path( r'^v1/users/login$',- views.LoginView.as_view(),- name = 'homebox_api_login' ),+ path( 'v1/users/login',+ views.LoginView.as_view(),+ name = 'homebox_api_login' ),- re_path( r'^v1/items$',- views.AllItemsView.as_view(),- name = 'homebox_api_items' ),+ path( 'v1/items',+ views.AllItemsView.as_view(),+ name = 'homebox_api_items' ),re_path( r'^v1/items/(?P<item_id>[\w\-]+)$',views.ItemDetailView.as_view(),diff --git a/src/hi/simulator/services/homebox/urls.py b/src/hi/simulator/services/homebox/urls.pyindex 54c7f1ca..52525969 100644--- a/src/hi/simulator/services/homebox/urls.py+++ b/src/hi/simulator/services/homebox/urls.py@@ -1,12 +1,13 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^$',- views.HomeView.as_view(),- name = 'homebox_home' ),+ path( '',+ views.HomeView.as_view(),+ name = 'homebox_home' ),- re_path( r'^api/', include('hi.simulator.services.homebox.api.urls' )),+ path( 'api/', include('hi.simulator.services.homebox.api.urls' )),]diff --git a/src/hi/simulator/services/zoneminder/api/urls.py b/src/hi/simulator/services/zoneminder/api/urls.pyindex d34a45f0..cc3d39b9 100644--- a/src/hi/simulator/services/zoneminder/api/urls.py+++ b/src/hi/simulator/services/zoneminder/api/urls.py@@ -1,34 +1,34 @@-from django.urls import re_path+from django.urls import pathfrom . import viewsurlpatterns = [- re_path( r'^host/login\.json$',- views.HostLoginView.as_view(),- name = 'zm_api_host_login' ),+ path( 'host/login.json',+ views.HostLoginView.as_view(),+ name = 'zm_api_host_login' ),- re_path( r'^host/getVersion\.json$',- views.HostVersionView.as_view(),- name = 'zm_api_host_version' ),+ path( 'host/getVersion.json',+ views.HostVersionView.as_view(),+ name = 'zm_api_host_version' ),- re_path( r'^monitors\.json$',- views.MonitorsView.as_view(),- name = 'zm_api_monitors' ),+ path( 'monitors.json',+ views.MonitorsView.as_view(),+ name = 'zm_api_monitors' ),- re_path( r'^monitors/(?P<monitor_id>\d+)\.json$',- views.MonitorsView.as_view(),- name = 'zm_api_monitors_set' ),+ path( 'monitors/<int:monitor_id>.json',+ views.MonitorsView.as_view(),+ name = 'zm_api_monitors_set' ),- re_path( r'^states\.json$',- views.StatesView.as_view(),- name = 'zm_api_states' ),+ path( 'states.json',+ views.StatesView.as_view(),+ name = 'zm_api_states' ),- re_path( r'^states/change/(?P<run_state>.+)\.json$',- views.StatesChangeView.as_view(),- name = 'zm_api_states_change' ),+ path( 'states/change/<path:run_state>.json',+ views.StatesChangeView.as_view(),+ name = 'zm_api_states_change' ),- re_path( r'^events/index/(?P<filter>.+)\.json$',- views.EventsIndexView.as_view(),- name = 'zm_api_events_index' ),+ path( 'events/index/<path:filter>.json',+ views.EventsIndexView.as_view(),+ name = 'zm_api_events_index' ),]diff --git a/src/hi/simulator/services/zoneminder/urls.py b/src/hi/simulator/services/zoneminder/urls.pyindex e01e5c52..171616ea 100644--- a/src/hi/simulator/services/zoneminder/urls.py+++ b/src/hi/simulator/services/zoneminder/urls.py@@ -1,23 +1,24 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^$',- views.HomeView.as_view(),- name = 'zoneminder_home' ),+ path( '',+ views.HomeView.as_view(),+ name = 'zoneminder_home' ),# Portal-level paths the HI integration requests for media:# event thumbnails go through index.php?view=image, and live /# event playback streams go through cgi-bin/nph-zms.- re_path( r'^index\.php$',- views.IndexPhpView.as_view(),- name = 'zoneminder_index_php' ),+ path( 'index.php',+ views.IndexPhpView.as_view(),+ name = 'zoneminder_index_php' ),- re_path( r'^cgi-bin/nph-zms$',- views.NphZmsView.as_view(),- name = 'zoneminder_nph_zms' ),+ path( 'cgi-bin/nph-zms',+ views.NphZmsView.as_view(),+ name = 'zoneminder_nph_zms' ),- re_path( r'^api/', include('hi.simulator.services.zoneminder.api.urls' )),+ path( 'api/', include('hi.simulator.services.zoneminder.api.urls' )),]diff --git a/src/hi/simulator/urls.py b/src/hi/simulator/urls.pyindex 8056cb72..be95bba0 100644--- a/src/hi/simulator/urls.py+++ b/src/hi/simulator/urls.py@@ -14,41 +14,41 @@ logger = logging.getLogger(__name__)urlpatterns = [path( 'admin/', admin.site.urls ),- re_path( r'^$',- views.HomeView.as_view(),- name = 'simulator_home' ),+ path( '',+ views.HomeView.as_view(),+ name = 'simulator_home' ),- re_path( r'^profile/create$',- views.ProfileCreateView.as_view(),- name = 'simulator_profile_create' ),+ path( 'profile/create',+ views.ProfileCreateView.as_view(),+ name = 'simulator_profile_create' ),- re_path( r'^profile/edit/(?P<profile_id>\d+)$',- views.ProfileEditView.as_view(),- name = 'simulator_profile_edit' ),+ path( 'profile/edit/<int:profile_id>',+ views.ProfileEditView.as_view(),+ name = 'simulator_profile_edit' ),- re_path( r'^profile/delete/(?P<profile_id>\d+)$',- views.ProfileDeleteView.as_view(),- name = 'simulator_profile_delete' ),+ path( 'profile/delete/<int:profile_id>',+ views.ProfileDeleteView.as_view(),+ name = 'simulator_profile_delete' ),- re_path( r'^profile/clone/(?P<profile_id>\d+)$',- views.ProfileCloneView.as_view(),- name = 'simulator_profile_clone' ),+ path( 'profile/clone/<int:profile_id>',+ views.ProfileCloneView.as_view(),+ name = 'simulator_profile_clone' ),- re_path( r'^profile/switch/(?P<profile_id>\d+)$',- views.ProfileSwitchView.as_view(),- name = 'simulator_profile_switch' ),+ path( 'profile/switch/<int:profile_id>',+ views.ProfileSwitchView.as_view(),+ name = 'simulator_profile_switch' ),re_path( r'^entity/add/(?P<simulator_id>[\w_\-\.\:]+)/(?P<class_id>[\w\.\_]+)$',views.SimEntityAddView.as_view(),name = 'simulator_entity_add' ),- re_path( r'^entity/edit/(?P<sim_entity_id>\d+)$',- views.SimEntityEditView.as_view(),- name = 'simulator_entity_edit' ),+ path( 'entity/edit/<int:sim_entity_id>',+ views.SimEntityEditView.as_view(),+ name = 'simulator_entity_edit' ),- re_path( r'^entity/delete/(?P<sim_entity_id>\d+)$',- views.SimEntityDeleteView.as_view(),- name = 'simulator_entity_delete' ),+ path( 'entity/delete/<int:sim_entity_id>',+ views.SimEntityDeleteView.as_view(),+ name = 'simulator_entity_delete' ),re_path( r'^entity/state/set/(?P<simulator_id>[\w_\-\.\:]+)/(?P<sim_entity_id>\d+)/(?P<sim_state_id>[\w\-]+)$',views.SimStateSetView.as_view(),@@ -58,9 +58,9 @@ urlpatterns = [views.SetSimulatorFaultModeView.as_view(),name = 'simulator_fault_mode_set' ),- re_path( r'^runtime/temperature-unit-override$',- views.TemperatureUnitOverrideSetView.as_view(),- name = 'simulator_temperature_unit_override_set' ),+ path( 'runtime/temperature-unit-override',+ views.TemperatureUnitOverrideSetView.as_view(),+ name = 'simulator_temperature_unit_override_set' ),]diff --git a/src/hi/testing/devtools/urls.py b/src/hi/testing/devtools/urls.pyindex 71c1913d..14ea3763 100644--- a/src/hi/testing/devtools/urls.py+++ b/src/hi/testing/devtools/urls.py@@ -1,6 +1,7 @@import importlibfrom django.apps import apps+from django.urls import pathfrom django.urls import include, re_pathfrom . import views@@ -20,9 +21,9 @@ def get_tests_devtools_urls():urlpatterns = [- re_path( r'^$',- views.DevtoolsHomeView.as_view(),- name='testing_devtools_home'),+ path( '',+ views.DevtoolsHomeView.as_view(),+ name='testing_devtools_home'),]urlpatterns += get_tests_devtools_urls()diff --git a/src/hi/testing/ui/urls.py b/src/hi/testing/ui/urls.pyindex 0b9d1b17..8a44b33e 100644--- a/src/hi/testing/ui/urls.py+++ b/src/hi/testing/ui/urls.py@@ -1,6 +1,7 @@import importlibfrom django.apps import apps+from django.urls import pathfrom django.urls import include, re_pathfrom . import views@@ -20,9 +21,9 @@ def get_tests_ui_urls():urlpatterns = [- re_path( r'^$',- views.TestingHomeView.as_view(),- name='testing_ui_home'),+ path( '',+ views.TestingHomeView.as_view(),+ name='testing_ui_home'),]urlpatterns += get_tests_ui_urls()diff --git a/src/hi/testing/urls.py b/src/hi/testing/urls.pyindex 7770f9a2..1b1bf665 100644--- a/src/hi/testing/urls.py+++ b/src/hi/testing/urls.py@@ -1,15 +1,16 @@-from django.urls import include, re_path+from django.urls import path+from django.urls import includefrom . import viewsurlpatterns = [- re_path( r'^$',- views.TestingHomeView.as_view(),- name='testing_home'),+ path( '',+ views.TestingHomeView.as_view(),+ name='testing_home'),- re_path( r'^ui/', include('hi.testing.ui.urls' )),- re_path( r'^devtools/', include('hi.testing.devtools.urls' )),+ path( 'ui/', include('hi.testing.ui.urls' )),+ path( 'devtools/', include('hi.testing.devtools.urls' )),]diff --git a/src/hi/urls.py b/src/hi/urls.pyindex 0f8a8e30..7af5cb8c 100644--- a/src/hi/urls.py+++ b/src/hi/urls.py@@ -11,53 +11,53 @@ urlpatterns = [# Favicons are tricky to get 100% right and some browsers will try# this no matter what.- re_path( r'^favicon.ico$',- RedirectView.as_view( url = staticfiles_storage.url('favicon.ico'),- permanent = False),- name="favicon"- ),+ path( 'favicon.ico',+ RedirectView.as_view( url = staticfiles_storage.url('favicon.ico'),+ permanent = False),+ name="favicon"+ ),re_path(r'^(?P<filename>(service-worker.js))$',views.home_javascript_files, name='home-javascript-files'),- re_path( r'^manifest.json$', views.ManifestView.as_view(), name='manifest' ),+ path( 'manifest.json', views.ManifestView.as_view(), name='manifest' ),path('admin/', admin.site.urls),- re_path( r'^$', views.HomeView.as_view(), name='home' ),- re_path( r'^index.html$', views.HomeView.as_view(), name='home_index' ),- re_path( r'^start$', views.StartView.as_view(), name='start' ),- re_path( r'^health$', views.HealthView.as_view(), name='health' ),+ path( '', views.HomeView.as_view(), name='home' ),+ path( 'index.html', views.HomeView.as_view(), name='home_index' ),+ path( 'start', views.StartView.as_view(), name='start' ),+ path( 'health', views.HealthView.as_view(), name='health' ),- re_path( r'^env/', include('hi.environment.urls' )),- re_path( r'^user/', include('hi.apps.user.urls' )),- re_path( r'^api/', include('hi.apps.api.urls' )),- re_path( r'^config/', include('hi.apps.config.urls' )),- re_path( r'^edit/', include('hi.apps.edit.urls' )),- re_path( r'^integration/', include('hi.integrations.urls' )),- re_path( r'^location/', include('hi.apps.location.urls' )),- re_path( r'^entity/', include('hi.apps.entity.urls' )),- re_path( r'^collection/', include('hi.apps.collection.urls' )),- re_path( r'^sense/', include('hi.apps.sense.urls' )),- re_path( r'^control/', include('hi.apps.control.urls' )),- re_path( r'^event/', include('hi.apps.event.urls' )),- re_path( r'^alert/', include('hi.apps.alert.urls' )),- re_path( r'^security/', include('hi.apps.security.urls' )),- re_path( r'^notify/', include('hi.apps.notify.urls' )),- re_path( r'^console/', include('hi.apps.console.urls' )),- re_path( r'^weather/', include('hi.apps.weather.urls' )),- re_path( r'^audio/', include('hi.apps.audio.urls' )),- re_path( r'^profiles/', include('hi.apps.profiles.urls' )),- re_path( r'^system/', include('hi.apps.system.urls' )),+ path( 'env/', include('hi.environment.urls' )),+ path( 'user/', include('hi.apps.user.urls' )),+ path( 'api/', include('hi.apps.api.urls' )),+ path( 'config/', include('hi.apps.config.urls' )),+ path( 'edit/', include('hi.apps.edit.urls' )),+ path( 'integration/', include('hi.integrations.urls' )),+ path( 'location/', include('hi.apps.location.urls' )),+ path( 'entity/', include('hi.apps.entity.urls' )),+ path( 'collection/', include('hi.apps.collection.urls' )),+ path( 'sense/', include('hi.apps.sense.urls' )),+ path( 'control/', include('hi.apps.control.urls' )),+ path( 'event/', include('hi.apps.event.urls' )),+ path( 'alert/', include('hi.apps.alert.urls' )),+ path( 'security/', include('hi.apps.security.urls' )),+ path( 'notify/', include('hi.apps.notify.urls' )),+ path( 'console/', include('hi.apps.console.urls' )),+ path( 'weather/', include('hi.apps.weather.urls' )),+ path( 'audio/', include('hi.apps.audio.urls' )),+ path( 'profiles/', include('hi.apps.profiles.urls' )),+ path( 'system/', include('hi.apps.system.urls' )),# Custom error pages- re_path( r'^400.html$', views.bad_request_response, name='bad_request' ),- re_path( r'^403.html$', views.not_authorized_response, name='not_authorized' ),- re_path( r'^404.html$', views.page_not_found_response, name='page_not_found' ),- re_path( r'^405.html$', views.method_not_allowed_response, name='method_not_allowed' ),- re_path( r'^500.html$', views.internal_error_response, name='internal_error' ),- re_path( r'^503.html$', views.transient_error_response, name='transient_error' ),+ path( '400.html', views.bad_request_response, name='bad_request' ),+ path( '403.html', views.not_authorized_response, name='not_authorized' ),+ path( '404.html', views.page_not_found_response, name='page_not_found' ),+ path( '405.html', views.method_not_allowed_response, name='method_not_allowed' ),+ path( '500.html', views.internal_error_response, name='internal_error' ),+ path( '503.html', views.transient_error_response, name='transient_error' ),]@@ -68,5 +68,5 @@ handler404 = 'hi.views.custom_404_handler'if settings.DEBUG:urlpatterns += [- re_path( r'^testing/', include('hi.testing.urls' )),+ path( 'testing/', include('hi.testing.urls' )),]diff --git a/src/hi/views.py b/src/hi/views.pyindex 5aae4401..4687f136 100644--- a/src/hi/views.py+++ b/src/hi/views.py@@ -37,7 +37,7 @@ def error_response( request : HttpRequest,if 'message' in context:context['error_message'] = context['message']- if force_json or ( request.META.get('HTTP_ACCEPT', '') == 'application/json' ):+ if force_json or ( request.headers.get('accept', '') == 'application/json' ):return HttpResponse( json.dumps( context ),content_type = "application/json",status = status_code )