Skip to content

Commit

Permalink
Merge pull request #671 from Gary-Community-Ventures/dev
Browse files Browse the repository at this point in the history
12/13/2024
  • Loading branch information
CalebPena authored Dec 13, 2024
2 parents 72af13d + 7a6e992 commit 2bc7fc8
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 29 deletions.
2 changes: 1 addition & 1 deletion configuration/white_labels/co.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_white_label(self) -> WhiteLabel:
"_label": "referralOptions.fircsummitresourcecenter",
"_default_message": "FIRC Summit Resource Center",
},
"ccig": "Colorado Community Insight Group",
"ccig": "Colorado Design Insight Group",
"eaglecounty": "Eagle County",
"searchEngine": {"_label": "referralOptions.searchEngine", "_default_message": "Google or other search engine"},
"socialMedia": {"_label": "referralOptions.socialMedia", "_default_message": "Social Media"},
Expand Down
10 changes: 1 addition & 9 deletions integrations/management/commands/health_check.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import Optional
from django.core.management.base import BaseCommand
from django.conf import settings
from decouple import config
from hubspot import HubSpot
from hubspot.crm.contacts.exceptions import ForbiddenException
from django.db.models import Q
from authentication.models import User
from integrations.models import Link
from programs.models import Navigator, Program, TranslationOverride, UrgentNeed
Expand Down Expand Up @@ -57,13 +55,7 @@ def _cant_read_hubspot(self) -> bool:
return False

def _no_pii_in_db(self) -> bool:
users = User.objects.filter(is_staff=False).filter(
Q(first_name__isnull=False)
| Q(last_name__isnull=False)
| Q(cell__isnull=False)
| Q(email__isnull=False)
| Q(external_id__isnull=True)
)
users = User.objects.filter(is_staff=False).filter(external_id__isnull=True)

if len(users) > 0:
return False
Expand Down
2 changes: 1 addition & 1 deletion integrations/services/communications/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _cell_client(self):
return Client(self.cell_account_sid, self.cell_auth_token)

def _generate_link(self):
return f"{self.front_end_domain}/{self.screen.uuid}/results"
return f"{self.front_end_domain}/{self.screen.white_label.code}/{self.screen.uuid}/results"

def log(self, type: Literal["emailScreen", "textScreen"]):
self.screen.last_email_request_date = timezone.now()
Expand Down
36 changes: 20 additions & 16 deletions programs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["ProgramCategory"]) -> "ProgramCategory":
return Model.objects.new_program_category(external_name, "housing")
return Model.objects.new_program_category("_default", external_name, "housing")


class ProgramCategory(models.Model):
Expand Down Expand Up @@ -229,7 +229,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["Document"]) -> "Document":
return Model.objects.new_document(external_name)
return Model.objects.new_document("_default", external_name)


class Document(models.Model):
Expand Down Expand Up @@ -397,7 +397,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["Program"]) -> "Program":
return Model.objects.new_program(external_name)
return Model.objects.new_program("_default", external_name)


# This model describes all of the benefit programs available in the screener
Expand Down Expand Up @@ -615,11 +615,11 @@ def from_model_data(self, data: DataType):
for category in data["categories"]:
try:
cat_instance = UrgentNeedCategory.objects.get(name=category["name"])
cat_instance.white_label = white_label
cat_instance.save()
except UrgentNeedCategory.DoesNotExist:
cat_instance = UrgentNeedFunction.objects.create(name=category["name"])
cat_instance = UrgentNeedCategory.objects.create(name=category["name"], white_label=white_label)

cat_instance.white_label = white_label
cat_instance.save()
categories.append(cat_instance)
need.type_short.set(categories)

Expand All @@ -637,7 +637,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["UrgentNeed"]) -> "UrgentNeed":
return Model.objects.new_urgent_need(external_name, None)
return Model.objects.new_urgent_need("_default", external_name, None)


class UrgentNeed(models.Model):
Expand Down Expand Up @@ -704,7 +704,7 @@ class NavigatorManager(models.Manager):
)
no_auto_fields = ("assistance_link",)

def new_navigator(self, white_label: str, name: str, phone_number: str):
def new_navigator(self, white_label: str, name: str, phone_number: Optional[str] = None):
translations = {}
for field in self.translated_fields:
translations[field] = Translation.objects.add_translation(
Expand Down Expand Up @@ -779,11 +779,11 @@ def from_model_data(self, data: DataType):
for county in data["counties"]:
try:
county_instance = County.objects.get(name=county["name"])
county_instance.white_label = white_label
county_instance.save()
except County.DoesNotExist:
county_instance = County.objects.create(name=county["name"])
county_instance = County.objects.create(name=county["name"], white_label=white_label)

county_instance.white_label = white_label
county_instance.save()
counties.append(county_instance)
navigator.counties.set(counties)

Expand All @@ -808,7 +808,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["Navigator"]) -> "Navigator":
return Model.objects.new_navigator(external_name, None)
return Model.objects.new_navigator("_default", external_name, None)


class Navigator(models.Model):
Expand Down Expand Up @@ -909,8 +909,10 @@ def from_model_data(self, data: DataType):
for county in data["counties"]:
try:
county_instance = County.objects.get(name=county["name"])
county_instance.white_label = white_label
county_instance.save()
except County.DoesNotExist:
county_instance = County.objects.create(name=county["name"])
county_instance = County.objects.create(name=county["name"], white_label=white_label)
counties.append(county_instance)
warning.counties.set(counties)

