[PATCH v2 2/6] models: Use non-null slugs for 'Check.name'

Stephen Finucane stephen.finucane at intel.com
Sat Mar 26 04:27:19 AEDT 2016


The schema for 'Check' defines 'Check.name' as a 'CharField'. This is
less than ideal as names with spaces and special characters can't be
represented cleanly in URLs etc. We should use 'SlugField' instead.

Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
Closes: #33
---
 patchwork/migrations/0009_slugified_check_context | 19 +++++++++++++++++++
 patchwork/models.py                               |  8 ++++----
 2 files changed, 23 insertions(+), 4 deletions(-)
 create mode 100644 patchwork/migrations/0009_slugified_check_context

diff --git a/patchwork/migrations/0009_slugified_check_context b/patchwork/migrations/0009_slugified_check_context
new file mode 100644
index 0000000..7916f7c
--- /dev/null
+++ b/patchwork/migrations/0009_slugified_check_context
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('patchwork', '0008_add_email_mixin'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='check',
+            name='context',
+            field=models.SlugField(default=b'default', help_text=b'A label to discern check from checks of other testing systems.', max_length=255),
+        ),
+    ]
diff --git a/patchwork/models.py b/patchwork/models.py
index 87d7d0d..267c08e 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -552,12 +552,12 @@ class Check(models.Model):
         help_text='The state of the check.')
     target_url = models.URLField(
         blank=True, null=True,
-        help_text='The target URL to associate with this check. This should'
-        ' be specific to the patch.')
+        help_text='The target URL to associate with this check. This should '
+        'be specific to the patch.')
     description = models.TextField(
         blank=True, null=True, help_text='A brief description of the check.')
-    context = models.CharField(
-        max_length=255, default='default', blank=True, null=True,
+    context = models.SlugField(
+        max_length=255, default='default',
         help_text='A label to discern check from checks of other testing '
         'systems.')
 
-- 
2.0.0



More information about the Patchwork mailing list