diff options
| -rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 2e3b822797..95df60e472 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
| @@ -45,6 +45,7 @@ from django.utils import formats | |||
| 45 | from toastergui.templatetags.projecttags import json as jsonfilter | 45 | from toastergui.templatetags.projecttags import json as jsonfilter |
| 46 | import json | 46 | import json |
| 47 | from os.path import dirname | 47 | from os.path import dirname |
| 48 | from functools import wraps | ||
| 48 | import itertools | 49 | import itertools |
| 49 | 50 | ||
| 50 | import magic | 51 | import magic |
| @@ -2314,6 +2315,18 @@ if True: | |||
| 2314 | 2315 | ||
| 2315 | return context | 2316 | return context |
| 2316 | 2317 | ||
| 2318 | def xhr_response(fun): | ||
| 2319 | """ | ||
| 2320 | Decorator for REST methods. | ||
| 2321 | calls jsonfilter on the returned dictionary and returns result | ||
| 2322 | as HttpResponse object of content_type application/json | ||
| 2323 | """ | ||
| 2324 | @wraps(fun) | ||
| 2325 | def wrapper(*args, **kwds): | ||
| 2326 | return HttpResponse(jsonfilter(fun(*args, **kwds)), | ||
| 2327 | content_type="application/json") | ||
| 2328 | return wrapper | ||
| 2329 | |||
| 2317 | def jsunittests(request): | 2330 | def jsunittests(request): |
| 2318 | """ Provides a page for the js unit tests """ | 2331 | """ Provides a page for the js unit tests """ |
| 2319 | bbv = BitbakeVersion.objects.filter(branch="master").first() | 2332 | bbv = BitbakeVersion.objects.filter(branch="master").first() |
