[bitbake-devel] [PATCH 05/11] toaster: libtoaster: Add getProjectInfo utility function

Alex DAMIAN alexandru.damian at intel.com
Thu Nov 20 16:27:21 UTC 2014


From: Michael Wood <michael.g.wood at intel.com>

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

Signed-off-by: Michael Wood <michael.g.wood at intel.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
 lib/toaster/toastergui/static/js/libtoaster.js | 22 ++++++++++++++++++++++
 lib/toaster/toastergui/urls.py                 |  1 +
 lib/toaster/toastergui/views.py                |  5 ++++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js
index b899b8d..4983ef6 100644
--- a/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/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/lib/toaster/toastergui/urls.py b/lib/toaster/toastergui/urls.py
index f43bb64..bae7103 100644
--- a/lib/toaster/toastergui/urls.py
+++ b/lib/toaster/toastergui/urls.py
@@ -85,6 +85,7 @@ urlpatterns = patterns('toastergui.views',
         url(r'^project/(?P<pid>\d+)/builds$', 'projectbuilds', name='projectbuilds'),
 
         url(r'^xhr_projectbuild/(?P<pid>\d+)/$', 'xhr_projectbuild', name='xhr_projectbuild'),
+        url(r'^xhr_projectinfo/$', 'xhr_projectinfo', name='xhr_projectinfo'),
         url(r'^xhr_projectedit/(?P<pid>\d+)/$', 'xhr_projectedit', name='xhr_projectedit'),
 
         url(r'^xhr_datatypeahead/$', 'xhr_datatypeahead', name='xhr_datatypeahead'),
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 1b4bb9f..9f214bb 100755
--- a/lib/toaster/toastergui/views.py
+++ b/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:
-- 
1.9.1




More information about the bitbake-devel mailing list