netbox/netbox
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
..
circuits Add description filter for ProviderNetwork, CircuitType, Circuit & CircuitTermination 2022-02-25 18:15:22 +01:00
dcim Closes #8736: Add PC and UPC fiber end faces for LC/SC/LSH port types 2022-03-01 11:43:00 -05:00
extras Merge pull request #8741 from djothi/develop 2022-02-25 13:18:40 -05:00
ipam Closes #8766: Add SCTP to service protocols list 2022-03-01 11:07:19 -05:00
media Tweak gitignore to include devicetype-images directory 2020-02-20 13:42:23 -05:00
netbox PRVB 2022-02-15 09:32:52 -05:00
project-static Fix navbar-toggler-icon visibility in dark mode 2022-02-25 11:23:14 -07:00
reports Restore reports directory 2018-08-07 13:47:36 -04:00
scripts Remove extraneous demo scripts 2019-09-23 09:21:38 -04:00
templates Closes #8762: Link to rack elevations list from site view 2022-03-01 11:32:17 -05:00
tenancy Add description filter for Tenant & ContactRole 2022-02-25 18:15:33 +01:00
users Add description filter for Token & ObjectPermission 2022-02-25 18:15:33 +01:00
utilities Fixes #8715: eliminates duplicates when used in many-to-many field constraints 2022-03-04 14:37:05 +07:00
virtualization Add description filter to VMInterface 2022-02-25 18:15:33 +01:00
wireless Add description filter to WirelessLAN & WirelessLink 2022-02-25 18:15:33 +01:00
generate_secret_key.py Fix how SECRET_KEY is generated 2021-01-24 21:20:55 +01:00
manage.py