crccheck / django-object-actions

A Django app for easily adding object tools in the Django admin
https://pypi.org/project/django-object-actions/
Apache License 2.0
681 stars 82 forks source link

AttributeError: 'XAdmin' object has no attribute '20_char_trimmed_name' #156

Closed matthieudesprez closed 1 year ago

matthieudesprez commented 1 year ago

Hello,

I'm experiencing this issue for the first time with django-object-actions

I suspect that I've put an action name which is too long (26 chars) and it seems to be looking for a 20 chars trimmed version of it in the related ModelAdmin

Original name is

change_actions = ["force_documents_collection"]

relevant part of the stack trace

File ".../lib/python3.8/site-packages/django_object_actions/utils.py", line 155, in _get_tool_dict
    tool = getattr(self, tool_name)
AttributeError: 'XAdmin' object has no attribute 'force_documents_coll'

So I guess it's trimmed somewhere but I didn't get the time to look further into it, also I was looking in the documentation if there was a mention of any limitation in actions naming but couldn't find anything either.

matthieudesprez commented 1 year ago

Ok my bad, sorry for that, a current implementation of get_change_actions in our codebase is iterating over Django permissions to have a more fine grained list of actions.

And, as these permissions are formatted like f"actionexecute{name_of_action" it returns a list of

action.strip("action_execute")

so it's just a wrong usage of strip at cause here.

Thanks for your work btw.