Introduce an option to negate the filtering on a queryset#21
Introduce an option to negate the filtering on a queryset#21
Conversation
src/jane/documents/models.py
Outdated
There was a problem hiding this comment.
Use the Q and ~ operator instead of plain SQL, see also:
http://stackoverflow.com/questions/687295/how-do-i-do-a-not-equal-in-django-queryset-filtering
There was a problem hiding this comment.
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)
|
This most likely won't be necessary anymore now, since migration to Django 1.9 with the possibility to do queries like |
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.