Expand All @@ -925,7 +927,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["WarningMessage"]) -> "WarningMessage":
return Model.objects.new_warning("_show", external_name)
return Model.objects.new_warning("_default", "_show", external_name)


class WarningMessage(models.Model):
Expand Down Expand Up @@ -1055,8 +1057,10 @@ def from_model_data(self, data: DataType):
for county in data["counties"]:
try:
county_instance = County.objects.get(name=county["name"])
county_instance.white_label = white_label
county_instance.save()
except County.DoesNotExist:
county_instance = County.objects.create(name=county["name"])
county_instance = County.objects.create(name=county["name"], white_label=white_label)
counties.append(county_instance)
translation_override.counties.set(counties)

Expand All @@ -1067,7 +1071,7 @@ def from_model_data(self, data: DataType):

@classmethod
def create_instance(cls, external_name: str, Model: type["TranslationOverride"]) -> "TranslationOverride":
return Model.objects.new_translation_override("_show", "", external_name)
return Model.objects.new_translation_override("_default", "_show", "", external_name)


class TranslationOverride(models.Model):
Expand Down
2 changes: 2 additions & 0 deletions programs/programs/nc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from .nc_aca.calculator import ACASubsidiesNC
from .medicaid.emergency_medicaid.calculator import EmergencyMedicaid
from .sun_bucks.calculator import SunBucks

from ..calc import ProgramCalculator

nc_calculators: dict[str, type[ProgramCalculator]] = {
"nc_aca": ACASubsidiesNC,
"nc_emergency_medicaid": EmergencyMedicaid,
"sunbucks": SunBucks,
}
4 changes: 2 additions & 2 deletions programs/programs/nc/pe/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class NcMedicaid(Medicaid):
"YOUNG_ADULT": 512, # * 12 = 6146, Medicaid Expansion Adults
"PARENT": 0,
"SSI_RECIPIENT": 0,
"AGED": 1519, # * 12 = 13035, Medicaid for the Aged
"DISABLED": 1086, # * 12 = 18227, Medicaid for the Disabled
"AGED": 1086, # * 12 = 13035, Medicaid for the Aged
"DISABLED": 1519, # * 12 = 18227, Medicaid for the Disabled
}

pe_inputs = [
Expand Down
Empty file.
29 changes: 29 additions & 0 deletions programs/programs/nc/sun_bucks/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from programs.programs.calc import MemberEligibility, ProgramCalculator, Eligibility
import programs.programs.messages as messages


class SunBucks(ProgramCalculator):
member_amount = 1440
min_age = 7
max_age = 16
fpl_percent = 1.85
dependencies = ["age", "insurance", "income_amount", "income_frequency", "household_size"]

def household_eligible(self, e: Eligibility):
# Income
fpl = self.program.fpl
income_limit = int(self.fpl_percent * fpl.get_limit(self.screen.household_size))
gross_income = int(self.screen.calc_gross_income("yearly", ["all"]))

# Must not have the following benefits
e.condition(not self.screen.has_benefit("snap"), messages.must_not_have_benefit("snap"))
e.condition(not self.screen.has_benefit("tanf"), messages.must_not_have_benefit("tanf"))
e.condition(not self.screen.has_benefit("medicaid"), messages.must_not_have_benefit("medicaid"))

e.condition(gross_income < income_limit, messages.income(gross_income, income_limit))

def member_eligible(self, e: MemberEligibility):
member = e.member

# age eligibility
e.condition(SunBucks.min_age <= member.age <= SunBucks.max_age)
18 changes: 18 additions & 0 deletions screener/migrations/0089_screen_has_sunbucks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-12-03 18:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("screener", "0088_alter_screen_white_label"),
]

operations = [
migrations.AddField(
model_name="screen",
name="has_sunbucks",
field=models.BooleanField(blank=True, default=False, null=True),
),
]
13 changes: 13 additions & 0 deletions screener/migrations/0090_merge_20241213_1726.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 4.2.15 on 2024-12-13 17:26

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("screener", "0089_screen_has_sunbucks"),
("screener", "0089_whitelabel_cms_method"),
]

operations = []
3 changes: 3 additions & 0 deletions screener/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Screen(models.Model):
has_tanf = models.BooleanField(default=False, blank=True, null=True)
has_wic = models.BooleanField(default=False, blank=True, null=True)
has_snap = models.BooleanField(default=False, blank=True, null=True)
has_sunbucks = models.BooleanField(default=False, blank=True, null=True)
has_lifeline = models.BooleanField(default=False, blank=True, null=True)
has_acp = models.BooleanField(default=False, blank=True, null=True)
has_eitc = models.BooleanField(default=False, blank=True, null=True)
Expand Down Expand Up @@ -280,8 +281,10 @@ def has_benefit(self, name_abbreviated):
"nc_tanf": self.has_tanf,
"co_tanf": self.has_tanf,
"wic": self.has_wic,
"co_wic": self.has_wic,
"nc_wic": self.has_wic,
"snap": self.has_snap,
"sunbucks": self.has_sunbucks,
"co_snap": self.has_snap,
"nc_snap": self.has_snap,
"lifeline": self.has_lifeline,
Expand Down
1 change: 1 addition & 0 deletions screener/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Meta:
"has_tanf",
"has_wic",
"has_snap",
"has_sunbucks",
"has_lifeline",
"has_acp",
"has_eitc",
Expand Down

0 comments on commit 2bc7fc8

Please sign in to comment.