1
1
from django import VERSION
2
+ from django import forms
2
3
from django .conf .urls import url
4
+ from django .utils .safestring import mark_safe
3
5
from django .utils .translation import ugettext_lazy as _
4
6
5
7
from six import string_types
@@ -28,9 +30,17 @@ class AdminRowActionsMixin(object):
28
30
29
31
@property
30
32
def media (self ):
31
- media = super (AdminRowActionsMixin , self ).media
32
- media .add_js (['js/jquery.dropdown.min.js' ])
33
- media .add_css ({'all' : ['css/jquery.dropdown.min.css' ]})
33
+ css = super (AdminRowActionsMixin , self ).media ._css
34
+ css ['all' ] = css .get ('all' , [])
35
+ css ['all' ].extend (["css/jquery.dropdown.min.css" ])
36
+
37
+ js = super (AdminRowActionsMixin , self ).media ._js
38
+ js .extend (["js/jquery.dropdown.min.js" ,])
39
+
40
+ media = forms .Media (
41
+ css = css , js = js
42
+ )
43
+
34
44
return media
35
45
36
46
def get_list_display (self , request ):
@@ -64,7 +74,7 @@ def to_dict(tool_name):
64
74
65
75
elif isinstance (tool , dict ): # A parameter dict
66
76
tool ['enabled' ] = tool .get ('enabled' , True )
67
- if 'action' in tool : # If 'action' is specified then use our generic url in preference to 'url' value
77
+ if 'action' in tool : # If 'action' is specified then use our generic url in preference to 'url' value
68
78
if isinstance (tool ['action' ], tuple ):
69
79
self ._named_row_actions [tool ['action' ][0 ]] = tool ['action' ][1 ]
70
80
tool ['url' ] = '{}rowactions/{}/' .format (url_prefix , tool ['action' ][0 ])
@@ -83,11 +93,15 @@ def _row_actions(self, obj):
83
93
items = items ,
84
94
request = getattr (self , '_request' )
85
95
).render ()
86
-
87
- return html
96
+ if VERSION < (1 , 9 ):
97
+ return html
98
+ else :
99
+ return mark_safe (html )
88
100
return ''
89
101
_row_actions .short_description = ''
90
- _row_actions .allow_tags = True
102
+
103
+ if VERSION < (1 , 9 ):
104
+ _row_actions .allow_tags = True
91
105
92
106
def get_tool_urls (self ):
93
107
0 commit comments