Skip to content

Commit

Permalink
Fix caveats in viewset
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Apr 11, 2024
1 parent 7f7057e commit 8d942da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion isimip_data/metadata/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def get_caveats_versions(self, obj):
if self.context.get('request').GET.get('caveats'):
user = self.context['request'].user
versions = Dataset.objects.using('metadata').filter(path=obj.path).exclude(id=obj.id)
queryset = Caveat.objects.filter(datasets__overlap=[version.id for version in versions]).public(user)
queryset = Caveat.objects.exclude(datasets__contains=[obj.id]) \
.filter(datasets__overlap=[version.id for version in versions]).public(user)
serializer = DatasetCaveatSerializer(queryset, many=True)
return serializer.data

Expand Down
4 changes: 2 additions & 2 deletions isimip_data/metadata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def dataset(request, pk=None, path=None):

if versions:
caveats_datasets = list(versions.exclude(id=obj.id).values_list('id', flat=True))
caveats_versions = Caveat.objects.exclude(id__in=[caveat.id for caveat in caveats]) \
caveats_versions = Caveat.objects.exclude(datasets__contains=[obj.id]) \
.filter(datasets__overlap=caveats_datasets)
else:
caveats_versions = None
Expand Down Expand Up @@ -104,7 +104,7 @@ def file(request, pk=None, path=None):

if versions:
caveats_datasets = list(versions.exclude(id=obj.id).values_list('dataset_id', flat=True))
caveats_versions = Caveat.objects.exclude(id__in=[caveat.id for caveat in caveats]) \
caveats_versions = Caveat.objects.exclude(datasets__contains=[obj.id]) \
.filter(datasets__overlap=caveats_datasets)
else:
caveats_versions = None
Expand Down

0 comments on commit 8d942da

Please sign in to comment.