Get author information from the tuple of draft.py. Do not mark as error if some author has no email. Fixes #626
- Legacy-Id: 2900
This commit is contained in:
parent
15a576b348
commit
6f6d720daa
|
@ -271,20 +271,8 @@ class UploadForm(forms.Form):
|
|||
file_type=','.join(self.file_type),
|
||||
)
|
||||
order = 0
|
||||
for author in draft.get_authors():
|
||||
try:
|
||||
name, email = author.rsplit(' ', 1)
|
||||
except ValueError:
|
||||
first_name = author
|
||||
last_name = ''
|
||||
email = ''
|
||||
else:
|
||||
try:
|
||||
first_name, last_name = name.split(' ', 1)
|
||||
except ValueError:
|
||||
first_name = name
|
||||
last_name = ''
|
||||
email = email.replace('<', '').replace('>', '')
|
||||
for author in draft.get_author_info():
|
||||
first_name, last_name, email = author
|
||||
order += 1
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=document_id,
|
||||
|
@ -378,9 +366,7 @@ class MetaDataForm(AutoPostForm):
|
|||
if not last_name:
|
||||
author['errors']['last_name'] = 'This field is required'
|
||||
email = self.data.get('email_%s' % index, '').strip()
|
||||
if not email:
|
||||
author['errors']['email'] = 'This field is required'
|
||||
elif not email_re.search(email):
|
||||
if email and not email_re.search(email):
|
||||
author['errors']['email'] = 'Enter a valid e-mail address'
|
||||
if first_name or last_name or email:
|
||||
author.update({'first_name': first_name,
|
||||
|
|
|
@ -167,15 +167,6 @@ class DraftValidation(object):
|
|||
if not self.authors:
|
||||
self.add_warning('authors', 'No authors found')
|
||||
return
|
||||
index = 1
|
||||
message = ''
|
||||
for author in self.authors:
|
||||
if not author.last_name:
|
||||
message += 'Author %s has no last name<br />' % index
|
||||
if not author.email:
|
||||
message += 'Author %s has no email<br />' % index
|
||||
if message:
|
||||
self.add_warning('authors', message)
|
||||
|
||||
def validate_creation_date(self):
|
||||
date = self.draft.creation_date
|
||||
|
|
|
@ -141,7 +141,7 @@ def draft_status(request, submission_id, submission_hash=None, message=None):
|
|||
allow_edit = None
|
||||
message = ('success', 'Your submission is pending email authentication. An email has been sent you with instructions.')
|
||||
else:
|
||||
return HttpResponseRedirect(reverse(draft_edit, None, kwargs={'submission_id': detail.submission_id}))
|
||||
return HttpResponseRedirect(reverse(draft_edit, None, kwargs={'submission_id': detail.submission_id, 'submission_hash': submission_hash}))
|
||||
else:
|
||||
auto_post_form = AutoPostForm(draft=detail, validation=validation)
|
||||
|
||||
|
|
|
@ -132,9 +132,9 @@ If you are one of the authors, then please click a button by your name to automa
|
|||
<tbody>
|
||||
{% for author in form.get_authors %}
|
||||
<tr class="editable {% cycle oddrow,evenrow %}{% if author.errors %} error{% endif %}">
|
||||
<td name="first_name"><span class="fieldValue">{{ author.first_name }}</span><span class="field-error">{{ author.errors.first_name }}</span></td>
|
||||
<td name="last_name"><span class="fieldValue">{{ author.last_name }}</span><span class="field-error">{{ author.errors.last_name }}</span></td>
|
||||
<td name="email"><span class="fieldValue">{{ author.email.1 }}</span><span class="field-error">{{ author.errors.email }}</span></td>
|
||||
<td name="first_name"><span class="fieldValue">{{ author.first_name|default:"" }}</span><span class="field-error">{{ author.errors.first_name }}</span></td>
|
||||
<td name="last_name"><span class="fieldValue">{{ author.last_name|default:"" }}</span><span class="field-error">{{ author.errors.last_name }}</span></td>
|
||||
<td name="email"><span class="fieldValue">{{ author.email.1|default:"" }}</span><span class="field-error">{{ author.errors.email }}</span></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -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 }} <{{ author.email.1 }}></td></tr>
|
||||
<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>
|
||||
{% 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