Skip to content

Commit

Permalink
Merge pull request #570 from CityOfNewYork/johnyu95-fdny-updates
Browse files Browse the repository at this point in the history
FDNY Updates
  • Loading branch information
johnyu95 authored Jan 22, 2024
2 parents aa7bbae + 74b09d1 commit cd1bdf6
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 16 deletions.
13 changes: 10 additions & 3 deletions app/agency/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_custom_request_form_options(agency_ein):
CustomRequestForms.repeatable,
CustomRequestForms.category,
CustomRequestForms.minimum_required).filter_by(
agency_ein=agency_ein).order_by(asc(CustomRequestForms.category), asc(CustomRequestForms.order)).all()
agency_ein=agency_ein, is_active=True).order_by(asc(CustomRequestForms.category), asc(CustomRequestForms.order)).all()
return jsonify(custom_request_forms), 200


Expand Down Expand Up @@ -175,12 +175,19 @@ def get_request_types(agency_ein):
if current_user.is_agency_active(agency_ein):
agency = Agencies.query.filter_by(ein=agency_ein).one_or_none()
if agency is not None and agency.agency_features['custom_request_forms']['enabled']:
request_types = [
active_request_types = [
(custom_request_form.form_name, custom_request_form.form_name)
for custom_request_form in CustomRequestForms.query.filter_by(
agency_ein=agency_ein
agency_ein=agency_ein, is_active=True
).order_by(asc(CustomRequestForms.category), asc(CustomRequestForms.order)).all()
]
inactive_request_types = [
(custom_request_form.form_name, "(Inactive) " + custom_request_form.form_name)
for custom_request_form in CustomRequestForms.query.filter_by(
agency_ein=agency_ein, is_active=False
).order_by(asc(CustomRequestForms.category), asc(CustomRequestForms.order)).all()
]
request_types = active_request_types + inactive_request_types
request_types.insert(0, ("", "All"))
return jsonify({"request_types": request_types}), 200

Expand Down
3 changes: 3 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ def es_update(self):
"public_title": "Private"
if self.privacy["title"]
else self.title,
"request_type": [metadata["form_name"] for metadata in self.custom_metadata.values()]
}
},
# refresh='wait_for'
Expand Down Expand Up @@ -2021,6 +2022,7 @@ class CustomRequestForms(db.Model):
category - an integer to separate different types of custom forms for an agency
minimum_required - an integer to dictates the minimum amount of fields required for a successful submission
order - an integer to determine sorting order when displaying form options in the dropdown
is_active - a boolean to determine if the custom request form is actively being used by the agency or not
"""

__tablename__ = "custom_request_forms"
Expand All @@ -2033,6 +2035,7 @@ class CustomRequestForms(db.Model):
category = db.Column(db.Integer, nullable=True)
minimum_required = db.Column(db.Integer, nullable=True)
order = db.Column(db.Integer, nullable=True)
is_active = db.Column(db.Boolean, nullable=True)

@classmethod
def populate(cls, json_name=None):
Expand Down
11 changes: 9 additions & 2 deletions app/request/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,19 @@ def __init__(self):
self.agency_user.default = current_user.get_id()

if default_agency.agency_features["custom_request_forms"]["enabled"]:
self.request_type.choices = [
active_forms = [
(custom_request_form.form_name, custom_request_form.form_name)
for custom_request_form in CustomRequestForms.query.filter_by(
agency_ein=default_agency.ein
agency_ein=default_agency.ein, is_active=True
).order_by(asc(CustomRequestForms.category), asc(CustomRequestForms.order)).all()
]
inactive_forms = [
(custom_request_form.form_name, "(Inactive) " + custom_request_form.form_name)
for custom_request_form in CustomRequestForms.query.filter_by(
agency_ein=default_agency.ein, is_active=False
).order_by(asc(CustomRequestForms.category), asc(CustomRequestForms.order)).all()
]
self.request_type.choices = active_forms + inactive_forms
self.request_type.choices.insert(0, ("", "All"))

# process form for default values
Expand Down
16 changes: 8 additions & 8 deletions app/static/js/request/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ function getRequestAgencyInstructions() {
}

// handle text change for agency instruction panel title
$('#collapse-agency-instructions').on('shown.bs.collapse', function () {
$('#agency-instructions-title-text').html("<span class=\"glyphicon glyphicon-chevron-up\"></span>&nbsp;&nbsp;Hide Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-up\"></span>");
});

$('#collapse-agency-instructions').on('hidden.bs.collapse', function () {
$('#agency-instructions-title-text').html("<span class=\"glyphicon glyphicon-chevron-down\"></span>&nbsp;&nbsp;Show Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-down\"></span>");
$("#agency-instructions-title-text").on("click", function () {
if ($("#agency-instructions-title-text").hasClass("collapsed")) {
$("#agency-instructions-title-text").html("<span class=\"glyphicon glyphicon-chevron-up\"></span>&nbsp;&nbsp;Hide Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-up\"></span>");
} else {
$("#agency-instructions-title-text").html("<span class=\"glyphicon glyphicon-chevron-down\"></span>&nbsp;&nbsp;Show Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-down\"></span>");
}
});

// variables used to handle custom forms
Expand All @@ -157,7 +157,7 @@ var currentCategory = ""; // tracks the current category that can be submitted f
var categorySelected = false; // a flag that determines if a category has been set yet or not
var categoryDividerText = "────────────────────";
var defaultInfoText = "Note: The request details written here will not be visible to the public. However, this agency may post a description of the records provided.";
var defaultCateogryInfoText = "This agency has categorized the different types of requests a user can submit and they are separated in the dropdown below. This request may have multiple submissions of only one category.";
var defaultCategoryInfoText = "This agency has categorized the different types of requests a user can submit and they are separated in the dropdown below. This request may have multiple submissions of only one category.";
var defaultCategoryWarningText = "Selecting this option will remove any existing information for other request types. Are you sure you want to change categories?";
var currentAgency = ""; // tracks the current agency that has been selected
var originalFormNames = {}; // tracks the original text for a form option
Expand Down Expand Up @@ -216,7 +216,7 @@ function getCustomRequestForms(agencyEin) {
if (data["custom_request_forms"]["category_info_text"]) {
$("#request-info-text").html(defaultInfoText.bold() + " " + data["custom_request_forms"]["category_info_text"].bold());
} else {
$("#request-info-text").html(defaultInfoText.bold() + " " + defaultCateogryInfoText.bold());
$("#request-info-text").html(defaultInfoText.bold() + " " + defaultCategoryInfoText.bold());
}
if (data["custom_request_forms"]["category_warning_text"]) {
$("#category-warning-text").html(data["custom_request_forms"]["category_warning_text"]);
Expand Down
2 changes: 1 addition & 1 deletion app/templates/_nyc_gov_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<button class="ico-search">Search</button>
</form>
<div class="copyright">
<p>City of New York. 2023 All Rights Reserved,</p>
<p>City of New York. 2024 All Rights Reserved,</p>

<p>NYC is a trademark and service mark of the City of New York</p>

Expand Down
2 changes: 1 addition & 1 deletion data/agencies.json

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion data/custom_request_forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
},
{
"agency_ein": "0057",
"form_name": "911 Call Report (CAD) (NOT Ambulance Call Report/ Pre-Hospital Care Report)",
"form_name": "911 Call Report (CAD) (NOT Ambulance Call Report/Pre-Hospital Care Report)",
"form_description": "<p>Please note this Request Type should be used for those requesting 911 Call Report not Ambulance Reports. Instructions for obtaining Ambulance Call Reports can be found under Agency Instructions above. <strong>Please complete all the required fields below.</strong></p>",
"field_definitions": [
{
Expand Down Expand Up @@ -829,6 +829,40 @@
"category": "1",
"minimum_required": "0"
},
{
"agency_ein": "0057",
"form_name": "Multi-Part Request",
"form_description": "For requests consisting of multiple items (even if listed individually on this page), please choose this option.",
"field_definitions": [
{
"Submission Method": {
"type": "radio",
"name": "fdny-form10-field1",
"values": [
"In Person/At FDNY",
"Online/At Home"
],
"help_text": "Please select an option.",
"required": true,
"error_message": "<span class=\"glyphicon glyphicon-exclamation-sign\"></span>&nbsp;<strong>Error, Submission Method is required.</strong> Please select an option."
}
},
{
"Description of Records": {
"type": "textarea",
"name": "fdny-form10-field2",
"required": true,
"error_message": "<span class=\"glyphicon glyphicon-exclamation-sign\"></span>&nbsp;<strong>Error, Description of Records is required.</strong> Please provide a short description.",
"max_length": 5000,
"character_counter": true,
"help_text": "Please provide a short description of the records you are requesting."
}
}
],
"repeatable": "1",
"category": "1",
"minimum_required": "0"
},
{
"agency_ein": "0056",
"form_name": "Complaint Report",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Add is_active Column to Custom Request Forms
Revision ID: 0fddd88d0a1d
Revises: 5e65ea2c1a5a
Create Date: 2023-11-03 19:48:08.761832
"""

# revision identifiers, used by Alembic.
revision = '0fddd88d0a1d'
down_revision = '5e65ea2c1a5a'

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('custom_request_forms', sa.Column('is_active', sa.Boolean(), nullable=True))
# ### end Alembic commands ###


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

0 comments on commit cd1bdf6

Please sign in to comment.