Skip to content

Comments

Introduce an option to negate the filtering on a queryset#21

Closed
megies wants to merge 1 commit intomasterfrom
inverted_filtering
Closed

Introduce an option to negate the filtering on a queryset#21
megies wants to merge 1 commit intomasterfrom
inverted_filtering

Conversation

@megies
Copy link
Collaborator

@megies megies commented May 3, 2016

i.e. make a filter that doesn't return events that do match all given criteria, but rather returns events, that do not match the combination of given criteria.

Otherwise with the current implementation through QuerySet.extra(..., where=..) it is impossible to define a retrieve permission for a combination of two criteria (i.e. when user "does not have permission" to exclude events that match the given combination of criteria, e.g. exclude events below magnitude Y at site X).

Should be done differently if Jane is migrated to Django 1.9, see #20.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@megies megies May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw that one, but I didn't know how to use it together with how the json field is set up right now, as I didn't have a template in the source code.
Since these more canonically looking operators aren't used right now (and the rather hacky extra() instead), I figured that maybe they can't be used with the json field right now..

Sorry.. no real django knowledge here, so mostly orienting on the current source..

i.e. make the filter not return events that match all given criteria,
but rather return events, that do not match the combination of given
criteria.

otherwise it is impossible to define a retrieve permission for a
combination of two criteria (i.e. when user "does not have permission"
to exclude events that match the given combination of criteria, e.g.
exclude events at site X and below magnitude Y)
@megies megies force-pushed the inverted_filtering branch from f569921 to 97934d0 Compare May 9, 2016 14:47
@megies
Copy link
Collaborator Author

megies commented Sep 28, 2017

This most likely won't be necessary anymore now, since migration to Django 1.9 with the possibility to do queries like queryset.filter/exclude(json__...=.., json__...=...)

@megies megies closed this Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants