texastribune/django-object-actions — pull request #14 by jamesshannon (2014-03-29 05:51:02+00:00)
Title: Added get_object_actions() function

Can use context['original'] (the model) to return dynamic objectactions. Note that this won't affect the url setup -- modeladmin.objectactions should include all possible actions.

My use case is that models should have different actions depending on the status. For example, "publish" should only be available if article is "draft".

Unfortunately, it doesn't look like the object is available before get_urls() is called, so the actions can't be set at that point; all possible actions must be defined.

I realized there'd be issues in modifying the self.objectactions directly (it looks like i could do it in get_readonly_fields() as it's called before render_change_form), but then I'm modifying the class's array, which caused problems.