dry-rest-permissions
dry-rest-permissions copied to clipboard
Allow DRYPermissionsField to return permissions for related objects
It would be useful if DRYPermissionsField
could return permission not only for the object itself, but also related objects. Currently, you can use additional_actions
to specify additional permissions to return, e.g. I have a model BookingAvailability
where I'm including some additional permissions:
permissions = DRYPermissionsField(
additional_actions=[
'make_available',
'make_busy',
]
)
It would be good if I could also do the following:
permissions = DRYPermissionsField(
additional_actions=[
'make_available',
'make_busy',
'booking.make_cancelled',
]
)
Where booking.make_cancelled
refers to the make_cancelled
permission of the related Booking
(BookingAvailability
has a ForeginKey
relationship to a Booking
).
This would be very similar to how other serializer fields (like DRF's CharField
) are able to use related objects, for example:
booking_title = serializers.CharField(source='booking.title')
Where booking_title
will be the title
of the related Booking
.