Skip to content

Commit

Permalink
Merge pull request #3748 from GeotrekCE/bug_missing_update_rights_inf…
Browse files Browse the repository at this point in the history
…rastructure

🐛 [BUG] Fix missing update rights for Infrastructure Condition and Infrastructure Type with no structure
  • Loading branch information
babastienne authored Sep 27, 2023
2 parents 6122804 + e277beb commit a4c5e4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------------
Expand Down
5 changes: 3 additions & 2 deletions geotrek/infrastructure/admin.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit a4c5e4b

Please sign in to comment.