Skip to content

Commit

Permalink
Merge pull request #541 from CityOfNewYork/johnyu95-main-additional-d…
Browse files Browse the repository at this point in the history
…etails-reasons

Added need_additional_details column to Reasons table
  • Loading branch information
johnyu95 authored Apr 28, 2021
2 parents 0967097 + b66b12f commit 1b7655a
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ class Reasons(db.Model):
title = db.Column(db.String, nullable=False)
content = db.Column(db.String, nullable=False)
has_appeals_language = db.Column(db.Boolean, default=True)
need_additional_details = db.Column(db.Boolean, default=False)

@classmethod
def populate(cls):
Expand Down
28 changes: 21 additions & 7 deletions app/response/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,21 +1566,28 @@ def _denial_email_handler(request_id, data, page, agency_name, email_template):
else:
description_hidden_by_default = False

_reasons = [Reasons.query.with_entities(Reasons.title, Reasons.content, Reasons.has_appeals_language).filter_by(
id=reason_id).one()
_reasons = [Reasons.query.with_entities(Reasons.title,
Reasons.content,
Reasons.has_appeals_language,
Reasons.type,
Reasons.need_additional_details).filter_by(id=reason_id).one()
for reason_id in data.getlist('reason_ids[]')]

has_appeals_language = False
need_additional_details = False
custom_reasons = False

reasons_text = []
# Render the jinja for the reasons content
for reason in _reasons:
if reason.need_additional_details:
need_additional_details = True
if reason.title == 'Denied - Reason Below':
custom_reasons = True
continue
if reason.has_appeals_language:
has_appeals_language = True

reasons_text.append(render_template_string(reason.content, user=point_of_contact_user))

reasons = render_template(
Expand Down Expand Up @@ -1609,7 +1616,8 @@ def _denial_email_handler(request_id, data, page, agency_name, email_template):
custom_request_forms_enabled=custom_request_forms_enabled,
description_hidden_by_default=description_hidden_by_default,
has_appeals_language=has_appeals_language),
"header": header
"header": header,
"showAdditionalDetailsWarning": need_additional_details
}), 200


Expand Down Expand Up @@ -1642,18 +1650,23 @@ def _closing_email_handler(request_id, data, page, agency_name, email_template):
description_hidden_by_default = False

header = CONFIRMATION_EMAIL_HEADER_TO_REQUESTER
_reasons = [Reasons.query.with_entities(Reasons.title, Reasons.content, Reasons.has_appeals_language,
Reasons.type).filter_by(
id=reason_id).one()
_reasons = [Reasons.query.with_entities(Reasons.title,
Reasons.content,
Reasons.has_appeals_language,
Reasons.type,
Reasons.need_additional_details).filter_by(id=reason_id).one()
for reason_id in data.getlist('reason_ids[]')]

has_appeals_language = False
need_additional_details = False
custom_reasons = False
denied = False

reasons_text = []
# Render the jinja for the reasons content
for reason in _reasons:
if reason.need_additional_details:
need_additional_details = True
if reason.title == 'Denied - Reason Below':
custom_reasons = True
continue
Expand Down Expand Up @@ -1684,7 +1697,8 @@ def _closing_email_handler(request_id, data, page, agency_name, email_template):
custom_request_forms_enabled=custom_request_forms_enabled,
description_hidden_by_default=description_hidden_by_default,
has_appeals_language=has_appeals_language),
"header": header
"header": header,
"showAdditionalDetailsWarning": need_additional_details
}), 200


Expand Down
3 changes: 0 additions & 3 deletions app/templates/main/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
{% endblock %}
{% block content %}
<div class="container col-sm-12">
<div class="alert alert-info home-page-description">Don’t forget the census. Take a few minutes to help NYC get its fair share of
federal funds. Go to <a href="https://my2020census.gov/">my2020census.gov</a> to complete the census.
</div>
<div class=" col-sm-8" role="main">
<h1 class="home-page-header">Welcome to NYC Government’s home for filing Freedom of Information Law (FOIL)
requests.
Expand Down
3 changes: 3 additions & 0 deletions app/templates/response/add_closing.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@

