Create all appropriate aliases when a Person record is created, both in ietfauth and in PersonFactory.
- Legacy-Id: 12958
This commit is contained in:
parent
c006c44423
commit
ce9f879500
ietf
|
@ -165,6 +165,10 @@ def confirm_account(request, auth):
|
|||
person = Person.objects.create(user=user,
|
||||
name=name,
|
||||
ascii=ascii)
|
||||
|
||||
for name in set([ person.name, person.ascii, person.plain_name(), person.plain_ascii(), ]):
|
||||
Alias.objects.create(person=person, name=name)
|
||||
|
||||
if not email_obj:
|
||||
email_obj = Email.objects.create(address=email, person=person)
|
||||
else:
|
||||
|
@ -253,7 +257,7 @@ def profile(request):
|
|||
|
||||
# Make sure the alias table contains any new and/or old names.
|
||||
existing_aliases = set(Alias.objects.filter(person=person).values_list("name", flat=True))
|
||||
curr_names = set(x for x in [updated_person.name, updated_person.ascii, updated_person.ascii_short, updated_person.plain_name(), ] if x)
|
||||
curr_names = set(x for x in [updated_person.name, updated_person.ascii, updated_person.ascii_short, updated_person.plain_name(), updated_person.plain_ascii(), ] if x)
|
||||
new_aliases = curr_names - existing_aliases
|
||||
for name in new_aliases:
|
||||
Alias.objects.create(person=updated_person, name=name)
|
||||
|
|
|
@ -51,6 +51,10 @@ class PersonFactory(factory.DjangoModelFactory):
|
|||
make_alias = getattr(AliasFactory, 'create' if create else 'build')
|
||||
make_alias(person=obj,name=obj.name)
|
||||
make_alias(person=obj,name=obj.ascii)
|
||||
if obj.name != obj.plain_name():
|
||||
make_alias(person=obj,name=obj.plain_name())
|
||||
if obj.ascii != obj.plain_ascii():
|
||||
make_alias(person=obj,name=obj.plain_ascii())
|
||||
|
||||
@factory.post_generation
|
||||
def default_emails(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
|
||||
|
|
Loading…
Reference in a new issue