Skip to content

Commit 6f6d720

Browse files
committed
Get author information from the tuple of draft.py. Do not mark as error if some author has no email. Fixes ietf-tools#626
- Legacy-Id: 2900
1 parent 15a576b commit 6f6d720

5 files changed

Lines changed: 8 additions & 31 deletions

File tree

ietf/submit/forms.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,8 @@ def save_draft_info(self, draft):
271271
file_type=','.join(self.file_type),
272272
)
273273
order = 0
274-
for author in draft.get_authors():
275-
try:
276-
name, email = author.rsplit(' ', 1)
277-
except ValueError:
278-
first_name = author
279-
last_name = ''
280-
email = ''
281-
else:
282-
try:
283-
first_name, last_name = name.split(' ', 1)
284-
except ValueError:
285-
first_name = name
286-
last_name = ''
287-
email = email.replace('<', '').replace('>', '')
274+
for author in draft.get_author_info():
275+
first_name, last_name, email = author
288276
order += 1
289277
TempIdAuthors.objects.create(
290278
id_document_tag=document_id,
@@ -378,9 +366,7 @@ def get_initial_authors(self):
378366
if not last_name:
379367
author['errors']['last_name'] = 'This field is required'
380368
email = self.data.get('email_%s' % index, '').strip()
381-
if not email:
382-
author['errors']['email'] = 'This field is required'
383-
elif not email_re.search(email):
369+
if email and not email_re.search(email):
384370
author['errors']['email'] = 'Enter a valid e-mail address'
385371
if first_name or last_name or email:
386372
author.update({'first_name': first_name,

ietf/submit/utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,6 @@ def validate_authors(self):
167167
if not self.authors:
168168
self.add_warning('authors', 'No authors found')
169169
return
170-
index = 1
171-
message = ''
172-
for author in self.authors:
173-
if not author.last_name:
174-
message += 'Author %s has no last name<br />' % index
175-
if not author.email:
176-
message += 'Author %s has no email<br />' % index
177-
if message:
178-
self.add_warning('authors', message)
179170

180171
def validate_creation_date(self):
181172
date = self.draft.creation_date

ietf/submit/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def draft_status(request, submission_id, submission_hash=None, message=None):
141141
allow_edit = None
142142
message = ('success', 'Your submission is pending email authentication. An email has been sent you with instructions.')
143143
else:
144-
return HttpResponseRedirect(reverse(draft_edit, None, kwargs={'submission_id': detail.submission_id}))
144+
return HttpResponseRedirect(reverse(draft_edit, None, kwargs={'submission_id': detail.submission_id, 'submission_hash': submission_hash}))
145145
else:
146146
auto_post_form = AutoPostForm(draft=detail, validation=validation)
147147

ietf/templates/submit/draft_edit.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ <h3>Authors</h3>
132132
<tbody>
133133
{% for author in form.get_authors %}
134134
<tr class="editable {% cycle oddrow,evenrow %}{% if author.errors %} error{% endif %}">
135-
<td name="first_name"><span class="fieldValue">{{ author.first_name }}</span><span class="field-error">{{ author.errors.first_name }}</span></td>
136-
<td name="last_name"><span class="fieldValue">{{ author.last_name }}</span><span class="field-error">{{ author.errors.last_name }}</span></td>
137-
<td name="email"><span class="fieldValue">{{ author.email.1 }}</span><span class="field-error">{{ author.errors.email }}</span></td>
135+
<td name="first_name"><span class="fieldValue">{{ author.first_name|default:"" }}</span><span class="field-error">{{ author.errors.first_name }}</span></td>
136+
<td name="last_name"><span class="fieldValue">{{ author.last_name|default:"" }}</span><span class="field-error">{{ author.errors.last_name }}</span></td>
137+
<td name="email"><span class="fieldValue">{{ author.email.1|default:"" }}</span><span class="field-error">{{ author.errors.email }}</span></td>
138138
</tr>
139139
{% endfor %}
140140
</tbody>

ietf/templates/submit/draft_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h3>Meta-Data errors found</h3>
157157
{% endif %}
158158
{% if validation.authors %}
159159
{% for author in validation.authors %}
160-
<tr{% if validation.warnings.authors %} class="warning"{% endif %}><th class="author">Author {{ forloop.counter }}</th><td>{{ author.email.0 }} &lt;{{ author.email.1 }}&gt;</td></tr>
160+
<tr{% if validation.warnings.authors %} class="warning"{% endif %}><th class="author">Author {{ forloop.counter }}</th><td>{{ author.email.0 }} {% if author.email.1 %}&lt;{{ author.email.1 }}&gt;{% endif %}</td></tr>
161161
{% endfor %}
162162
{% endif %}
163163
<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>

0 commit comments

Comments
 (0)