Increased the length of the list Subscribed email field from 64 to 128, updated the import_mailman_listinfo management command, and added a migration for the model change.

- Legacy-Id: 16370
This commit is contained in:
Henrik Levkowetz 2019-07-03 20:52:17 +00:00
parent 5e09c5a0aa
commit e60a3e74f8
3 changed files with 28 additions and 4 deletions

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2016, All Rights Reserved # Copyright The IETF Trust 2016-2019, All Rights Reserved
import sys import sys
from textwrap import dedent from textwrap import dedent
@ -35,6 +35,8 @@ def import_mailman_listinfo(verbosity=0):
names = list(Utils.list_names()) names = list(Utils.list_names())
names.sort() names.sort()
addr_max_length = Subscribed._meta.get_field('email').max_length
debug.show('addr_max_length')
for name in names: for name in names:
mlist = MailList.MailList(name, lock=False) mlist = MailList.MailList(name, lock=False)
note("List: %s" % mlist.internal_name()) note("List: %s" % mlist.internal_name())
@ -62,7 +64,7 @@ def import_mailman_listinfo(verbosity=0):
note(" Removing address with no subscriptions: %s" % (addr)) note(" Removing address with no subscriptions: %s" % (addr))
old.delete() old.delete()
for addr in members: for addr in members:
if len(addr) > 64: if len(addr) > addr_max_length:
sys.stderr.write(" ** Email address subscribed to '%s' too long for table: <%s>\n" % (name, addr)) sys.stderr.write(" ** Email address subscribed to '%s' too long for table: <%s>\n" % (name, addr))
continue continue
if not addr in known: if not addr in known:

View file

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright The IETF Trust 2019, All Rights Reserved
# Generated by Django 1.11.22 on 2019-07-03 13:44
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mailinglists', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='subscribed',
name='email',
field=models.CharField(max_length=128, validators=[django.core.validators.EmailValidator()]),
),
]

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2016, All Rights Reserved # Copyright The IETF Trust 2016-2019, All Rights Reserved
from django.conf import settings from django.conf import settings
@ -19,7 +19,7 @@ class List(models.Model):
class Subscribed(models.Model): class Subscribed(models.Model):
time = models.DateTimeField(auto_now_add=True) time = models.DateTimeField(auto_now_add=True)
email = models.CharField(max_length=64, validators=[validate_email]) email = models.CharField(max_length=128, validators=[validate_email])
lists = models.ManyToManyField(List) lists = models.ManyToManyField(List)
def __unicode__(self): def __unicode__(self):
return "<Subscribed: %s at %s>" % (self.email, self.time) return "<Subscribed: %s at %s>" % (self.email, self.time)