Include middle initial and name suffix into authors information if presented.
Fix author update when auto posting. Fixes #626 - Legacy-Id: 2903
This commit is contained in:
parent
1dbe9bf3ed
commit
153cdc72fe
|
@ -272,12 +272,14 @@ class UploadForm(forms.Form):
|
|||
)
|
||||
order = 0
|
||||
for author in draft.get_author_info():
|
||||
first_name, last_name, email = author
|
||||
full_name, first_name, middle_initial, last_name, name_suffix, email = author
|
||||
order += 1
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=document_id,
|
||||
first_name=first_name,
|
||||
middle_initial=middle_initial,
|
||||
last_name=last_name,
|
||||
name_suffix=name_suffix,
|
||||
email_address=email,
|
||||
author_order=order,
|
||||
submission=detail)
|
||||
|
@ -302,7 +304,7 @@ class AutoPostForm(forms.Form):
|
|||
full_name = '%s. %s' % (i.first_name[0], i.last_name)
|
||||
buttons.append(button_template % {'first_name': i.first_name,
|
||||
'last_name': i.last_name,
|
||||
'email': i.email()[1],
|
||||
'email': i.email()[1] or '',
|
||||
'full_name': full_name})
|
||||
return ''.join(buttons)
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ import datetime
|
|||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
|
||||
from ietf.idtracker.models import InternetDraft, PersonOrOrgInfo, IETFWG
|
||||
from ietf.idtracker.models import (InternetDraft, PersonOrOrgInfo, IETFWG,
|
||||
IDAuthor, EmailAddress)
|
||||
from ietf.utils.mail import send_mail
|
||||
|
||||
|
||||
|
@ -34,7 +35,6 @@ def request_full_url(request, submission):
|
|||
|
||||
def perform_post(submission):
|
||||
group_id = submission.group_acronym and submission.group_acronym.pk or NONE_WG
|
||||
updated = False
|
||||
try:
|
||||
draft = InternetDraft.objects.get(filename=submission.filename)
|
||||
draft.title = submission.id_document_name
|
||||
|
@ -47,7 +47,6 @@ def perform_post(submission):
|
|||
draft.last_modified_date = datetime.date.today()
|
||||
draft.abstract = submission.abstract
|
||||
draft.save()
|
||||
updated = True
|
||||
except InternetDraft.DoesNotExist:
|
||||
draft = InternetDraft.objects.create(
|
||||
title=submission.id_document_name,
|
||||
|
@ -63,11 +62,71 @@ def perform_post(submission):
|
|||
status_id=1, # Active
|
||||
intended_status_id=8, # None
|
||||
)
|
||||
update_authors(draft, submission)
|
||||
move_docs(submission)
|
||||
submission.status_id = POSTED
|
||||
submission.save()
|
||||
|
||||
|
||||
def find_person(first_name, last_name, middle_initial, name_suffix, email):
|
||||
person_list = None
|
||||
if email:
|
||||
person_list = PersonOrOrgInfo.objects.filter(emailaddress__address=email).distinct()
|
||||
if person_list and len(person_list) == 1:
|
||||
return person_list[0]
|
||||
if not person_list:
|
||||
person_list = PersonOrOrgInfo.objects.all()
|
||||
person_list = person_list.filter(first_name=first_name,
|
||||
last_name=last_name)
|
||||
if middle_initial:
|
||||
person_list = person_list.filter(middle_initial=middle_initial)
|
||||
if name_suffix:
|
||||
person_list = person_list.filter(name_suffix=name_suffix)
|
||||
if person_list:
|
||||
return person_list[0]
|
||||
return None
|
||||
|
||||
|
||||
def update_authors(draft, submission):
|
||||
# TempAuthor of order 0 is submitter
|
||||
new_authors = list(submission.tempidauthors_set.filter(author_order__gt=0))
|
||||
person_pks = []
|
||||
for author in new_authors:
|
||||
person = find_person(author.first_name, author.last_name,
|
||||
author.middle_initial, author.name_suffix,
|
||||
author.email_address)
|
||||
if not person:
|
||||
person = PersonOrOrgInfo(
|
||||
first_name=author.first_name,
|
||||
last_name=author.last_name,
|
||||
middle_initial=author.middle_initial or '',
|
||||
name_suffix=author.name_suffix or '',
|
||||
)
|
||||
person.save()
|
||||
if author.email:
|
||||
EmailAddress.objects.create(
|
||||
address=author.email,
|
||||
priority=1,
|
||||
type='INET',
|
||||
person_or_org=person,
|
||||
)
|
||||
person_pks.append(person.pk)
|
||||
try:
|
||||
idauthor = IDAuthor.objects.get(
|
||||
document=draft,
|
||||
person=person,
|
||||
)
|
||||
idauthor.author_order = author.author_order
|
||||
except IDAuthor.DoesNotExist:
|
||||
idauthor = IDAuthor(
|
||||
document=draft,
|
||||
person=person,
|
||||
author_order=author.author_order,
|
||||
)
|
||||
idauthor.save()
|
||||
draft.authors.exclude(person__pk__in=person_pks).delete()
|
||||
|
||||
|
||||
def get_person_for_user(user):
|
||||
try:
|
||||
return user.get_profile().person()
|
||||
|
|
|
@ -157,7 +157,7 @@ returned to the submitter.
|
|||
{% endif %}
|
||||
{% if validation.authors %}
|
||||
{% for author in validation.authors %}
|
||||
<tr{% if validation.warnings.authors %} class="warning"{% endif %}><th class="author">Author {{ forloop.counter }}</th><td>{{ author.email.0 }} {% if author.email.1 %}<{{ author.email.1 }}>{% endif %}</td></tr>
|
||||
<tr{% if validation.warnings.authors %} class="warning"{% endif %}><th class="author">Author {{ forloop.counter }}</th><td>{{ author.get_full_name }} {% if author.email.1 %}<{{ author.email.1 }}>{% endif %}</td></tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<tr{% if validation.warnings.pages %} class="warning"{% endif %}><th>Pages</th><td>{{ detail.txt_page_count }}<div class="warn_message">{{ validation.warnings.pages }}</div></td></tr>
|
||||
|
|
Loading…
Reference in a new issue