diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-06-30 15:58:36 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-07-14 14:10:03 +0100 |
commit | e7fa0c325d59811c272b7dad671225fea8c29609 (patch) | |
tree | 599e0c75cef2d37fc1573d7ff91b9f3ce7b6f180 /bitbake/lib/toaster/orm/models.py | |
parent | d19b784c1a2a4380c63947690ae6f7fa393c1ebc (diff) | |
download | poky-e7fa0c325d59811c272b7dad671225fea8c29609.tar.gz |
bitbake: toaster: new project page implementation
We add the logic to create a new project. This page
also serves as user registration and silent login
for users.
Once the project is added, the main project page is displayed.
(Bitbake rev: 8855daebe55917c4f5855413d02ae1f3f7f76571)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index b67afe139c..f4064296bc 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -23,10 +23,48 @@ from django.db import models | |||
23 | from django.db.models import F | 23 | from django.db.models import F |
24 | from django.utils.encoding import python_2_unicode_compatible | 24 | from django.utils.encoding import python_2_unicode_compatible |
25 | 25 | ||
26 | class ProjectManager(models.Manager): | ||
27 | def create_project(self, name, branch, short_description): | ||
28 | prj = self.model(name = name, branch = branch, short_description = short_description) | ||
29 | prj.save() | ||
30 | |||
31 | # create default variables | ||
32 | ProjectVariable.objects.create(project = prj, name = "MACHINE", value = "qemux86") | ||
33 | ProjectVariable.objects.create(project = prj, name = "DISTRO", value = "poky") | ||
34 | |||
35 | # create default layers | ||
36 | ProjectLayer.objects.create(project = prj, | ||
37 | name = "meta", | ||
38 | giturl = "git://git.yoctoproject.org/poky", | ||
39 | commit = branch, | ||
40 | treepath = "meta") | ||
41 | |||
42 | ProjectLayer.objects.create(project = prj, | ||
43 | name = "meta-yocto", | ||
44 | giturl = "git://git.yoctoproject.org/poky", | ||
45 | commit = branch, | ||
46 | treepath = "meta-yocto") | ||
47 | |||
48 | return prj | ||
49 | |||
50 | def create(self, *args, **kwargs): | ||
51 | raise Exception("Invalid call to Project.objects.create. Use Project.objects.create_project() to create a project") | ||
52 | |||
53 | def get_or_create(self, *args, **kwargs): | ||
54 | raise Exception("Invalid call to Project.objects.get_or_create. Use Project.objects.create_project() to create a project") | ||
55 | |||
26 | class Project(models.Model): | 56 | class Project(models.Model): |
27 | name = models.CharField(max_length=100) | 57 | name = models.CharField(max_length=100) |
58 | branch = models.CharField(max_length=50) | ||
59 | short_description = models.CharField(max_length=50, blank=True) | ||
28 | created = models.DateTimeField(auto_now_add = True) | 60 | created = models.DateTimeField(auto_now_add = True) |
29 | updated = models.DateTimeField(auto_now = True) | 61 | updated = models.DateTimeField(auto_now = True) |
62 | # This is a horrible hack; since Toaster has no "User" model available when | ||
63 | # running in interactive mode, we can't reference the field here directly | ||
64 | # Instead, we keep a possible null reference to the User id, as not to force | ||
65 | # hard links to possibly missing models | ||
66 | user_id = models.IntegerField(null = True) | ||
67 | objects = ProjectManager() | ||
30 | 68 | ||
31 | class Build(models.Model): | 69 | class Build(models.Model): |
32 | SUCCEEDED = 0 | 70 | SUCCEEDED = 0 |