diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-07-31 15:09:10 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-01 11:26:11 +0100 |
commit | 9af7ce513ca4259029edf62fb06c4f8c59e274fc (patch) | |
tree | 0a520da1103536511dc76b4d2deefaf27a579ae5 /bitbake | |
parent | 7a589c0b206a999e892825a9f9afb290abe1ed1a (diff) | |
download | poky-9af7ce513ca4259029edf62fb06c4f8c59e274fc.tar.gz |
bitbake: toastergui: http api Add guard against incomplete change requests
If we get a request to the project change api which either contains the
current configuration (i.e no change) or empty configuration handle this
gracefully.
(Bitbake rev: cc6c606c07baadc849c3290b23c56ad4e719fba2)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 9e89714b9c..688a4c276f 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2160,12 +2160,12 @@ if True: | |||
2160 | # execute POST requests | 2160 | # execute POST requests |
2161 | if request.method == "POST": | 2161 | if request.method == "POST": |
2162 | # add layers | 2162 | # add layers |
2163 | if 'layerAdd' in request.POST: | 2163 | if 'layerAdd' in request.POST and len(request.POST['layerAdd']) > 0: |
2164 | for lc in Layer_Version.objects.filter(pk__in=[i for i in request.POST['layerAdd'].split(",") if len(i) > 0]): | 2164 | for lc in Layer_Version.objects.filter(pk__in=[i for i in request.POST['layerAdd'].split(",") if len(i) > 0]): |
2165 | ProjectLayer.objects.get_or_create(project = prj, layercommit = lc) | 2165 | ProjectLayer.objects.get_or_create(project = prj, layercommit = lc) |
2166 | 2166 | ||
2167 | # remove layers | 2167 | # remove layers |
2168 | if 'layerDel' in request.POST: | 2168 | if 'layerDel' in request.POST and len(request.POST['layerDel']) > 0: |
2169 | for t in request.POST['layerDel'].strip().split(" "): | 2169 | for t in request.POST['layerDel'].strip().split(" "): |
2170 | pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete() | 2170 | pt = ProjectLayer.objects.filter(project = prj, layercommit_id = int(t)).delete() |
2171 | 2171 | ||
@@ -2174,6 +2174,10 @@ if True: | |||
2174 | prj.save(); | 2174 | prj.save(); |
2175 | 2175 | ||
2176 | if 'projectVersion' in request.POST: | 2176 | if 'projectVersion' in request.POST: |
2177 | # If the release is the current project then return now | ||
2178 | if prj.release.pk == int(request.POST.get('projectVersion',-1)): | ||
2179 | return {} | ||
2180 | |||
2177 | prj.release = Release.objects.get(pk = request.POST['projectVersion']) | 2181 | prj.release = Release.objects.get(pk = request.POST['projectVersion']) |
2178 | # we need to change the bitbake version | 2182 | # we need to change the bitbake version |
2179 | prj.bitbake_version = prj.release.bitbake_version | 2183 | prj.bitbake_version = prj.release.bitbake_version |
@@ -2257,8 +2261,12 @@ if True: | |||
2257 | 2261 | ||
2258 | # returns layer versions that would be deleted on the new release__pk | 2262 | # returns layer versions that would be deleted on the new release__pk |
2259 | if request.GET.get('type', None) == "versionlayers": | 2263 | if request.GET.get('type', None) == "versionlayers": |
2264 | # If we're already on this project do nothing | ||
2265 | if prj.release.pk == int(request.GET.get('search', -1)): | ||
2266 | return HttpResponse(jsonfilter({"error": "ok", "rows": []}), content_type="application/json") | ||
2260 | 2267 | ||
2261 | retval = [] | 2268 | retval = [] |
2269 | |||
2262 | for i in prj.projectlayer_set.all(): | 2270 | for i in prj.projectlayer_set.all(): |
2263 | lv = prj.compatible_layerversions(release = Release.objects.get(pk=request.GET.get('search', None))).filter(layer__name = i.layercommit.layer.name) | 2271 | lv = prj.compatible_layerversions(release = Release.objects.get(pk=request.GET.get('search', None))).filter(layer__name = i.layercommit.layer.name) |
2264 | # there is no layer_version with the new release id, and the same name | 2272 | # there is no layer_version with the new release id, and the same name |