Modify `AND` and `OR` permission operands to have the ability to use custom messages
refs #6427
-
AND- If failed permission has a message, it will be returned. -
OR- If both permissions will be failed: a) if both permissions have messages - will be returned one message combined from two messages; b) if only one permission (from both failed) has a message - this message will be returned (I suppose this is better then return the default one). -
NOT- If failed permission has amessage_invertedattribute, it will be returned. (@iproha94 thanks for this suggestion).
@ozandogrultan Many thanks for your comments. I have updated this PR.
@samitnuk wrote
NOT - untouched here since in any case, we cannot use the message from "inverted" permission.
I think for this case, we should add the inverted_message property to the custom permission class, so
class MyCustomPermission(permissions.BasePermission):
message = _("you are not active")
inverted_message = _("you are active")
and use it for rest_framework/permissions.py:
class NOT:
def __init__(self, op1):
self.op1 = op1
self.message = getattr(self.op1, 'inverted_message', None)
but this is incorrect for double negative.
Hi, @iproha94. Thank you for your review. I will check your comments and make updates asap.
@ozandogrultan, @auvipy, @iproha94 please review the updated PR. Many thanks.
Is this being merged?
Any plans to to get this merged??
I am running into this issue currently. Is this in the roadmap to get merged?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Same issue here. I like the solution and would be happy to see this merged.
let see how it works on current CI
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.