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

support for handling additional, non-descript, attribute properties t… #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion inline_actions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ def render_inline_actions(self, obj=None):
except AttributeError:
css_classes = ''

# Add per-object attribute support
attr_handler = getattr(
self, 'get_{}_attr'.format(action_name), None)
if callable(attr_handler):
attribute_properties = attr_handler(obj=obj)
else:
try:
attribute_properties = action_func.attribute_properties
except AttributeError:
attribute_properties = ''

# If the form is submitted, we have no information about the
# requested action.
# Hence we need all data to be encoded using the action name.
Expand All @@ -116,10 +127,11 @@ def render_inline_actions(self, obj=None):
str(obj.pk)
]
buttons.append(
'<input type="submit" name="{}" value="{}" class="{}">'.format(
'<input type="submit" name="{}" value="{}" class="{}" {}>'.format(
'_action__{}'.format('__'.join(action_data)),
description,
css_classes,
attribute_properties
)
)
return mark_safe('<div class="submit_row inline_actions">{}</div>'.format(
Expand Down