<div class="third" hidden>
<h4 id="edit-body-header">Edit Email Body</h4>
<div id="additional-details-warning" class="alert alert-warning hidden" role="alert">
<strong>Please provide additional details when selecting this reason.</strong>
</div>
<div id="closing-editor" class="form-group">
<div class="email-content-hidden" hidden></div>
<textarea title="closing-body" name="closing-body"
Expand Down
4 changes: 4 additions & 0 deletions app/templates/response/add_closing.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
tinyMCE.get("closing-body").setContent(emailContent.html());
editor.unblock();
next3.prop('disabled', false);
if (data.showAdditionalDetailsWarning) {
$('#additional-details-warning').removeClass('hidden');
}
}
});
edit_body_header.html("Edit Email Body");
Expand Down Expand Up @@ -220,6 +223,7 @@
prev3.click(function() {
third.hide();
second.show();
$('#additional-details-warning').addClass('hidden');
});

prev4.click(function () {
Expand Down
3 changes: 3 additions & 0 deletions app/templates/response/add_denial.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
</div>
<div class="third" hidden>
<h4 id="edit-body-header">Edit Email Body</h4>
<div id="additional-details-warning" class="alert alert-warning hidden" role="alert">
<strong>Please provide additional details when selecting this reason.</strong>
</div>
<div id="denial-editor" class="form-group">
<div class="email-content-hidden" hidden></div>
<textarea title="denial-body" name="denial-body"
Expand Down
4 changes: 4 additions & 0 deletions app/templates/response/add_denial.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
tinyMCE.get("denial-body").setContent(emailContent.html());
editor.unblock();
next3.prop('disabled', false);
if (data.showAdditionalDetailsWarning) {
$('#additional-details-warning').removeClass('hidden');
}
}
});
edit_body_header.html("Edit Email Body");
Expand Down Expand Up @@ -220,6 +223,7 @@
prev3.click(function () {
third.hide();
second.show();
$('#additional-details-warning').addClass('hidden');
});

prev4.click(function () {
Expand Down
2 changes: 1 addition & 1 deletion data/reasons.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"type","title","content","agency_ein","has_appeals_language"
"closing","Fulfilled in Whole","Your request under the Freedom of Information Law (FOIL) has been reviewed and the documents you requested have been posted on the OpenRecords portal.","","False"
"closing","Fulfilled in Part","Your request under the Freedom of Information Law (FOIL) has been reviewed and is granted in part and denied in part because some of the records or portions of records are disclosable and others are exempt from disclosure under FOIL.","","True"
"closing","Fulfilled in Part","Your request under the Freedom of Information Law (FOIL) is denied in part and granted in part for the reasons stated below.","","True"
"closing","Fulfilled via Email","Your request under the Freedom of Information Law (FOIL) has been fulfilled and the documents you requested have been emailed to you.","","True"
"closing","Fulfilled via Fax","Your request under the Freedom of Information Law (FOIL) has been fulfilled and the documents you requested have been faxed to you.","","True"
"closing","Fulfilled via Mail","Your request under the Freedom of Information Law (FOIL) has been been fulfilled and the documents you requested have been mailed to you. Please allow 7 - 10 days for receipt.","","True"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Added need_additional_details to Reasons
Revision ID: 5bb24f92ca63
Revises: afde33bde2e0
Create Date: 2021-04-20 21:14:10.825678
"""

# revision identifiers, used by Alembic.
revision = '5bb24f92ca63'
down_revision = 'afde33bde2e0'

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('reasons', sa.Column('need_additional_details', sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('reasons', 'need_additional_details')
# ### end Alembic commands ###

0 comments on commit 1b7655a

Please sign in to comment.