From 5b8a62dad7d429034c52290385da570c5ca1da34 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Fri, 14 Nov 2014 18:12:20 +0000 Subject: bitbake: toaster: libtoaster: Add getProjectInfo utility function Add a utility function to return a specified project's info/config This re-uses the existing server code path for the project edit except that it allows any project id to be used as a parameter (Bitbake rev: af42ea5f006c5cf55a7c57a42904f412639d261f) Signed-off-by: Michael Wood Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- .../lib/toaster/toastergui/static/js/libtoaster.js | 22 ++++++++++++++++++++++ bitbake/lib/toaster/toastergui/urls.py | 1 + bitbake/lib/toaster/toastergui/views.py | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/toaster/toastergui') diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index b899b8de4d..4983ef6f6d 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js @@ -88,10 +88,32 @@ var libtoaster = (function (){ } }); }; + /* Get a project's configuration info */ + function _getProjectInfo(url, projectId, onsuccess, onfail){ + $.ajax({ + type: "POST", + url: url, + data: { project_id : projectId }, + headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, + success: function (_data) { + if (_data.error != "ok") { + console.log(_data.error); + } else { + if (onsuccess != undefined) onsuccess(_data); + } + }, + error: function (_data) { + console.log(_data); + if (onfail) onfail(data); + } + }); + }; + return { reload_params : reload_params, startABuild : _startABuild, makeTypeahead : _makeTypeahead, + getProjectInfo: _getProjectInfo, } })(); diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py index f43bb64653..bae7103091 100644 --- a/bitbake/lib/toaster/toastergui/urls.py +++ b/bitbake/lib/toaster/toastergui/urls.py @@ -85,6 +85,7 @@ urlpatterns = patterns('toastergui.views', url(r'^project/(?P\d+)/builds$', 'projectbuilds', name='projectbuilds'), url(r'^xhr_projectbuild/(?P\d+)/$', 'xhr_projectbuild', name='xhr_projectbuild'), + url(r'^xhr_projectinfo/$', 'xhr_projectinfo', name='xhr_projectinfo'), url(r'^xhr_projectedit/(?P\d+)/$', 'xhr_projectedit', name='xhr_projectedit'), url(r'^xhr_datatypeahead/$', 'xhr_datatypeahead', name='xhr_datatypeahead'), diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 1b4bb9ff69..9f214bb677 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -2057,8 +2057,11 @@ if toastermain.settings.MANAGED: except Exception as e: return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json") + def xhr_projectinfo(request): + if request.POST.has_key("project_id") == False: + raise BadParameterException("invalid project id") - + return xhr_projectedit(request, request.POST['project_id']) def xhr_projectedit(request, pid): try: -- cgit v1.2.3-54-g00ecf