Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow DRYPermissionsField to return permissions for related objects #52

Open
jordanmkoncz opened this issue May 12, 2018 · 0 comments
Open

Comments

@jordanmkoncz
Copy link

jordanmkoncz commented May 12, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant