aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Post/migrations/0005_build_error_type.py19
-rw-r--r--Post/models.py26
2 files changed, 45 insertions, 0 deletions
diff --git a/Post/migrations/0005_build_error_type.py b/Post/migrations/0005_build_error_type.py
new file mode 100644
index 0000000..5061cbe
--- /dev/null
+++ b/Post/migrations/0005_build_error_type.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('Post', '0004_auto_20160530_1126'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='build',
+ name='ERROR_TYPE',
+ field=models.CharField(default=b'recipe', max_length=20, choices=[(b'recipe', b'Recipe'), (b'core', b'Core'), (b'bitbake-selftest', b'Bitbake selftest'), (b'oe-selftest', b'OE selftest')]),
+ ),
+ ]
diff --git a/Post/models.py b/Post/models.py
index 84f8abf..ddf2fc7 100644
--- a/Post/models.py
+++ b/Post/models.py
@@ -11,8 +11,24 @@ from datetime import datetime
import Levenshtein
+class ErrorType(object):
+ RECIPE = 'recipe'
+ CORE = 'core'
+ BITBAKE_SELFTEST = 'bitbake-selftest'
+ OE_SELFTEST = 'oe-selftest'
+
+class InvalidErrorType(Exception):
+ pass
+
# Create your models here.
class Build(models.Model):
+ ERROR_TYPE_CHOICES = (
+ (ErrorType.RECIPE, 'Recipe'),
+ (ErrorType.CORE, 'Core'),
+ (ErrorType.BITBAKE_SELFTEST, 'Bitbake selftest'),
+ (ErrorType.OE_SELFTEST, 'OE selftest'),
+ )
+
DATE = models.DateTimeField('Submit date', blank=True, null=True)
MACHINE = models.CharField(max_length=50)
BRANCH = models.CharField(max_length=200)
@@ -25,6 +41,16 @@ class Build(models.Model):
NAME = models.CharField(max_length=50)
EMAIL = models.CharField(max_length=50)
LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
+ ERROR_TYPE = models.CharField(max_length=20, choices=ERROR_TYPE_CHOICES,
+ default=ErrorType.RECIPE)
+
+ def save(self, *args, **kwargs):
+ if self.ERROR_TYPE not in [e_type[0] for e_type in
+ self.ERROR_TYPE_CHOICES]:
+ raise InvalidErrorType("Error type %s is not known" %
+ self.ERROR_TYPE)
+
+ super(Build, self).save(*args, **kwargs)
class BuildFailure(models.Model):
TASK = models.CharField(max_length=1024)