aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-06-13 13:33:43 -0500
committerMichael Wood <michael.g.wood@intel.com>2016-06-23 12:23:54 +0100
commitf402c8ad58a1675a680887e31fef15f7a2ad296e (patch)
tree6b71261ea770551cee3b850053e758c2d89ab0f4
parentef6ace38e7368f9a99d06b3cb111b201de1f64ed (diff)
downloaderror-report-web-f402c8ad58a1675a680887e31fef15f7a2ad296e.tar.gz
error-report-web-f402c8ad58a1675a680887e31fef15f7a2ad296e.tar.bz2
error-report-web-f402c8ad58a1675a680887e31fef15f7a2ad296e.zip
models: Build model add support for Error type.
In order to support other errors not only Recipe ones adds a ERROR_TYPE field to the Build model defaults to "Recipe". [YOCTO #7583] Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com>
-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)