Skip to content

Commit

Permalink
docs: more tweaks as I read code
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Jan 13, 2016
1 parent 0efc304 commit 936fe08
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions django_object_actions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class BaseDjangoObjectActions(object):
Write the names of the callable attributes (methods) of the model admin
that can be used as tools.
tools_view_name : str
The name of the Django Object Actions admin view. Populated by
`get_tool_urls`.
The name of the Django Object Actions admin view, including the 'admin'
namespace. Populated by `get_tool_urls`.
"""
objectactions = []
tools_view_name = None
Expand All @@ -50,7 +50,7 @@ def get_tool_urls(self):
return [
# supports pks that are numbers or uuids
url(r'^(?P<pk>[0-9a-f\-]+)/tools/(?P<tool>\w+)/$',
self.admin_site.admin_view(
self.admin_site.admin_view( # checks permissions
ModelToolsView.as_view(
model=self.model,
tools=tools,
Expand Down Expand Up @@ -94,7 +94,19 @@ def to_dict(tool_name):
################

def get_object_actions(self, request, context, **kwargs):
"""Override this to customize what actions get sent."""
"""
Override this method to customize what actions get sent.
For example, to restrict actions to superusers, you could do:
class ChoiceAdmin(DjangoObjectActions, admin.ModelAdmin):
def get_object_actions(self, request, context, **kwargs):
if request.user.is_superuser:
return super(ChoiceAdmin, self).get_object_actions(
request, context, **kwargs
)
return []
"""
return self.objectactions

def get_djoa_button_attrs(self, tool):
Expand Down

0 comments on commit 936fe08

Please sign in to comment.