11from django import VERSION
2+ from django import forms
23from django .conf .urls import url
4+ from django .utils .safestring import mark_safe
35from django .utils .translation import ugettext_lazy as _
46
57from six import string_types
@@ -28,9 +30,17 @@ class AdminRowActionsMixin(object):
2830
2931 @property
3032 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+
3444 return media
3545
3646 def get_list_display (self , request ):
@@ -64,7 +74,7 @@ def to_dict(tool_name):
6474
6575 elif isinstance (tool , dict ): # A parameter dict
6676 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
6878 if isinstance (tool ['action' ], tuple ):
6979 self ._named_row_actions [tool ['action' ][0 ]] = tool ['action' ][1 ]
7080 tool ['url' ] = '{}rowactions/{}/' .format (url_prefix , tool ['action' ][0 ])
@@ -83,11 +93,15 @@ def _row_actions(self, obj):
8393 items = items ,
8494 request = getattr (self , '_request' )
8595 ).render ()
86-
87- return html
96+ if VERSION < (1 , 9 ):
97+ return html
98+ else :
99+ return mark_safe (html )
88100 return ''
89101 _row_actions .short_description = ''
90- _row_actions .allow_tags = True
102+
103+ if VERSION < (1 , 9 ):
104+ _row_actions .allow_tags = True
91105
92106 def get_tool_urls (self ):
93107
0 commit comments