Skip to content

Commit

Permalink
Fix get filter layer saved with anonymous user. (#654)
Browse files Browse the repository at this point in the history
Co-authored-by: wlorenzetti <[email protected]>
  • Loading branch information
wlorenzetti and wlorenzetti committed Nov 15, 2023
1 parent b7c8443 commit a2d91ef
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions g3w-admin/qdjango/api/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,14 @@ def to_representation(self, instance):

# Get FilterToken layer filters saved:
# Build a layer_filters dict to pass FilterLayerSaved instance to LayerSerializer
# Only if user is not anonymous
layer_filters = {}
filters = FilterLayerSaved.objects.filter(user=self.request.user, layer__project=instance)
for f in filters:
if f.layer.qgs_layer_id not in layer_filters:
layer_filters[f.layer.qgs_layer_id] = []
layer_filters[f.layer.qgs_layer_id].append(f)
if not self.request.user.is_anonymous:
filters = FilterLayerSaved.objects.filter(user=self.request.user, layer__project=instance)
for f in filters:
if f.layer.qgs_layer_id not in layer_filters:
layer_filters[f.layer.qgs_layer_id] = []
layer_filters[f.layer.qgs_layer_id].append(f)


def readLeaf(layer, container):
Expand Down

0 comments on commit a2d91ef

Please sign in to comment.