Skip to content

Commit

Permalink
Feature Request: Update Community Response Form (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanetteobr authored Jan 14, 2025
1 parent e72f915 commit ff01efb
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 50 deletions.
8 changes: 3 additions & 5 deletions apps/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,13 @@ def community_response_notification_data():
return dict(
first_name="SpongeBob",
last_name="SquarePants",
organization_name="Krabby Patty Organization",
title="Fry Cook",
email_address="spongebob@phila.gov",
cell_phone="(215)333-4567",
organization_street_address="831 Bottom Feeder Lane",
organization_po_box="1",
organization_name="Krabby Patty Organization",
organization_type="Arts and Culture",
organization_zip_code=98765,
organization_zip_codes_served="98765,99999",
organization_community_members_served="All of these",
organization_mision_statement="To make the best Krabby Patties",
)


Expand Down
2 changes: 0 additions & 2 deletions apps/notifications/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ class CommunityResponseSubscriberAdmin(ExportMixin, admin.ModelAdmin):
list_display = (
"full_name",
"organization_name",
"title",
)
list_filter = ("organization_community_members_served",)
search_fields = (
"first_name",
"last_name",
"organization_name",
"title",
"email_address",
)

Expand Down
19 changes: 4 additions & 15 deletions apps/notifications/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,18 @@ def about_you_fields(self):
about_you_field_names = [
"first_name",
"last_name",
"organization_name",
"title",
]
return [self[name] for name in self.fields if name in about_you_field_names]

def contact_information_fields(self):
contact_info_field_names = [
"email_address",
"cell_phone",
]
return [self[name] for name in self.fields if name in contact_info_field_names]
return [self[name] for name in self.fields if name in about_you_field_names]

def organization_info_fields(self):
organization_info_field_names = [
"organization_street_address",
"organization_po_box",
"organization_name",
"organization_type",
"organization_zip_code",
"organization_zip_codes_served",
"organization_community_members_served",
"organization_mission_statement",
]
return [
self[name] for name in self.fields if name in organization_info_field_names
Expand All @@ -126,10 +119,6 @@ def form_sections(self):
"""Return the sections of this form, including a header, and the fields in the section."""
return [
{"header": "About You", "fields": self.about_you_fields()},
{
"header": "Contact Information",
"fields": self.contact_information_fields(),
},
{
"header": "Organization Information",
"fields": self.organization_info_fields(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Generated by Django 4.2.14 on 2025-01-02 19:57

from django.db import migrations, models

import phonenumber_field.modelfields


class Migration(migrations.Migration):

dependencies = [
("notifications", "0008_coderedcodebluesubscriber_fields_are_optional"),
]

operations = [
migrations.RemoveField(
model_name="communityresponsesubscriber",
name="organization_po_box",
),
migrations.RemoveField(
model_name="communityresponsesubscriber",
name="organization_street_address",
),
migrations.RemoveField(
model_name="communityresponsesubscriber",
name="organization_zip_codes_served",
),
migrations.RemoveField(
model_name="communityresponsesubscriber",
name="title",
),
migrations.AddField(
model_name="communityresponsesubscriber",
name="organization_mission_statement",
field=models.CharField(
blank=True, max_length=255, verbose_name="Mission Statement"
),
),
migrations.AddField(
model_name="communityresponsesubscriber",
name="organization_type",
field=models.CharField(
choices=[
("Arts and Culture", "Arts and Culture"),
("Block Captain", "Block Captain"),
(
"Civic Engagement/Elected Official",
"Civic Engagement/Elected Official",
),
(
"Disabilities and Access and Functional Needs",
"Disabilities and Access and Functional Needs",
),
(
"Education (Schools/Colleges/Universities)",
"Education (Schools/Colleges/Universities)",
),
("Free Library of Philadelphia", "Free Library of Philadelphia"),
("General Community Services", "General Community Services"),
("Healthcare", "Healthcare"),
(
"Immigrant/Refugee/Communities that speak languages other than English",
"Immigrant/Refugee/Communities that speak languages other than English",
),
("Live Bird Market", "Live Bird Market"),
("Mental/Behavioral Health", "Mental/Behavioral Health"),
("Older Adults", "Older Adults"),
("Housing/Homeless Services", "Housing/Homeless Services"),
("RCO/CDC/NAC", "RCO/CDC/NAC"),
("Recreational", "Recreational"),
("Religious/Faith-based", "Religious/Faith-based"),
("Workers", "Workers"),
("Youth", "Youth"),
("Unaffiliated Community Leader", "Unaffiliated Community Leader"),
],
default="",
max_length=255,
verbose_name="Organization Type*",
),
),
migrations.AlterField(
model_name="communityresponsesubscriber",
name="cell_phone",
field=phonenumber_field.modelfields.PhoneNumberField(
blank=True, max_length=128, region=None, verbose_name="Cell Phone"
),
),
migrations.AlterField(
model_name="communityresponsesubscriber",
name="first_name",
field=models.CharField(
blank=True, max_length=255, verbose_name="First Name"
),
),
migrations.AlterField(
model_name="communityresponsesubscriber",
name="last_name",
field=models.CharField(
blank=True, max_length=255, verbose_name="Last Name"
),
),
]
109 changes: 90 additions & 19 deletions apps/notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,50 +339,121 @@ class COMMUNITY_MEMBERS_CHOICES(models.TextChoices):
"All of these",
)

class ORGANIZATION_TYPE_CHOICES(models.TextChoices):
ARTS_CULTURE = (
"Arts and Culture",
"Arts and Culture",
)
BLOCK_CAPTAIN = ("Block Captain",)
CIVIC_ENGAGEMENT_ELECTED_OFFICIAL = (
"Civic Engagement/Elected Official",
"Civic Engagement/Elected Official",
)
DISABILITIES_ACCESS_FUNCTIONAL_NEEDS = (
"Disabilities and Access and Functional Needs",
"Disabilities and Access and Functional Needs",
)
EDUCATION = (
"Education (Schools/Colleges/Universities)",
"Education (Schools/Colleges/Universities)",
)
FREE_LIBRARY_OF_PHILADELPHIA = (
"Free Library of Philadelphia",
"Free Library of Philadelphia",
)
GENERAL_COMMUNITY_SERVICES = (
"General Community Services",
"General Community Services",
)
HEALTHCARE = (
"Healthcare",
"Healthcare",
)
IMMIGRANT_REFUGEE_COMMUNITIES = (
"Immigrant/Refugee/Communities that speak languages other than English",
"Immigrant/Refugee/Communities that speak languages other than English",
)
LIVE_BIRD_MARKET = (
"Live Bird Market",
"Live Bird Market",
)
MENTAL_BEHAVIORAL_HEALTH = (
"Mental/Behavioral Health",
"Mental/Behavioral Health",
)
OLDER_ADULTS = (
"Older Adults",
"Older Adults",
)
HOUSING_HOMELESS_SERVICES = (
"Housing/Homeless Services",
"Housing/Homeless Services",
)
RCO_CDC_NAC = (
"RCO/CDC/NAC",
"RCO/CDC/NAC",
)
RECREATIONAL = (
"Recreational",
"Recreational",
)
RELIGIOUS_FAITH_BASED = (
"Religious/Faith-based",
"Religious/Faith-based",
)
WORKERS = (
"Workers",
"Workers",
)
YOUTH = (
"Youth",
"Youth",
)
UNAFFILIATED_COMMUNITY_LEADER = (
"Unaffiliated Community Leader",
"Unaffiliated Community Leader",
)

first_name = models.CharField(
"First Name*",
"First Name",
max_length=255,
default="",
blank=True,
)
last_name = models.CharField(
"Last Name*",
"Last Name",
max_length=255,
default="",
blank=True,
)
organization_name = models.CharField(
"Organization Name*",
max_length=255,
default="",
)
title = models.CharField(
"Title/Position*",
max_length=255,
default="",
)

email_address = models.EmailField("Email Address*")
cell_phone = PhoneNumberField("Cell Phone*")

organization_street_address = models.CharField(
"Street Address of Organization*", max_length=255
)
organization_po_box = models.CharField(
"Organization PO Box", max_length=255, blank=True
cell_phone = PhoneNumberField("Cell Phone", blank=True)
organization_type = models.CharField(
"Organization Type*",
max_length=255,
choices=ORGANIZATION_TYPE_CHOICES.choices,
default="",
)
organization_zip_code = models.CharField(
"Zip Code of Organization*",
max_length=10,
default="",
validators=[zipcode_validator],
)
organization_zip_codes_served = models.CharField(
"Zip Codes Served by Your Organization*", max_length=255, default=""
)
organization_community_members_served = models.CharField(
"Community Members Served by Your Organization*",
max_length=100,
choices=COMMUNITY_MEMBERS_CHOICES.choices,
)
organization_mission_statement = models.CharField(
"Mission Statement",
max_length=255,
blank=True,
)

class Meta:
verbose_name_plural = "Community Response Subscribers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ <h5 class="is-size-5 pt-2 pl-4">
<h6 class="is-size-6 py-2"><strong>{{ form_section.header }}</strong></h6>
{% for field in form_section.fields %}
<div class="py-2 field form-sections-hip">
<label class="label is-block is-size-7" for="{{ field.id_for_label }}">{{ field.label }}</label>
<label class="label is-block is-size-7" for="{{ field.id_for_label }}">
{% if "*" in field.label %}
{{ field.label|slice:":-1" }}<span class="required">*</span>
{% else %}
{{ field.label }}
{% endif %}
</label>
<div class="control">
{% if field|widget_class == "Select" %}
<div class="select is-small">
Expand Down
10 changes: 4 additions & 6 deletions apps/notifications/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ class Meta:

first_name = factory.faker.Faker("first_name")
last_name = factory.faker.Faker("last_name")
organization_name = factory.faker.Faker("company")
title = factory.faker.Faker("job")
email_address = factory.faker.Faker("email")
cell_phone = factory.faker.Faker("phone_number")
organization_street_address = factory.faker.Faker("street_address")
organization_po_box = random.randint(0, 9999)
organization_name = factory.faker.Faker("company")
organization_zip_code = factory.faker.Faker("postcode")
organization_zip_codes_served = ", ".join(
[str(random.randint(11111, 99999)) for i in range(0, random.randint(0, 5))]
organization_type = random.choice(
[str(t) for t in CommunityResponseSubscriber.ORGANIZATION_TYPE_CHOICES]
)
organization_community_members_served = random.choice(
[str(l) for l in CommunityResponseSubscriber.COMMUNITY_MEMBERS_CHOICES]
)
organization_mission_statement = factory.faker.Faker("text")


class InternalEmployeeAlertSubscriberFactory(factory.django.DjangoModelFactory):
Expand Down
4 changes: 2 additions & 2 deletions apps/notifications/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ def test_community_response_notification_signup_invalid_data(
):
"""POSTting invalid data shows errors to the user."""
data = community_response_notification_data.copy()
data.pop("first_name")
data.pop("email_address")

response = client.post(reverse("community_notifications_signup"), data)

assert HTTPStatus.OK == response.status_code
assert {"first_name": ["This field is required."]} == response.context[
assert {"email_address": ["This field is required."]} == response.context[
"form"
].errors

Expand Down
4 changes: 4 additions & 0 deletions hip/static/styles/includes/notification_signup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
@include headers;
@include paragraphs;
}

.required {
color: red;
}

0 comments on commit ff01efb

Please sign in to comment.