diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-06-30 15:58:36 +0100 |
---|---|---|
committer | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-07-09 17:33:29 +0100 |
commit | 8855daebe55917c4f5855413d02ae1f3f7f76571 (patch) | |
tree | 30f6c9d0e167e000d572956599f2a6d669550e36 /lib/toaster/orm/models.py | |
parent | 5f33d1a240faa49bd8259a48eb15ef57a6b4ce55 (diff) | |
download | bitbake-contrib-8855daebe55917c4f5855413d02ae1f3f7f76571.tar.gz |
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.
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib/toaster/orm/models.py')
-rw-r--r-- | lib/toaster/orm/models.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py index b67afe139..f4064296b 100644 --- a/lib/toaster/orm/models.py +++ b/lib/toaster/orm/models.py @@ -23,10 +23,48 @@ from django.db import models from django.db.models import F from django.utils.encoding import python_2_unicode_compatible +class ProjectManager(models.Manager): + def create_project(self, name, branch, short_description): + prj = self.model(name = name, branch = branch, short_description = short_description) + prj.save() + + # create default variables + ProjectVariable.objects.create(project = prj, name = "MACHINE", value = "qemux86") + ProjectVariable.objects.create(project = prj, name = "DISTRO", value = "poky") + + # create default layers + ProjectLayer.objects.create(project = prj, + name = "meta", + giturl = "git://git.yoctoproject.org/poky", + commit = branch, + treepath = "meta") + + ProjectLayer.objects.create(project = prj, + name = "meta-yocto", + giturl = "git://git.yoctoproject.org/poky", + commit = branch, + treepath = "meta-yocto") + + return prj + + def create(self, *args, **kwargs): + raise Exception("Invalid call to Project.objects.create. Use Project.objects.create_project() to create a project") + + def get_or_create(self, *args, **kwargs): + raise Exception("Invalid call to Project.objects.get_or_create. Use Project.objects.create_project() to create a project") + class Project(models.Model): name = models.CharField(max_length=100) + branch = models.CharField(max_length=50) + short_description = models.CharField(max_length=50, blank=True) created = models.DateTimeField(auto_now_add = True) updated = models.DateTimeField(auto_now = True) + # This is a horrible hack; since Toaster has no "User" model available when + # running in interactive mode, we can't reference the field here directly + # Instead, we keep a possible null reference to the User id, as not to force + # hard links to possibly missing models + user_id = models.IntegerField(null = True) + objects = ProjectManager() class Build(models.Model): SUCCEEDED = 0 |