diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 6042a96ee4..ed22a4ebc1 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js @@ -121,14 +121,14 @@ function basePageInit(ctx) { }); function _checkProjectBuildable() { - if (selectedProject.projectId === undefined) { + if (selectedProject.projectId === undefined || selectedProject.projectIsDefault) { return; } libtoaster.getProjectInfo(selectedProject.projectPageUrl, function (data) { if (data.machine === null || data.machine.name === undefined || data.layers.length === 0) { - /* we can't build anything with out a machine and some layers */ + /* we can't build anything without a machine and some layers */ $("#new-build-button #targets-form").hide(); $("#new-build-button .alert").show(); } else { @@ -147,7 +147,7 @@ function basePageInit(ctx) { /* If we don't have a current project then present the set project * form. */ - if (selectedProject.projectId === undefined) { + if (selectedProject.projectId === undefined || selectedProject.projectIsDefault) { $('#change-project-form').show(); $('#project .icon-pencil').hide(); } diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html index 3f277909d7..c1d0693066 100644 --- a/bitbake/lib/toaster/toastergui/templates/base.html +++ b/bitbake/lib/toaster/toastergui/templates/base.html @@ -38,6 +38,7 @@ projectId : {{project.id}}, projectPageUrl : {% url 'project' project.id as purl %}{{purl|json}}, projectName : {{project.name|json}}, + projectIsDefault: {% if project.is_default %}true{% else %}false{% endif %}, recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}}, layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}}, machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as paturl%}{{paturl|json}}, @@ -48,7 +49,7 @@ projectId : undefined, projectPageUrl : undefined, projectName : undefined, - projectId : undefined, + projectIsDefault: false, {% endif %} }; @@ -122,52 +123,54 @@
New project
- - + {% endif %} diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index c4264a11a9..e2f2874539 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -1870,10 +1870,15 @@ def image_information_dir(request, build_id, target_id, packagefile_id): return redirect(builds) # the context processor that supplies data used across all the pages - +# a context processor which runs on every request; this provides the +# projects and non_cli_projects (i.e. projects created by the user) +# variables referred to in templates, which used to determine the +# visibility of UI elements like the "New build" button def managedcontextprocessor(request): + projects = Project.objects.all() ret = { - "projects": Project.objects.all(), + "projects": projects, + "non_cli_projects": projects.exclude(is_default=True), "DEBUG" : toastermain.settings.DEBUG, "CUSTOM_IMAGE" : toastermain.settings.CUSTOM_IMAGE, "TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH,