From 626c95844b453444042731bf35b8803ea8a7954f Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Wed, 27 Sep 2023 12:13:54 +0200 Subject: [PATCH] :bug: [BUG] Fix missing update rights for Infrastructure Condition and Infrastructure Type with no structure --- docs/changelog.rst | 4 ++++ geotrek/infrastructure/admin.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index a47e94bed0..503c2e4bdd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,10 @@ CHANGELOG - Upgrade `django-mapentity` to 8.6.1. New authentication system for screamshotter and convertit by token instead of IP detection. - Refactor code for accessibility attachments +**Bug fixes** + +- Fix missing update rights for Infrastructure Condition and Infrastructure Type with no structure in Admin Site (#3747) + 2.100.2 (2023-09-12) ------------------------ diff --git a/geotrek/infrastructure/admin.py b/geotrek/infrastructure/admin.py index 44b98ac5d0..a4fc74c7ed 100644 --- a/geotrek/infrastructure/admin.py +++ b/geotrek/infrastructure/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.db.models import Q from geotrek.common.mixins.actions import MergeActionMixin from geotrek.infrastructure.models import InfrastructureAccessMean, InfrastructureMaintenanceDifficultyLevel, InfrastructureType, InfrastructureCondition, InfrastructureUsageDifficultyLevel @@ -15,7 +16,7 @@ def get_queryset(self, request): """ qs = super().get_queryset(request) if not request.user.has_perm('authent.can_bypass_structure'): - qs = qs.filter(structure=request.user.profile.structure) + qs = qs.filter(Q(structure=request.user.profile.structure) | Q(structure=None)) return qs def formfield_for_foreignkey(self, db_field, request, **kwargs): @@ -51,7 +52,7 @@ def get_queryset(self, request): """ qs = super().get_queryset(request) if not request.user.has_perm('authent.can_bypass_structure'): - qs = qs.filter(structure=request.user.profile.structure) + qs = qs.filter(Q(structure=request.user.profile.structure) | Q(structure=None)) return qs def formfield_for_foreignkey(self, db_field, request, **kwargs):