@@ -33,6 +33,12 @@ class Action(models.Model):
33
33
pass
34
34
35
35
36
+ def decorate (fn ):
37
+ def wrapper (self , request , * args , ** kwargs ):
38
+ return fn (self , request , * args , ** kwargs )
39
+ return wrapper
40
+
41
+
36
42
class ActionViewSet (GenericViewSet ):
37
43
queryset = Action .objects .all ()
38
44
@@ -62,6 +68,11 @@ def custom_detail_action(self, request, *args, **kwargs):
62
68
def unresolvable_detail_action (self , request , * args , ** kwargs ):
63
69
raise NotImplementedError
64
70
71
+ @action (detail = False )
72
+ @decorate
73
+ def wrapped (self , request , * args , ** kwargs ):
74
+ raise NotImplementedError
75
+
65
76
66
77
class ActionNamesViewSet (GenericViewSet ):
67
78
@@ -157,6 +168,7 @@ def test_extra_actions(self):
157
168
'detail_action' ,
158
169
'list_action' ,
159
170
'unresolvable_detail_action' ,
171
+ 'wrapped' ,
160
172
]
161
173
162
174
self .assertEqual (actual , expected )
@@ -172,6 +184,7 @@ def test_list_view(self):
172
184
expected = OrderedDict ([
173
185
('Custom list action' , 'http://testserver/api/actions/custom_list_action/' ),
174
186
('List action' , 'http://testserver/api/actions/list_action/' ),
187
+ ('Wrapped' , 'http://testserver/api/actions/wrapped/' ),
175
188
])
176
189
177
190
self .assertEqual (view .get_extra_action_url_map (), expected )
0 commit comments