Programs - Gary-Community-Ventures/benefits-api GitHub Wiki
Programs
Programs are the main thing that is displayed to the user on the results page. Text like the name, description, and apply link are handled in the admin, while rules for eligibility and value are handled in code. There are 2 methods for calculating eligibility and value.
- Write our own rules
- Use Policy Engine
This section will discuss programming the rules for a program, and how add/edit a program in the admin.
Admin
The Admin allows non developers to edit program information without the help of a developer.
Creating a program
- Go to the "Translation Admin".
- Go to "Programs".
- Click "Add New".
- Enter the "Name abbreviated" that corresponds to the calculator for the program (you may need to ask a developer for this).
-
Add all of the text for the program by clicking the links, and replacing the placeholder text with the desired text.
- Translation documentation
- Documentation for each field can be found in the Translation admin section.
-
Click "Edit in Main Admin"
- Update the fields
- Documentation for each field can be found in the Main Admin section.
Updating a program
Translation admin
To edit any of the text in the translation admin:
- Go to the "Translation Admin".
- Go to "Programs".
- Search the name of the program.
- Select "Go to".
- Select the field to update.
The translations can also be accessed through the main admin by clicking on the hamburger menu in the "Translate" column
Main Admin
- Go to "Programs.
- Search the name of the program.
- Click on the name.
- Update the fields.
What things mean
Translation admin
The following translated text can be edited in the translation admin:
- Name: The name that is displayed to the user
- Description: The description that is displayed to the user
- Short description: Deprecated
- Learn more link: Deprecated
- Apply button link: The link that will take the user to the application. This is a translation, because there can be different links for different languages
- Value type: Deprecated
- Estimated delivery time: Deprecated
- Estimated application time: The estimated amount of time it would take for the user to apply
- Category: The category that this benefit is in. If it is the same as another program, then those programs will be grouped together
- Website description: The description on the page that lists all of the MFB benefits
- Estimated value: If this value is not empty, then the program value will be set to this value. Can be text
Main admin
The following things can be edited in the main admin:
- Name abbreviated: The rules to use
- External name: Syncs programs across environments
- Legal status required: The citizenship statuses that are eligible for this program
- Documents: The documents that are needed to apply for this program
- Active: Only active programs are showed to the user
- Low confidence: Display a flag to the user that reads "Low Confidence"
- Fpl: The year that the program should be calculated for. For the custom calculators, this is used for choosing what FPL year to use. For the Policy Engine calculators, this is used to determine which period to use.
Other program related features
The following can be added to a program.
- Navigator: An organization that will help the user apply the program.
- Warning message: An additional message to display to the user under certain conditions.
- Translation override: Override translated text of the program under certain conditions.
Development
Base classes are provided for both writing custom rules, and fetching rules from Policy Engine.
Custom rules
Create a new folder with the name of the new program in one of the state (or federal) folders in /programs/programs/. In that folder add the files __init__.py
and calculator.py
.
To create a program calculator in the calculator.py
, create a new class that inherits from ProgramCalculator
in /programs/programs/calc.py.
The following methods and attributes can be overridden:
household_eligible
(method): Eligibility rules that apply to the whole household.- An
Eligibility
object is passed as a parameter. To add a condition, calle.condition(bool)
. A program will be marked as eligible if all of the conditions areTrue
. There is an additional condition that at least one household member must be eligible.
- An
member_eligible
(method): Eligibility rules that apply to individual household members.- An
MemberEligibility
object is passed as a parameter. To add a condition, calle.condition(bool)
. A member will be marked as eligible if all of the conditions areTrue
.
- An
household_value
(method): The household value of the program if eligible.member_value
(method): The value of the program for each eligible household member.amount
(attribute): The value returned byhousehold_value
if it is not overridden.member_amount
(attribute): The value returned bymember_value
if it is not overridden.dependencies
(attribute): A list of fields needed so that the program does not through an error when run. If the screen is missing one of these fields, then the program will be skipped. Syntax:Screen
andHouseholdMember
fields:{field}
IncomeStream
fields:income_{field}
Expense
fields:expense_{field}
Import and add the calculator to the dictionary in the __init__.py
file in the corresponding state folders /programs/programs/. The key used is matched to the name_abbreviated
of a program.
Policy Engine rules
TODO
Brief technical overview
- Program calculators are in the state (and federal) folders in /programs/programs.
- The
ProgramCalculator
base class is located in /programs/programs/calc.py. - The calculators are run in /programs/models.py in the
eligibility
method on theProgram
model. Program
is used ineligibility_results
to return the API response for the results screen.- How programs are imported/exported is controlled by the
ProgramDataController
class in /programs/models.py.