I am trying, in vain, to create a simple Django template tag to show or hide the delete link next to the submitted comment on my site.
In short, I want to pass the comment object to the template tag, determine if the authorized user is currently allowed to delete the comment, and then show or not show the link.
Use in my template would be like this:
{% load access_tags %}
{% if_authorized comment %}
<a href="{% url delete_comment comment.id %}">Delete</a>
{% endif_authorized %}
Be sure that I will also check the relevant submission if the user has the right to delete the comment.
Does this tag type have a specific name? This will certainly help me in a google search if this happens. Thank you for your help!
UPDATE 1:
How my site works, two people can allow a comment to be deleted: 1) the creator of the comment and 2) the owner of the message in which the comment remained. Because of this, I need to determine for the comment if one of these conditions is present.
I don’t think that I can use something like the built-in Django authorization system, because this requires that the permissions are "set globally for each type of object, and not for a specific instance of the object."
In my case, the user "Bob" may have permission to delete the comment (if he wrote it or he is on the message he created), but he is also not allowed to delete it (if he looks at the comment to someone else).
UPDATE 2:
, , : " , token.split_contents(), ". , , , .
, , :
self.comment.resolve(context).user
.
self.comment.user