Permission constraint on Journal Entries #11794
Replies: 3 comments 1 reply
-
I basically want the same, but for everything instead of only
And giving me the same error:
Maybe it's possible to add this reverse relation for the |
Beta Was this translation helpful? Give feedback.
-
Did anyone find a way around this yet? I realized that I have a need to allow users to see Journal entries for the objects in their tenant. |
Beta Was this translation helpful? Give feedback.
-
I have the same problem, but would like to allow users to only create Journal entries for Devices and VMs, I feel like this should be possible with a constraint on assigned_object_type, but I get the same error as all of you do. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Currently I'm looking into using Netbox for a multi-tenant project, where tenants should be able to see "their" racks and edit their devices. I found the Journal to be useful when logging things that we notice about racks, e.g. "Rack contains packaging material left there after installation. Needs removal". I want these entries to be visible to the tenant of the rack, but not to other tenants.
The
JournalEntry
model of Netbox contains the fieldsassigned_object_type. assigned_object_id, assigned_object, created_by, kind, comments
. None of which are related to the Tenancy models, exceptassigned_object_type
.However, when defining a persmission constraint like so:
{"assigned_object_type": "Rack", "assigned_object__tenant_id": "4"}
, I get the following error message:Invalid filter for <class 'extras.models.models.JournalEntry'>: Field 'assigned_object' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.
The relevant line is found here:
https://github.com/netbox-community/netbox/blob/develop/netbox/extras/models/models.py#L528
I understand why the error message is shown and why it doesn't work. Is there any (other) way to achieve what I described above?
Greetings,
Chris
Beta Was this translation helpful? Give feedback.
All reactions