Skip to content

Commit 630a263

Browse files
committed
Merged in [8870] from rjsparks@nostrum.com:
Inform the secretariat when a duplicate Alias.name is created that isn't already a duplicate Person.name. Improve the message that's sent when either duplicate Person or Alias names are detected. - Legacy-Id: 8893 Note: SVN reference [8870] has been migrated to Git commit 8e1abfa
1 parent c065e59 commit 630a263

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

ietf/person/models.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ class Alias(models.Model):
127127
"""
128128
person = models.ForeignKey(Person)
129129
name = models.CharField(max_length=255, db_index=True)
130+
131+
def save(self, *args, **kwargs):
132+
created = not self.pk
133+
super(Alias, self).save(*args, **kwargs)
134+
if created:
135+
if Alias.objects.filter(name=self.name).exclude(person__name=self.name).count() > 1 :
136+
msg = render_to_string('person/mail/possible_duplicates.txt',
137+
dict(name=self.name,
138+
persons=Person.objects.filter(alias__name=self.name),
139+
settings=settings
140+
))
141+
send_mail_preformatted(None, msg)
142+
143+
130144
def __unicode__(self):
131145
return self.name
132146
class Meta:

ietf/templates/person/mail/possible_duplicates.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
To: <iesg-secretary@ietf.org>
33
Subject: Possible duplicate Person objects for {{name}}
44

5-
A new Person object was just created for {{name}}.
5+
A new Person and/or Alias object was just created for {{name}}.
66

77
There are now {{persons|length}} Person objects sharing that name.
88

99
Please check to see if they represent the same actual person, and if so, merge the objects as appropriate.
1010

11-
{% for person in persons %}Person {{forloop.counter}} (pk={{person.pk}})
12-
time: {{person.time}}
13-
ascii: {{person.ascii}}
14-
email: {% for email in person.email_set.all %}{{ email.address }} {% endfor %}
11+
{% for person in persons %}Person {{forloop.counter}} {{ person.name }} (pk={{person.pk}})
12+
time: {{person.time}}
13+
ascii: {{person.ascii}}
14+
email: {% for email in person.email_set.all %}{{ email.address }} {% endfor %}
15+
aliases: {{ person.alias_set.all|join:", " }}
1516

1617
{% endfor %} {% endautoescape %}

0 commit comments

Comments
 (0)