5
5
from django .views .generic .detail import SingleObjectMixin
6
6
7
7
8
- class DjObjectTools (object ):
8
+ class DjangoObjectActions (object ):
9
9
"""
10
10
mixin to add object-tools just like you would add admin actions.
11
11
@@ -15,26 +15,26 @@ class DjObjectTools(object):
15
15
16
16
def toolfunc(self, request, obj)
17
17
18
- They are exposed by putting them in a djobjecttools attribute in your
18
+ They are exposed by putting them in a `objectactions` attribute in your
19
19
modeladmin like:
20
20
21
- class MyModelAdmin(DjObjectTools , admin.ModelAdmin):
21
+ class MyModelAdmin(DjangoObjectActions , admin.ModelAdmin):
22
22
def toolfunc(self, request, obj):
23
23
pass
24
24
toolfunc.short_description = "does nothing"
25
25
26
- djobjecttools = ('toolfunc',)
26
+ objectactions = ('toolfunc',)
27
27
28
28
Why this functionality isn't baked into contrib.admin is beyond me.
29
29
30
30
TODO: get `form` and `change` so you can write tools that can also save
31
31
TODO: handle getting returned an HttpResponse
32
32
"""
33
- change_form_template = "djobjecttools /change_form.html"
33
+ change_form_template = "django_object_actions /change_form.html"
34
34
35
35
def get_tool_urls (self ):
36
36
tools = {}
37
- for tool in self .djobjecttools :
37
+ for tool in self .objectactions :
38
38
tools [tool ] = getattr (self , tool )
39
39
my_urls = patterns ('' ,
40
40
(r'^(?P<pk>\d+)/tools/(?P<tool>\w+)/$' , self .admin_site .admin_view (
@@ -43,14 +43,14 @@ def get_tool_urls(self):
43
43
return my_urls
44
44
45
45
def get_urls (self ):
46
- urls = super (DjObjectTools , self ).get_urls ()
46
+ urls = super (DjangoObjectActions , self ).get_urls ()
47
47
return self .get_tool_urls () + urls
48
48
49
49
def render_change_form (self , request , context , ** kwargs ):
50
- context ['djtools ' ] = [(x ,
50
+ context ['objectactions ' ] = [(x ,
51
51
getattr (getattr (self , x ), 'short_description' , '' ))
52
- for x in self .djobjecttools ]
53
- return super (DjObjectTools , self ).render_change_form (request ,
52
+ for x in self .objectactions ]
53
+ return super (DjangoObjectActions , self ).render_change_form (request ,
54
54
context , ** kwargs )
55
55
56
56
0 commit comments