@@ -59,9 +59,18 @@ def to_dict(tool_name):
59
59
##################
60
60
61
61
def get_object_actions (self , request , context , ** kwargs ):
62
+ """Override this to customize what actions get sent."""
62
63
return self .objectactions
63
64
64
65
def get_djoa_button_attrs (self , tool ):
66
+ """
67
+ Get the HTML attributes associated with a tool.
68
+
69
+ There are some standard attributes (class and title) that the template
70
+ will always want. Any number of additional attributes can be specified
71
+ and passed on. This is kinda awkward and due for a refactor for
72
+ readability.
73
+ """
65
74
attrs = getattr (tool , 'attrs' , {})
66
75
# href is not allowed to be set. should an exception be raised instead?
67
76
if 'href' in attrs :
@@ -101,7 +110,7 @@ def get(self, request, **kwargs):
101
110
try :
102
111
ret = self .tools [kwargs ['tool' ]](request , obj )
103
112
except KeyError :
104
- raise Http404
113
+ raise Http404 ( u'Tool does not exist' )
105
114
if isinstance (ret , HttpResponse ):
106
115
return ret
107
116
back = request .path .rsplit ('/' , 3 )[0 ] + '/'
@@ -117,7 +126,13 @@ def message_user(self, request, message):
117
126
118
127
119
128
class QuerySetIsh (QuerySet ):
120
- """Takes an instance and mimics it coming from a QuerySet."""
129
+ """
130
+ Takes an instance and mimics it coming from a QuerySet.
131
+
132
+ This is a hack to support the `takes_instance_or_queryset` decorator so
133
+ that you can re-use functions written for standard Django admin actions and
134
+ use them for Object Tools too.
135
+ """
121
136
def __init__ (self , instance = None , * args , ** kwargs ):
122
137
try :
123
138
model = instance ._meta .model
@@ -141,7 +156,7 @@ def get(self, *args, **kwargs):
141
156
142
157
143
158
def takes_instance_or_queryset (func ):
144
- """Decorator that makes standard actions compatible."""
159
+ """Decorator that makes standard Django admin actions compatible."""
145
160
@wraps (func )
146
161
def decorated_function (self , request , queryset ):
147
162
# func follows the prototype documented at:
0 commit comments