mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-25 02:19:12 -04:00
Make row in URL match displayed row
Spreadsheets start at row 1 (the header row), and the values don’t start until row 2. The row numbers in our URLs start at 0, which is a concept that only makes sense to programmers. It’s more predictable and consistent to make the number in the URL match the row number displayed on the page when previewing the spreadsheet.
This commit is contained in:
@@ -523,9 +523,12 @@ def _check_messages(service_id, template_type, upload_id, preview_row, letters_a
|
||||
|
||||
count_of_recipients = len(list(recipients.rows))
|
||||
|
||||
if preview_row < count_of_recipients:
|
||||
template.values = recipients[preview_row]
|
||||
elif preview_row > 0:
|
||||
if preview_row < 2:
|
||||
abort(404)
|
||||
|
||||
if preview_row < count_of_recipients + 2:
|
||||
template.values = recipients[preview_row - 2]
|
||||
elif preview_row > 2:
|
||||
abort(404)
|
||||
|
||||
session['upload_data']['notification_count'] = count_of_recipients
|
||||
@@ -562,7 +565,7 @@ def _check_messages(service_id, template_type, upload_id, preview_row, letters_a
|
||||
@main.route("/services/<service_id>/<template_type>/check/<upload_id>/row-<int:row_index>", methods=['GET'])
|
||||
@login_required
|
||||
@user_has_permissions('send_texts', 'send_emails', 'send_letters')
|
||||
def check_messages(service_id, template_type, upload_id, row_index=0):
|
||||
def check_messages(service_id, template_type, upload_id, row_index=2):
|
||||
|
||||
data = _check_messages(service_id, template_type, upload_id, row_index)
|
||||
|
||||
@@ -590,7 +593,7 @@ def check_messages(service_id, template_type, upload_id, row_index=0):
|
||||
@main.route("/services/<service_id>/<template_type>/check/<upload_id>/row-<int:row_index>.<filetype>", methods=['GET'])
|
||||
@login_required
|
||||
@user_has_permissions('send_texts', 'send_emails', 'send_letters')
|
||||
def check_messages_preview(service_id, template_type, upload_id, filetype, row_index=0):
|
||||
def check_messages_preview(service_id, template_type, upload_id, filetype, row_index=2):
|
||||
if filetype not in ('pdf', 'png'):
|
||||
abort(404)
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@
|
||||
) %}
|
||||
{% call index_field() %}
|
||||
<span>
|
||||
{% if item.index == preview_row %}
|
||||
{% if (item.index + 2) == preview_row %}
|
||||
{{ item.index + 2 }}
|
||||
{% else %}
|
||||
<a href="{{ url_for('.check_messages', service_id=current_service.id, template_type=template.template_type, upload_id=upload_id, row_index=(item.index)) }}">{{ item.index + 2 }}</a>
|
||||
<a href="{{ url_for('.check_messages', service_id=current_service.id, template_type=template.template_type, upload_id=upload_id, row_index=(item.index + 2)) }}">{{ item.index + 2 }}</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endcall %}
|
||||
|
||||
Reference in New Issue
Block a user