diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-06-08 18:41:46 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-12 00:01:48 +0100 |
commit | 4a2a057130e877eae96d726bc86c6b9f48ed1ca3 (patch) | |
tree | 2cf8147a96e976333627cc52e7089b62e4748083 /bitbake/lib | |
parent | b1c91d06e0262e886154129fb1b6b4a12e3fc5fe (diff) | |
download | poky-4a2a057130e877eae96d726bc86c6b9f48ed1ca3.tar.gz |
bitbake: toastergui: remove xhr_projectedit and xhr_projectinfo URLs
This patch removes the xhr_projectedit and xhr_projectinfo URLs
in favour of REST calls to the Project page.
The project page takes now the POST requests to modify project
settings. All usages of removed URLs are now changed to point to the
project page, using the json format.
The interface call specs have not modified.
(Bitbake rev: 6ad3078bd2be1a8cda99040acaa9bb81d77f0013)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/toaster/contrib/tts/urllist.py | 3 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/base.js | 3 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 8 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/projectapp.js | 73 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/templates/base.html | 3 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/templates/project.html | 2 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/tests.py | 1 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/urls.py | 2 | ||||
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 110 |
9 files changed, 108 insertions, 97 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/urllist.py b/bitbake/lib/toaster/contrib/tts/urllist.py index a7d6d6ec4e..433ac9fe85 100644 --- a/bitbake/lib/toaster/contrib/tts/urllist.py +++ b/bitbake/lib/toaster/contrib/tts/urllist.py | |||
@@ -40,10 +40,7 @@ URLS = [ | |||
40 | 'toastergui/project/1/importlayer', | 40 | 'toastergui/project/1/importlayer', |
41 | 'toastergui/project/1/targets/', | 41 | 'toastergui/project/1/targets/', |
42 | 'toastergui/project/1/machines/', | 42 | 'toastergui/project/1/machines/', |
43 | 'toastergui/xhr_build/', | ||
44 | 'toastergui/xhr_projectbuild/1/', | 43 | 'toastergui/xhr_projectbuild/1/', |
45 | 'toastergui/xhr_projectinfo/', | ||
46 | 'toastergui/xhr_projectedit/1', | ||
47 | 'toastergui/xhr_configvaredit/1', | 44 | 'toastergui/xhr_configvaredit/1', |
48 | 'toastergui/xhr_datatypeahead/1', | 45 | 'toastergui/xhr_datatypeahead/1', |
49 | 'toastergui/xhr_importlayer/', | 46 | 'toastergui/xhr_importlayer/', |
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 9424b6c328..9c8d01ef5a 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js | |||
@@ -29,7 +29,7 @@ function basePageInit (ctx) { | |||
29 | if (libtoaster.ctx.projectId == undefined) | 29 | if (libtoaster.ctx.projectId == undefined) |
30 | return; | 30 | return; |
31 | 31 | ||
32 | libtoaster.getProjectInfo(ctx.projectInfoUrl, libtoaster.ctx.projectId, | 32 | libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, |
33 | function(data){ | 33 | function(data){ |
34 | if (data.machine.name == undefined || data.layers.length == 0) { | 34 | if (data.machine.name == undefined || data.layers.length == 0) { |
35 | /* we can't build anything with out a machine and some layers */ | 35 | /* we can't build anything with out a machine and some layers */ |
@@ -102,7 +102,6 @@ function basePageInit (ctx) { | |||
102 | /* TBD: do we override even if we already have a context project ?? */ | 102 | /* TBD: do we override even if we already have a context project ?? */ |
103 | /* TODO: replace global library context with references to the "selected" project */ | 103 | /* TODO: replace global library context with references to the "selected" project */ |
104 | libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl; | 104 | libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl; |
105 | libtoaster.ctx.xhrProjectEditUrl = selectedProject.xhrProjectEditUrl; | ||
106 | libtoaster.ctx.projectName = selectedProject.name; | 105 | libtoaster.ctx.projectName = selectedProject.name; |
107 | libtoaster.ctx.projectId = selectedProject.id; | 106 | libtoaster.ctx.projectId = selectedProject.id; |
108 | 107 | ||
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 72fb0a93f5..87910299a5 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
@@ -120,11 +120,11 @@ var libtoaster = (function (){ | |||
120 | } | 120 | } |
121 | 121 | ||
122 | /* Get a project's configuration info */ | 122 | /* Get a project's configuration info */ |
123 | function _getProjectInfo(url, projectId, onsuccess, onfail){ | 123 | function _getProjectInfo(url, onsuccess, onfail){ |
124 | $.ajax({ | 124 | $.ajax({ |
125 | type: "POST", | 125 | type: "GET", |
126 | data : { format: "json" }, | ||
126 | url: url, | 127 | url: url, |
127 | data: { project_id : projectId }, | ||
128 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | 128 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, |
129 | success: function (_data) { | 129 | success: function (_data) { |
130 | if (_data.error !== "ok") { | 130 | if (_data.error !== "ok") { |
@@ -150,7 +150,7 @@ var libtoaster = (function (){ | |||
150 | function _editCurrentProject(data, onSuccess, onFail){ | 150 | function _editCurrentProject(data, onSuccess, onFail){ |
151 | $.ajax({ | 151 | $.ajax({ |
152 | type: "POST", | 152 | type: "POST", |
153 | url: libtoaster.ctx.xhrProjectEditUrl, | 153 | url: libtoaster.ctx.projectPageUrl + "?format=json", |
154 | data: data, | 154 | data: data, |
155 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | 155 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, |
156 | success: function (data) { | 156 | success: function (data) { |
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index a3309c76af..36c942fa29 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js | |||
@@ -156,6 +156,62 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
156 | * Retrieves text suggestions for text-edit drop down autocomplete boxes | 156 | * Retrieves text suggestions for text-edit drop down autocomplete boxes |
157 | */ | 157 | */ |
158 | 158 | ||
159 | $scope.getLayersAutocompleteSuggestions = function(currentValue) { | ||
160 | var deffered = $q.defer(); | ||
161 | |||
162 | $http({method:"GET", url: $scope.urls.layers, params : { search: currentValue, format: "json" }}) | ||
163 | .success(function (_data) { | ||
164 | if (_data.error != "ok") { | ||
165 | console.warn("error on data", _data.error); | ||
166 | deffered.reject(_data.error); | ||
167 | } | ||
168 | deffered.resolve(_data.rows); | ||
169 | }); | ||
170 | |||
171 | return deffered.promise; | ||
172 | } | ||
173 | |||
174 | $scope.filterProjectLayerIds = function () { | ||
175 | return $scope.layers.map(function (e) { return e.id; }); | ||
176 | } | ||
177 | |||
178 | $scope.getMachinesAutocompleteSuggestions = function(currentValue) { | ||
179 | var deffered = $q.defer(); | ||
180 | |||
181 | $http({method:"GET", url: $scope.urls.machines, params : { search: currentValue, format: "json" }}) | ||
182 | .success(function (_data) { | ||
183 | if (_data.error != "ok") { | ||
184 | console.warn("error on data", _data.error); | ||
185 | deffered.reject(_data.error); | ||
186 | } | ||
187 | deffered.resolve(_data.rows); | ||
188 | }); | ||
189 | |||
190 | return deffered.promise; | ||
191 | } | ||
192 | |||
193 | $scope.getRecipesAutocompleteSuggestions = function(currentValue) { | ||
194 | var deffered = $q.defer(); | ||
195 | |||
196 | $http({method:"GET", url: $scope.urls.targets, params : { search: currentValue, format: "json" }}) | ||
197 | .success(function (_data) { | ||
198 | if (_data.error != "ok") { | ||
199 | console.warn("error on data", _data.error); | ||
200 | deffered.reject(_data.error); | ||
201 | } | ||
202 | deffered.resolve(_data.rows); | ||
203 | }); | ||
204 | return deffered.promise; | ||
205 | } | ||
206 | |||
207 | $scope.values = function() { | ||
208 | var deffered = $q.defer(); | ||
209 | |||
210 | deffered.resolve(["mama", "tata"]); | ||
211 | |||
212 | return deffered.promise; | ||
213 | }; | ||
214 | |||
159 | $scope.getAutocompleteSuggestions = function(type, currentValue) { | 215 | $scope.getAutocompleteSuggestions = function(type, currentValue) { |
160 | var deffered = $q.defer(); | 216 | var deffered = $q.defer(); |
161 | 217 | ||
@@ -421,7 +477,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
421 | 477 | ||
422 | 478 | ||
423 | $scope.onLayerSelect = function (item) { | 479 | $scope.onLayerSelect = function (item) { |
424 | $scope.layerAddId = item.id; | 480 | $scope.layerToAdd = item; |
425 | }; | 481 | }; |
426 | 482 | ||
427 | $scope.machineSelect = function (machineName) { | 483 | $scope.machineSelect = function (machineName) { |
@@ -443,14 +499,9 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
443 | }; | 499 | }; |
444 | 500 | ||
445 | 501 | ||
446 | $scope.layerAddById = function (id) { | ||
447 | $scope.layerAddId = id; | ||
448 | $scope.layerAdd(); | ||
449 | }; | ||
450 | |||
451 | $scope.layerAdd = function() { | 502 | $scope.layerAdd = function() { |
452 | 503 | ||
453 | $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "layerdeps", value: $scope.layerAddId }}) | 504 | $http({method:"GET", url: $scope.layerToAdd.layerdict.layerdetailurl, params : {}}) |
454 | .success(function (_data) { | 505 | .success(function (_data) { |
455 | if (_data.error != "ok") { | 506 | if (_data.error != "ok") { |
456 | console.warn(_data.error); | 507 | console.warn(_data.error); |
@@ -493,7 +544,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
493 | }); | 544 | }); |
494 | 545 | ||
495 | modalInstance.result.then(function (selectedArray) { | 546 | modalInstance.result.then(function (selectedArray) { |
496 | selectedArray.push($scope.layerAddId); | 547 | selectedArray.push($scope.layerToAdd.layerversion.id); |
497 | console.warn("TRC6: selected", selectedArray); | 548 | console.warn("TRC6: selected", selectedArray); |
498 | 549 | ||
499 | $scope._makeXHRCall({ | 550 | $scope._makeXHRCall({ |
@@ -512,7 +563,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
512 | $scope._makeXHRCall({ | 563 | $scope._makeXHRCall({ |
513 | method: "POST", url: $scope.urls.xhr_edit, | 564 | method: "POST", url: $scope.urls.xhr_edit, |
514 | data: { | 565 | data: { |
515 | layerAdd: $scope.layerAddId, | 566 | layerAdd: $scope.layerToAdd.layerversion.id, |
516 | } | 567 | } |
517 | }).then(function () { | 568 | }).then(function () { |
518 | $scope.layerAddName = undefined; | 569 | $scope.layerAddName = undefined; |
@@ -768,10 +819,8 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
768 | 819 | ||
769 | 820 | ||
770 | _cmdExecuteWithParam("/layeradd=", function (layer) { | 821 | _cmdExecuteWithParam("/layeradd=", function (layer) { |
771 | angular.forEach(layer.split(","), function (l) { | 822 | $scope.layerToAdd = layer; |
772 | $scope.layerAddId = l; | ||
773 | $scope.layerAdd(); | 823 | $scope.layerAdd(); |
774 | }); | ||
775 | }); | 824 | }); |
776 | }; | 825 | }; |
777 | 826 | ||
diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index e10dc11673..5d51bc3c95 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html | |||
@@ -34,13 +34,11 @@ | |||
34 | projectsUrl : "{% url 'all-projects' %}", | 34 | projectsUrl : "{% url 'all-projects' %}", |
35 | {% if project.id %} | 35 | {% if project.id %} |
36 | xhrProjectDataTypeaheadUrl : "{% url 'xhr_datatypeahead' project.id %}", | 36 | xhrProjectDataTypeaheadUrl : "{% url 'xhr_datatypeahead' project.id %}", |
37 | xhrProjectEditUrl : "{% url 'xhr_projectedit' project.id %}", | ||
38 | projectPageUrl : "{% url 'project' project.id %}", | 37 | projectPageUrl : "{% url 'project' project.id %}", |
39 | projectName : "{{project.name}}", | 38 | projectName : "{{project.name}}", |
40 | projectId : {{project.id}}, | 39 | projectId : {{project.id}}, |
41 | {% else %} | 40 | {% else %} |
42 | xhrProjectDataTypeaheadUrl : undefined, | 41 | xhrProjectDataTypeaheadUrl : undefined, |
43 | xhrProjectEditUrl : undefined, | ||
44 | projectPageUrl : undefined, | 42 | projectPageUrl : undefined, |
45 | projectName : undefined, | 43 | projectName : undefined, |
46 | projectId : undefined, | 44 | projectId : undefined, |
@@ -53,7 +51,6 @@ | |||
53 | $(document).ready(function () { | 51 | $(document).ready(function () { |
54 | /* Vars needed for base.js */ | 52 | /* Vars needed for base.js */ |
55 | var ctx = {}; | 53 | var ctx = {}; |
56 | ctx.projectInfoUrl = "{% url 'xhr_projectinfo' %}"; | ||
57 | ctx.numProjects = {{projects|length}}; | 54 | ctx.numProjects = {{projects|length}}; |
58 | ctx.currentUrl = "{{request.path|escapejs}}"; | 55 | ctx.currentUrl = "{{request.path|escapejs}}"; |
59 | 56 | ||
diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html index 933da4f7da..e598631304 100644 --- a/bitbake/lib/toaster/toastergui/templates/project.html +++ b/bitbake/lib/toaster/toastergui/templates/project.html | |||
@@ -430,7 +430,7 @@ angular.element(document).ready(function() { | |||
430 | scope = angular.element("#main").scope(); | 430 | scope = angular.element("#main").scope(); |
431 | scope.urls = {}; | 431 | scope.urls = {}; |
432 | scope.urls.xhr_build = "{% url 'xhr_projectbuild' project.id %}"; | 432 | scope.urls.xhr_build = "{% url 'xhr_projectbuild' project.id %}"; |
433 | scope.urls.xhr_edit = "{% url 'xhr_projectedit' project.id %}"; | 433 | scope.urls.xhr_edit = "{% url 'project' project.id %}?format=json"; |
434 | scope.urls.xhr_datatypeahead = "{% url 'xhr_datatypeahead' project.id %}"; | 434 | scope.urls.xhr_datatypeahead = "{% url 'xhr_datatypeahead' project.id %}"; |
435 | scope.urls.layers = "{% url 'all-layers' project.id %}"; | 435 | scope.urls.layers = "{% url 'all-layers' project.id %}"; |
436 | scope.urls.targets = "{% url 'all-targets' project.id %}"; | 436 | scope.urls.targets = "{% url 'all-targets' project.id %}"; |
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 0f10020940..c92c5feeb5 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py | |||
@@ -40,7 +40,6 @@ class AllProjectsViewTestCase(ProvisionedProjectTestCase): | |||
40 | self.assertTrue("id" in data["list"][0]) | 40 | self.assertTrue("id" in data["list"][0]) |
41 | self.assertTrue("xhrProjectDataTypeaheadUrl" in data["list"][0]) | 41 | self.assertTrue("xhrProjectDataTypeaheadUrl" in data["list"][0]) |
42 | self.assertTrue("projectPageUrl" in data["list"][0]) | 42 | self.assertTrue("projectPageUrl" in data["list"][0]) |
43 | self.assertTrue("xhrProjectEditUrl" in data["list"][0]) | ||
44 | self.assertTrue("projectBuildUrl" in data["list"][0]) | 43 | self.assertTrue("projectBuildUrl" in data["list"][0]) |
45 | 44 | ||
46 | class ProvisionedLayersProjectTestCase(ProvisionedProjectTestCase): | 45 | class ProvisionedLayersProjectTestCase(ProvisionedProjectTestCase): |
diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py index e10e0bb159..d527be0017 100644 --- a/bitbake/lib/toaster/toastergui/urls.py +++ b/bitbake/lib/toaster/toastergui/urls.py | |||
@@ -122,8 +122,6 @@ urlpatterns = patterns('toastergui.views', | |||
122 | name=tables.LayerMachinesTable.__name__.lower()), | 122 | name=tables.LayerMachinesTable.__name__.lower()), |
123 | 123 | ||
124 | url(r'^xhr_projectbuild/(?P<pid>\d+)$', 'xhr_projectbuild', name='xhr_projectbuild'), | 124 | url(r'^xhr_projectbuild/(?P<pid>\d+)$', 'xhr_projectbuild', name='xhr_projectbuild'), |
125 | url(r'^xhr_projectinfo/$', 'xhr_projectinfo', name='xhr_projectinfo'), | ||
126 | url(r'^xhr_projectedit/(?P<pid>\d+)$', 'xhr_projectedit', name='xhr_projectedit'), | ||
127 | url(r'^xhr_configvaredit/(?P<pid>\d+)$', 'xhr_configvaredit', name='xhr_configvaredit'), | 125 | url(r'^xhr_configvaredit/(?P<pid>\d+)$', 'xhr_configvaredit', name='xhr_configvaredit'), |
128 | 126 | ||
129 | url(r'^xhr_datatypeahead/(?P<pid>\d+)$', 'xhr_datatypeahead', name='xhr_datatypeahead'), | 127 | url(r'^xhr_datatypeahead/(?P<pid>\d+)$', 'xhr_datatypeahead', name='xhr_datatypeahead'), |
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 678e356e0d..91c4fa2543 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2210,6 +2210,45 @@ if toastermain.settings.MANAGED: | |||
2210 | except User.DoesNotExist: | 2210 | except User.DoesNotExist: |
2211 | puser = None | 2211 | puser = None |
2212 | 2212 | ||
2213 | # execute POST requests | ||
2214 | if request.method == "POST": | ||
2215 | # add layers | ||
2216 | if 'layerAdd' in request.POST: | ||
2217 | for lc in Layer_Version.objects.filter(pk__in=request.POST['layerAdd'].split(",")): | ||
2218 | ProjectLayer.objects.get_or_create(project = prj, layercommit = lc) | ||
2219 | |||
2220 | # remove layers | ||
2221 | if 'layerDel' in request.POST: | ||
2222 | for t in request.POST['layerDel'].strip().split(" "): | ||
2223 | pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete() | ||
2224 | |||
2225 | if 'projectName' in request.POST: | ||
2226 | prj.name = request.POST['projectName'] | ||
2227 | prj.save(); | ||
2228 | |||
2229 | if 'projectVersion' in request.POST: | ||
2230 | prj.release = Release.objects.get(pk = request.POST['projectVersion']) | ||
2231 | # we need to change the bitbake version | ||
2232 | prj.bitbake_version = prj.release.bitbake_version | ||
2233 | prj.save() | ||
2234 | # we need to change the layers | ||
2235 | for i in prj.projectlayer_set.all(): | ||
2236 | # find and add a similarly-named layer on the new branch | ||
2237 | try: | ||
2238 | lv = prj.compatible_layerversions(layer_name = i.layercommit.layer.name)[0] | ||
2239 | ProjectLayer.objects.get_or_create(project = prj, layercommit = lv) | ||
2240 | except IndexError: | ||
2241 | pass | ||
2242 | finally: | ||
2243 | # get rid of the old entry | ||
2244 | i.delete() | ||
2245 | |||
2246 | if 'machineName' in request.POST: | ||
2247 | machinevar = prj.projectvariable_set.get(name="MACHINE") | ||
2248 | machinevar.value=request.POST['machineName'] | ||
2249 | machinevar.save() | ||
2250 | |||
2251 | |||
2213 | # we use implicit knowledge of the current user's project to filter layer information, e.g. | 2252 | # we use implicit knowledge of the current user's project to filter layer information, e.g. |
2214 | pid = prj.id | 2253 | pid = prj.id |
2215 | 2254 | ||
@@ -2241,10 +2280,12 @@ if toastermain.settings.MANAGED: | |||
2241 | "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}}, | 2280 | "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}}, |
2242 | prj.projectlayer_set.all().order_by("id")), | 2281 | prj.projectlayer_set.all().order_by("id")), |
2243 | "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()), | 2282 | "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()), |
2283 | "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), | ||
2244 | "freqtargets": freqtargets[:5], | 2284 | "freqtargets": freqtargets[:5], |
2245 | "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()), | 2285 | "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()), |
2246 | "project_html": 1, | 2286 | "project_html": 1, |
2247 | } | 2287 | } |
2288 | |||
2248 | try: | 2289 | try: |
2249 | context["machine"] = {"name": prj.projectvariable_set.get(name="MACHINE").value} | 2290 | context["machine"] = {"name": prj.projectvariable_set.get(name="MACHINE").value} |
2250 | except ProjectVariable.DoesNotExist: | 2291 | except ProjectVariable.DoesNotExist: |
@@ -2300,66 +2341,6 @@ if toastermain.settings.MANAGED: | |||
2300 | except Exception as e: | 2341 | except Exception as e: |
2301 | return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json") | 2342 | return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json") |
2302 | 2343 | ||
2303 | # This is a wraper for xhr_projectedit which allows for a project id | ||
2304 | # which only becomes known client side | ||
2305 | def xhr_projectinfo(request): | ||
2306 | if request.POST.has_key("project_id") == False: | ||
2307 | raise BadParameterException("invalid project id") | ||
2308 | |||
2309 | return xhr_projectedit(request, request.POST['project_id']) | ||
2310 | |||
2311 | def xhr_projectedit(request, pid): | ||
2312 | try: | ||
2313 | prj = Project.objects.get(id = pid) | ||
2314 | # add layers | ||
2315 | if 'layerAdd' in request.POST: | ||
2316 | for lc in Layer_Version.objects.filter(pk__in=request.POST['layerAdd'].split(",")): | ||
2317 | ProjectLayer.objects.get_or_create(project = prj, layercommit = lc) | ||
2318 | |||
2319 | # remove layers | ||
2320 | if 'layerDel' in request.POST: | ||
2321 | for t in request.POST['layerDel'].strip().split(" "): | ||
2322 | pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete() | ||
2323 | |||
2324 | if 'projectName' in request.POST: | ||
2325 | prj.name = request.POST['projectName'] | ||
2326 | prj.save(); | ||
2327 | |||
2328 | if 'projectVersion' in request.POST: | ||
2329 | prj.release = Release.objects.get(pk = request.POST['projectVersion']) | ||
2330 | # we need to change the bitbake version | ||
2331 | prj.bitbake_version = prj.release.bitbake_version | ||
2332 | prj.save() | ||
2333 | # we need to change the layers | ||
2334 | for i in prj.projectlayer_set.all(): | ||
2335 | # find and add a similarly-named layer on the new branch | ||
2336 | try: | ||
2337 | lv = prj.compatible_layerversions(layer_name = i.layercommit.layer.name)[0] | ||
2338 | ProjectLayer.objects.get_or_create(project = prj, layercommit = lv) | ||
2339 | except IndexError: | ||
2340 | pass | ||
2341 | finally: | ||
2342 | # get rid of the old entry | ||
2343 | i.delete() | ||
2344 | |||
2345 | if 'machineName' in request.POST: | ||
2346 | machinevar = prj.projectvariable_set.get(name="MACHINE") | ||
2347 | machinevar.value=request.POST['machineName'] | ||
2348 | machinevar.save() | ||
2349 | |||
2350 | # return all project settings | ||
2351 | return HttpResponse(jsonfilter( { | ||
2352 | "error": "ok", | ||
2353 | "layers" : map(lambda x: {"id": x.layercommit.pk, "orderid" : x.pk, "name" : x.layercommit.layer.name, "giturl" : x.layercommit.layer.vcs_url, "url": x.layercommit.layer.layer_index_url, "layerdetailurl": reverse("layerdetails", args=(prj.id, x.layercommit.pk,)), "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name}}, prj.projectlayer_set.all().select_related("layer").order_by("id")), | ||
2354 | "builds" : _project_recent_build_list(prj), | ||
2355 | "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), | ||
2356 | "machine": {"name": prj.projectvariable_set.get(name="MACHINE").value}, | ||
2357 | "prj": {"name": prj.name, "release": { "id": prj.release.pk, "name": prj.release.name, "desc": prj.release.description}}, | ||
2358 | }), content_type = "application/json") | ||
2359 | |||
2360 | except Exception as e: | ||
2361 | return HttpResponse(jsonfilter({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json") | ||
2362 | |||
2363 | 2344 | ||
2364 | from django.views.decorators.csrf import csrf_exempt | 2345 | from django.views.decorators.csrf import csrf_exempt |
2365 | @csrf_exempt | 2346 | @csrf_exempt |
@@ -2929,7 +2910,6 @@ if toastermain.settings.MANAGED: | |||
2929 | p.id = p.pk | 2910 | p.id = p.pk |
2930 | p.xhrProjectDataTypeaheadUrl = reverse('xhr_datatypeahead', args=(p.id,)) | 2911 | p.xhrProjectDataTypeaheadUrl = reverse('xhr_datatypeahead', args=(p.id,)) |
2931 | p.projectPageUrl = reverse('project', args=(p.id,)) | 2912 | p.projectPageUrl = reverse('project', args=(p.id,)) |
2932 | p.xhrProjectEditUrl = reverse('xhr_projectedit', args=(p.id,)) | ||
2933 | p.projectBuildUrl = reverse('xhr_projectbuild', args=(p.id,)) | 2913 | p.projectBuildUrl = reverse('xhr_projectbuild', args=(p.id,)) |
2934 | 2914 | ||
2935 | # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) | 2915 | # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) |
@@ -3234,14 +3214,6 @@ else: | |||
3234 | return {} | 3214 | return {} |
3235 | 3215 | ||
3236 | @_template_renderer('landing_not_managed.html') | 3216 | @_template_renderer('landing_not_managed.html') |
3237 | def xhr_projectinfo(request): | ||
3238 | return {} | ||
3239 | |||
3240 | @_template_renderer('landing_not_managed.html') | ||
3241 | def xhr_projectedit(request, pid): | ||
3242 | return {} | ||
3243 | |||
3244 | @_template_renderer('landing_not_managed.html') | ||
3245 | def xhr_datatypeahead(request): | 3217 | def xhr_datatypeahead(request): |
3246 | return {} | 3218 | return {} |
3247 | 3219 | ||