Skip to content

Commit

Permalink
Changes reasons below ordering for closings
Browse files Browse the repository at this point in the history
  • Loading branch information
johnyu95 committed Jan 9, 2018
1 parent e31ada4 commit 1bd670d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 21 additions & 2 deletions app/response/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,27 @@ def _closing_email_handler(request_id, data, page, agency_name, email_template):
if content.endswith(TINYMCE_EDITABLE_P_TAG):
content = content[:-len(TINYMCE_EDITABLE_P_TAG)]
else:
reasons = [Reasons.query.filter_by(id=reason_id).one().content
for reason_id in data.getlist('reason_ids[]')]
_reasons = [Reasons.query.with_entities(Reasons.title, Reasons.content).filter_by(id=reason_id).one()
for reason_id in data.getlist('reason_ids[]')]

# Determine if a custom reason is used
# TODO: Hardcoded values; Need to figure out a better way to do this; Might be part of Agency Features at a later date.
custom_reasons = any('Denied - Reason Below' in x[0] for x in _reasons)

# In order to handle the custom logic for an empty denial reason, remove the reason from the list and pass in
# "custom_reasons" to the template so that the code is generated correctly.
if custom_reasons:
for reason in _reasons:
if reason[0] == 'Denied - Reason Below':
_reasons.remove(reason)
break

reasons = render_template(
os.path.join(current_app.config['EMAIL_TEMPLATE_DIR'], '_email_response_determinations_list.html'),
reasons=_reasons,
custom_reasons=custom_reasons
)

default_content = True
content = None
header = None
Expand Down
4 changes: 1 addition & 3 deletions app/templates/email_templates/email_response_closing.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
The {{ agency_name }} has <strong>closed</strong> your FOIL request <a href='{{ page }}'>{{ request.id }}</a>
for the following reason{% if reasons|length > 1 %}s{% endif %}:
</span>
{% for reason in reasons %}
<p><span class="mceNonEditable">&nbsp;&nbsp;&nbsp;{{ reason }}</span></p>
{% endfor %}
{{ reasons | safe }}
<span class="mceNonEditable">
You may appeal the decision to deny access to material that was redacted in part or withheld in entirety
by contacting the agency's FOIL Appeals Officer: <a
Expand Down

0 comments on commit 1bd670d

Please sign in to comment.