mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-12 09:24:15 -04:00
Lookup index, rather than iterating
Since instances of `Recipients` are now iterable we can just look up the first row by index, rather than having to hit the rows property as a generator. There is a chance that there won’t be a first row, if the file has 1 or fewer columns. So we still need to handle a possible exception (albeit it a different one to before).
This commit is contained in:
@@ -521,8 +521,8 @@ def _check_messages(service_id, template_type, upload_id, letters_as_pdf=False):
|
||||
back_link = url_for('.send_messages', service_id=service_id, template_id=template.id)
|
||||
choose_time_form = ChooseTimeForm()
|
||||
|
||||
with suppress(StopIteration):
|
||||
template.values = next(recipients.rows)
|
||||
with suppress(IndexError):
|
||||
template.values = recipients[0]
|
||||
|
||||
session['upload_data']['notification_count'] = len(list(recipients.rows))
|
||||
session['upload_data']['valid'] = not recipients.has_errors
|
||||
|
||||
Reference in New Issue
Block a user