tinpan / integration /

import subprocess
from django.db import models
from django.conf import settings

class Project(models.Model):
    """A single project that will be tested continuously."""
    name = models.CharField(max_length=80)
    test_bed = models.CharField(max_length=500)
    command = models.CharField(max_length=500)
    slug = models.SlugField(unique=True)
    class Meta:
        ordering = ['name']
    def last_build(self):
            return self.buildrun_set.order_by('-start_time')[0]
        except IndexError:
            return None
    def run_build(self):
        subprocess.Popen(['./', self.slug], cwd=settings.BASE_DIR)
    def __unicode__(self):
        return u"%s" %
    def get_absolute_url(self):
        return ('project_detail', (), { 'slug': self.slug } )

class BuildRun(models.Model):
    """A model representing a single run of a build."""
    project = models.ForeignKey(Project)
    success = models.BooleanField(default=False)
    command = models.CharField(max_length=500)
    start_time = models.DateTimeField(blank=True, null=True, auto_now_add=True)
    end_time = models.DateTimeField(blank=True, null=True, auto_now_add=False)
    output = models.TextField(blank=True)
    class Meta:
        ordering = ['-start_time']
    def __unicode__(self):
        return u"Build Run (%d) for %s" % (, self.project)
    def get_absolute_url(self):
        return ('build_detail', (), { 'slug': self.project.slug, 'id': } )