1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

17 Commits

Author SHA1 Message Date
jeremystretch
12c138b341 Closes #9074: Enable referencing the current user when evaluating permission constraints 2022-07-01 13:34:10 -04:00
jeremystretch
c6dfdf10e5 Introduce qs_filter_from_constraints() for constructing object permission QS filters 2022-07-01 11:49:36 -04:00
seros1521
90257e9dee Fixes #8715: eliminates duplicates when used in many-to-many field constraints
When using permissions that use tags, a user may receive multiple permissions
of the same type if multiple tags are assigned to the device. This causes the
RestrictedQuerySet class to generate a query similar to this:

>>> dcim.models.Device.objects.filter(Q(tags__name='tag1')|Q(tags__name='tag2'))
<ConfigContextModelQuerySet [<Device: device1>, <Device: device1>]>

This query returns the same object twice if both tags are assigned to it. This
is due to the use of the django-taggit library. The library's documentation
describes this behavior as expected and suggests using an explicit distinct()
call in queries to avoid duplicates.

However, the use of DISTINCT in queries has a global side effect -
deduplication of responses, which may or may not be acceptable behavior
(depending on further use). Since it is not known how RestrictedQuerySet will
be used in the rest of the code, it was decided to dedupe using a subquery.
2022-03-04 14:37:05 +07:00
Jeremy Stretch
4ee8e473eb Move ObjectChange creation into signal receivers 2020-08-14 17:03:45 -04:00
Jeremy Stretch
4a516103a6 Extend ObjectPermission constraints to OR multiple JSON objects 2020-08-06 15:53:23 -04:00
Jeremy Stretch
cb36f9fdb3 Remove restriction enforcement from RestrictedQuerySet 2020-07-23 12:48:03 -04:00
Jeremy Stretch
9777f25b9f Set the default action to 'view' for restrict() 2020-06-26 11:57:07 -04:00
Jeremy Stretch
2d4694e72d Merge pull request #4770 from netbox-community/3703-limit-tag-creation
Closes #3703: Restrict tag creation
2020-06-17 12:28:04 -04:00
Jeremy Stretch
54ece346bc DummyQuerySet should be iterable to allow for serialization 2020-06-17 12:20:56 -04:00
Jeremy Stretch
ffb43a8534 Introduce unrestricted() method on RestrictedQuerySet 2020-06-16 12:20:21 -04:00
Jeremy Stretch
ce5fd7955f Catch and log evaluation of RestrictedQuerySet without calling restrict() 2020-06-16 10:39:15 -04:00
Jeremy Stretch
3a9512f086 Refine queryset restriction logic 2020-06-01 13:09:34 -04:00
Jeremy Stretch
3c334a0238 Update views to restrict all querysets 2020-06-01 11:43:49 -04:00
Jeremy Stretch
5574aaa8cb Tweak restrict() to accept only an action keyword 2020-06-01 10:45:49 -04:00
Jeremy Stretch
e23b2c4c4f Implement RestrictedQuerySet as a manager 2020-05-29 16:27:36 -04:00
Jeremy Stretch
5b6a6fb63e Move restrict_queryset() function to RestrictedQuerySet 2020-05-29 15:09:08 -04:00
Jeremy Stretch
ccb9f7bfe2 Rewrote ObjectChangeMiddleware to remove the curried handle_deleted_object() function 2019-10-22 15:10:49 -04:00