mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
bitbake: toaster: Create default project with get_or_create* method
Rather than maintain data as part of the migrations (as was done for the default project previously), create the default (cli builds) project on demand as a by-product of getting it from the database. [YOCTO #8364] (Bitbake rev: 5fd8e90ab9b81d1bd0d301bc1c91228ecbbea74b) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
9de8dfa11a
commit
7a0c45e478
@@ -91,18 +91,25 @@ class ProjectManager(models.Manager):
|
||||
|
||||
return prj
|
||||
|
||||
def create(self, *args, **kwargs):
|
||||
raise Exception("Invalid call to Project.objects.create. Use Project.objects.create_project() to create a project")
|
||||
|
||||
# return single object with is_default = True
|
||||
def get_default_project(self):
|
||||
def get_or_create_default_project(self):
|
||||
projects = super(ProjectManager, self).filter(is_default = True)
|
||||
|
||||
if len(projects) > 1:
|
||||
raise Exception("Inconsistent project data: multiple " +
|
||||
"default projects (i.e. with is_default=True)")
|
||||
raise Exception('Inconsistent project data: multiple ' +
|
||||
'default projects (i.e. with is_default=True)')
|
||||
elif len(projects) < 1:
|
||||
raise Exception("Inconsistent project data: no default project found")
|
||||
return projects[0]
|
||||
options = {
|
||||
'name': 'Command line builds',
|
||||
'short_description': 'Project for builds started outside Toaster',
|
||||
'is_default': True
|
||||
}
|
||||
project = Project.objects.create(**options)
|
||||
project.save()
|
||||
|
||||
return project
|
||||
else:
|
||||
return projects[0]
|
||||
|
||||
class Project(models.Model):
|
||||
search_allowed_fields = ['name', 'short_description', 'release__name', 'release__branch_name']
|
||||
|
||||
Reference in New Issue
Block a user