Skip to content

Commit

Permalink
Added need_additional_details column to Reasons table
Browse files Browse the repository at this point in the history
  • Loading branch information
johnyu95 committed Apr 27, 2021
1 parent 0967097 commit 25e093a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 10 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
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 25e093a

Please sign in to comment.