fix: add structures_autocomplete_assets url route and safely handle user_config in structures_index

This commit is contained in:
kdeterme 2026-08-21 12:17:31 +02:00
parent 4599537be3
commit c40bcb7f8f
2 changed files with 3 additions and 1 deletions

View file

@ -161,6 +161,7 @@ urlpatterns = [
path('structures/locations/<int:location_id>/', structures.structures_locations_detail, name='structures_locations_detail'),
path('structures/assets/', structures.structures_assets, name='structures_assets'),
path('structures/assets/geojson/', structures.structures_assets_geojson, name='structures_assets_geojson'),
path('structures/assets/autocomplete/', structures.structures_assets_autocomplete, name='structures_autocomplete_assets'),
path('structures/exceptional-transport/geojson/', structures.structures_exceptional_transport_geojson, name='structures_exceptional_transport_geojson'),
path('structures/structures/<int:structure_id>/edit-exceptional-transport/', structures.structures_edit_exceptional_transport, name='structures_edit_exceptional_transport'),
path('structures/<str:asset_model>/<int:asset_id>/', structures.structures_assets_detail, name='structures_assets_detail'),

View file

@ -61,9 +61,10 @@ def structures_index(request):
selected_locations_ids = draft_data.get('locations', [])
user_config, _ = UserConfig.objects.get_or_create(user=request.user)
thematic_choices_qs = (
UserThematics.objects
.filter(user_config=request.user.config, can_view_assets=True)
.filter(user_config=user_config, can_view_assets=True)
.select_related('thematic')
.order_by(f'thematic__{"name_nl" if lang == "nl" else "name_fr"}')
)