From cfcb543478eb1d14274ed7db3b04197732833124 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 8 Jul 2017 21:31:12 +0200 Subject: [PATCH] Make mailinglist name unique in the database This should have been the case from the beginning, there are many things that would break if this was not followed. --- .../lists/migrations/0002_listname_unique.py | 19 +++++++++++++++++++ pgweb/lists/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 pgweb/lists/migrations/0002_listname_unique.py diff --git a/pgweb/lists/migrations/0002_listname_unique.py b/pgweb/lists/migrations/0002_listname_unique.py new file mode 100644 index 00000000..984eab01 --- /dev/null +++ b/pgweb/lists/migrations/0002_listname_unique.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lists', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='mailinglist', + name='listname', + field=models.CharField(unique=True, max_length=64), + ), + ] diff --git a/pgweb/lists/models.py b/pgweb/lists/models.py index 220d8255..9531a1cd 100644 --- a/pgweb/lists/models.py +++ b/pgweb/lists/models.py @@ -18,7 +18,7 @@ class MailingListGroup(models.Model): class MailingList(models.Model): group = models.ForeignKey(MailingListGroup, null=False) - listname = models.CharField(max_length=64, null=False, blank=False) + listname = models.CharField(max_length=64, null=False, blank=False, unique=True) active = models.BooleanField(null=False, default=False) externallink = models.URLField(max_length=200, null=True, blank=True) description = models.TextField(null=False, blank=True)