[damned-lies] Removed null=True on text-based fields
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Removed null=True on text-based fields
- Date: Sun, 25 Mar 2018 16:18:37 +0000 (UTC)
commit cdc627a023d3be7a0e7daddd076be60a42aeaa30
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Mar 24 11:32:02 2018 +0100
Removed null=True on text-based fields
stats/fixtures/sample_data.json | 110 ++++++++++----------
stats/management/commands/update-trans.py | 2 +-
.../migrations/0009_remove_null_on_text_fields.py | 89 ++++++++++++++++
stats/models.py | 28 +++---
stats/tests/tests.py | 2 +-
5 files changed, 160 insertions(+), 71 deletions(-)
---
diff --git a/stats/fixtures/sample_data.json b/stats/fixtures/sample_data.json
index 07d4dd2..b74cff2 100644
--- a/stats/fixtures/sample_data.json
+++ b/stats/fixtures/sample_data.json
@@ -196,38 +196,38 @@
},
{
"fields": {
- "comment": null,
+ "comment": "",
"archived": false,
"vcs_web": "https://git.gnome.org/browse/gnome-hello/",
"name": "gnome-hello",
"vcs_root": "git://git.gnome.org/gnome-hello",
"bugs_product": "test",
- "ext_platform": null,
+ "ext_platform": "",
"maintainers": [],
"bugs_component": "test",
"bugs_base": "https://bugzilla.gnome.org",
"vcs_type": "git",
- "homepage": null,
- "description": null
+ "homepage": "",
+ "description": ""
},
"model": "stats.module",
"pk": 1
},
{
"fields": {
- "comment": null,
+ "comment": "",
"archived": false,
"vcs_web": "https://git.gnome.org/browse/zenity/",
"name": "zenity",
"vcs_root": "git://git.gnome.org/zenity",
"bugs_product": "zenity",
- "ext_platform": null,
+ "ext_platform": "",
"maintainers": [],
"bugs_component": "general",
"bugs_base": "https://bugzilla.gnome.org",
"vcs_type": "git",
- "homepage": null,
- "description": null
+ "homepage": "",
+ "description": ""
},
"model": "stats.module",
"pk": 2
@@ -240,12 +240,12 @@
"name": "shared-mime-info",
"vcs_root": "git://anongit.freedesktop.org/xdg/shared-mime-info",
"bugs_product": "shared-mime-info",
- "ext_platform": null,
+ "ext_platform": "",
"maintainers": [],
"bugs_component": "general",
"bugs_base": "https://bugs.freedesktop.org/",
"vcs_type": "git",
- "homepage": null,
+ "homepage": "",
"description": "Shared MIME Info"
},
"model": "stats.module",
@@ -253,7 +253,7 @@
},
{
"fields": {
- "vcs_subpath": null,
+ "vcs_subpath": "",
"file_hashes": "",
"weight": 0,
"name": "master",
@@ -264,7 +264,7 @@
},
{
"fields": {
- "vcs_subpath": null,
+ "vcs_subpath": "",
"file_hashes": "",
"weight": 0,
"name": "gnome-3-8",
@@ -275,7 +275,7 @@
},
{
"fields": {
- "vcs_subpath": null,
+ "vcs_subpath": "",
"file_hashes": "",
"weight": 0,
"name": "master",
@@ -286,7 +286,7 @@
},
{
"fields": {
- "vcs_subpath": null,
+ "vcs_subpath": "",
"file_hashes": "",
"weight": 0,
"name": "master",
@@ -300,10 +300,10 @@
"branch_from": null,
"name": "po",
"dtype": "ui",
- "pot_method": null,
+ "pot_method": "",
"module": 1,
- "linguas_location": null,
- "red_filter": null,
+ "linguas_location": "",
+ "red_filter": "",
"branch_to": null,
"directory": "po",
"description": "UI Translations"
@@ -316,10 +316,10 @@
"branch_from": null,
"name": "help",
"dtype": "doc",
- "pot_method": null,
+ "pot_method": "",
"module": 1,
- "linguas_location": null,
- "red_filter": null,
+ "linguas_location": "",
+ "red_filter": "",
"branch_to": null,
"directory": "help",
"description": "User Guide"
@@ -332,10 +332,10 @@
"branch_from": null,
"name": "po",
"dtype": "ui",
- "pot_method": null,
+ "pot_method": "",
"module": 2,
- "linguas_location": null,
- "red_filter": null,
+ "linguas_location": "",
+ "red_filter": "",
"branch_to": null,
"directory": "po",
"description": "UI Translations"
@@ -348,10 +348,10 @@
"branch_from": null,
"name": "help",
"dtype": "doc",
- "pot_method": null,
+ "pot_method": "",
"module": 2,
- "linguas_location": null,
- "red_filter": null,
+ "linguas_location": "",
+ "red_filter": "",
"branch_to": null,
"directory": "help",
"description": "User Guide"
@@ -364,10 +364,10 @@
"branch_from": null,
"name": "po",
"dtype": "ui",
- "pot_method": null,
+ "pot_method": "",
"module": 3,
- "linguas_location": null,
- "red_filter": null,
+ "linguas_location": "",
+ "red_filter": "",
"branch_to": null,
"directory": "po",
"description": "UI Translations"
@@ -380,10 +380,10 @@
"branch_from": null,
"name": "help",
"dtype": "doc",
- "pot_method": null,
+ "pot_method": "",
"module": 3,
- "linguas_location": null,
- "red_filter": null,
+ "linguas_location": "",
+ "red_filter": "",
"branch_to": null,
"directory": "help",
"description": "User Guide"
@@ -596,7 +596,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 1
@@ -611,7 +611,7 @@
"figures": null,
"fuzzy": 0,
"translated": 47,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 2
@@ -626,7 +626,7 @@
"figures": null,
"fuzzy": 10,
"translated": 30,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 3
@@ -641,7 +641,7 @@
"figures": "[{\"path\": \"figures/gnome-hello-new.png\", \"hash\": \"8a1fcc6f46a22a1f500cfef9ca51b481\"},
{\"path\": \"figures/gnome-hello-logo.png\", \"hash\": \"1ae47b7a7c4fbeb1f6bb72c0cf18d389\"}]",
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 4
@@ -656,7 +656,7 @@
"figures": "[{\"translated\": false, \"path\": \"figures/gnome-hello-new.png\", \"hash\":
\"8a1fcc6f46a22a1f500cfef9ca51b481\", \"fuzzy\": true}, {\"translated\": false, \"path\":
\"figures/gnome-hello-logo.png\", \"hash\": \"1ae47b7a7c4fbeb1f6bb72c0cf18d389\", \"fuzzy\": false}]",
"fuzzy": 0,
"translated": 20,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 5
@@ -671,7 +671,7 @@
"figures": null,
"fuzzy": 0,
"translated": 20,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 6
@@ -686,7 +686,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 7
@@ -701,7 +701,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 8
@@ -716,7 +716,7 @@
"figures": null,
"fuzzy": 0,
"translated": 136,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 9
@@ -731,7 +731,7 @@
"figures": null,
"fuzzy": 0,
"translated": 130,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 10
@@ -746,7 +746,7 @@
"figures": null,
"fuzzy": 0,
"translated": 100,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 11
@@ -761,7 +761,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 12
@@ -776,7 +776,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 13
@@ -791,7 +791,7 @@
"figures": null,
"fuzzy": 0,
"translated": 259,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 14
@@ -806,7 +806,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 15
@@ -821,7 +821,7 @@
"figures": null,
"fuzzy": 4,
"translated": 255,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 16
@@ -836,7 +836,7 @@
"figures": null,
"fuzzy": 0,
"translated": 259,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 17
@@ -851,7 +851,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 18
@@ -866,7 +866,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 19
@@ -881,7 +881,7 @@
"figures": null,
"fuzzy": 0,
"translated": 259,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 20
@@ -896,7 +896,7 @@
"figures": null,
"fuzzy": 0,
"translated": 0,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 21
@@ -911,7 +911,7 @@
"figures": null,
"fuzzy": 20,
"translated": 598,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 22
@@ -926,7 +926,7 @@
"figures": null,
"fuzzy": 6,
"translated": 620,
- "path": null
+ "path": ""
},
"model": "stats.pofile",
"pk": 23
diff --git a/stats/management/commands/update-trans.py b/stats/management/commands/update-trans.py
index 9dab871..9c6667d 100644
--- a/stats/management/commands/update-trans.py
+++ b/stats/management/commands/update-trans.py
@@ -43,7 +43,7 @@ class Command(BaseCommand):
Language.objects.exclude(name__exact=F('locale')).values_list('name', flat=True),
Domain.objects.distinct().values_list('description', flat=True),
Module.objects.exclude(name__exact=F('description')).values_list('description', flat=True),
- Module.objects.filter(comment__isnull=False).values_list('comment', flat=True),
+ Module.objects.exclude(comment='').values_list('comment', flat=True),
Release.objects.values_list('description', flat=True),
CategoryName.objects.values_list('name', flat=True)):
if value:
diff --git a/stats/migrations/0009_remove_null_on_text_fields.py
b/stats/migrations/0009_remove_null_on_text_fields.py
new file mode 100644
index 0000000..38b59e6
--- /dev/null
+++ b/stats/migrations/0009_remove_null_on_text_fields.py
@@ -0,0 +1,89 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('stats', '0008_domain_extra_its_dirs'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='branch',
+ name='vcs_subpath',
+ field=models.CharField(blank=True, default='', max_length=50),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='domain',
+ name='description',
+ field=models.TextField(blank=True, default=''),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='domain',
+ name='linguas_location',
+ field=models.CharField(blank=True, default='', help_text="Use 'no' for no LINGUAS check, or
path/to/file#variable for a non-standard location.\n Leave blank for standard location
(ALL_LINGUAS in LINGUAS/configure.ac/.in for UI and DOC_LINGUAS in Makefile.am for DOC)", max_length=50),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='domain',
+ name='pot_method',
+ field=models.CharField(blank=True, default='', help_text="Leave blank for standard method
(intltool for UI and gnome-doc-utils for DOC), or '<gettext>' for the pure xgettext-based extraction",
max_length=100),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='domain',
+ name='red_filter',
+ field=models.TextField(blank=True, default='', help_text='pogrep filter to strip po file from
unprioritized strings (format: location|string, "-" for no filter)'),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='bugs_base',
+ field=models.CharField(blank=True, default='', max_length=250),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='bugs_component',
+ field=models.CharField(blank=True, default='', max_length=50),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='bugs_product',
+ field=models.CharField(blank=True, default='', max_length=50),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='comment',
+ field=models.TextField(blank=True, default=''),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='description',
+ field=models.TextField(blank=True, default=''),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='ext_platform',
+ field=models.URLField(blank=True, default='', help_text='URL to external translation platform,
if any'),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='module',
+ name='homepage',
+ field=models.URLField(blank=True, default='', help_text='Automatically updated if the module
contains a doap file.'),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='pofile',
+ name='path',
+ field=models.CharField(blank=True, default='', max_length=255),
+ preserve_default=False,
+ ),
+ ]
diff --git a/stats/models.py b/stats/models.py
index ca59ddd..4267ac3 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -55,18 +55,18 @@ BRANCH_HEAD_NAMES = (
class Module(models.Model):
name = models.CharField(max_length=50, unique=True, validators=[validate_slug])
- homepage = models.URLField(null=True, blank=True,
- help_text="Automatically updated if the module contains a doap file.")
- description = models.TextField(null=True, blank=True)
- comment = models.TextField(null=True, blank=True)
- bugs_base = models.CharField(max_length=250, null=True, blank=True)
- bugs_product = models.CharField(max_length=50, null=True, blank=True)
- bugs_component = models.CharField(max_length=50, null=True, blank=True)
+ homepage = models.URLField(blank=True,
+ help_text="Automatically updated if the module contains a doap file.")
+ description = models.TextField(blank=True)
+ comment = models.TextField(blank=True)
+ bugs_base = models.CharField(max_length=250, blank=True)
+ bugs_product = models.CharField(max_length=50, blank=True)
+ bugs_component = models.CharField(max_length=50, blank=True)
vcs_type = models.CharField(max_length=5, choices=VCS_TYPE_CHOICES)
# URLField is too restrictive for vcs_root
vcs_root = models.CharField(max_length=200)
vcs_web = models.URLField()
- ext_platform = models.URLField(null=True, blank=True,
+ ext_platform = models.URLField(blank=True,
help_text="URL to external translation platform, if any")
archived = models.BooleanField(default=False)
@@ -179,7 +179,7 @@ class Branch(models.Model):
""" Branch of a module """
name = models.CharField(max_length=50)
#description = models.TextField(null=True)
- vcs_subpath = models.CharField(max_length=50, null=True, blank=True)
+ vcs_subpath = models.CharField(max_length=50, blank=True)
module = models.ForeignKey(Module, on_delete=models.CASCADE)
weight = models.IntegerField(default=0, help_text="Smaller weight is displayed first")
file_hashes = DictionaryField(default='', blank=True, editable=False)
@@ -721,20 +721,20 @@ DOMAIN_TYPE_CHOICES = (
class Domain(models.Model):
module = models.ForeignKey(Module, on_delete=models.CASCADE)
name = models.CharField(max_length=50)
- description = models.TextField(null=True, blank=True)
+ description = models.TextField(blank=True)
dtype = models.CharField(max_length=5, choices=DOMAIN_TYPE_CHOICES, default='ui')
directory = models.CharField(max_length=50)
# The pot_method is a command who should produce a potfile in the po directory of
# the domain, named <potbase()>.pot (e.g. /po/gnucash.pot).
- pot_method = models.CharField(max_length=100, null=True, blank=True,
+ pot_method = models.CharField(max_length=100, blank=True,
help_text="Leave blank for standard method (intltool for UI and gnome-doc-utils for DOC), "
"or '<gettext>' for the pure xgettext-based extraction")
extra_its_dirs = models.TextField(blank=True,
help_text="colon-separated directories containing extra .its/.loc files for gettext")
- linguas_location = models.CharField(max_length=50, null=True, blank=True,
+ linguas_location = models.CharField(max_length=50, blank=True,
help_text="""Use 'no' for no LINGUAS check, or path/to/file#variable for a non-standard location.
Leave blank for standard location (ALL_LINGUAS in LINGUAS/configure.ac/.in for UI and
DOC_LINGUAS in Makefile.am for DOC)""")
- red_filter = models.TextField(null=True, blank=True,
+ red_filter = models.TextField(blank=True,
help_text="""pogrep filter to strip po file from unprioritized strings (format: location|string, "-"
for no filter)""")
# Allow to specify the branches to which this domain applies
branch_from = models.ForeignKey(Branch, null=True, blank=True, on_delete=models.PROTECT,
related_name='+')
@@ -1226,7 +1226,7 @@ class Category(models.Model):
class PoFile(models.Model):
# File type fields of Django may not be flexible enough for our use case
- path = models.CharField(max_length=255, blank=True, null=True)
+ path = models.CharField(max_length=255, blank=True)
updated = models.DateTimeField(auto_now_add=True)
translated = models.IntegerField(default=0)
fuzzy = models.IntegerField(default=0)
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 4e6fa13..7a2e923 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -82,7 +82,7 @@ class ModuleTestCase(TestCase):
response,
'https://bugzilla.gnome.org/enter_bug.cgi?product=test&keywords=I18N+L10N&component=test'
)
- self.mod.bugs_base = None
+ self.mod.bugs_base = ''
self.mod.save()
response = self.client.get(reverse('module', args=[self.mod.name]))
self.assertContains(response, "Sorry, no known locations to report bugs for this module.")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]