Conditions | 4 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | from __future__ import absolute_import |
||
13 | def jsonp(view): |
||
14 | if isinstance(view, types.FunctionType): |
||
15 | @require_GET |
||
16 | @wraps(view) |
||
17 | def jsonpfied_view(request, *args, **kwargs): |
||
18 | |||
19 | return get_jsonp_response(view(request, *args, **kwargs), callback=get_callback(request)) |
||
20 | return jsonpfied_view |
||
21 | |||
22 | elif issubclass(view, View): |
||
23 | class JSONPfiedCBV(view): |
||
24 | http_method_names = ['get'] # only GET method is allowed for JSONP |
||
25 | |||
26 | def get(self, request, *args, **kwargs): |
||
27 | return get_jsonp_response( |
||
28 | super(JSONPfiedCBV, self).get(request, *args, **kwargs), |
||
29 | callback=get_callback(request)) |
||
30 | |||
31 | return JSONPfiedCBV |
||
32 | else: |
||
33 | raise NotImplementedError('Only django CBVs and FBVs are supported') |
||
34 |