-
Notifications
You must be signed in to change notification settings - Fork 23
Adding Counties or Fields
Limited sets of the production data are committed to the repository and loaded into each environment upon release (including test, review, staging, and production). We also have tests that rely on some of these fixtures. Additionally, there are some things we can currently only do by modifying the fixture files, like adding a county or organization (see steps above).
For this reason, we should treat our committed fixtures as the source of truth and try to edit them (and then load them into production) instead of editing information in the admin interface. [Note: This does not include users—see below]
If we suspect that any of these have been edited in the Django admin, we should update them using the steps below as soon as possible.
Here are the essential fixtures loaded when manage.py load_essential_data
is run:
-
intake/fixtures/county.json
- County in Django admin -
intake/fixtures/template_options.json
- not in Django admin -
user_accounts/fixtures/organizations.json
- Organization in Django admin -
user_accounts/fixtures/addresses.json
- 'Addresses' in edit view for a specific Organization -
user_accounts/fixtures/groups.json
- Group in Django admin, used to manage permissions
If we need to update one of the above models in the production database (County, Organization, or Group), update their corresponding JSON file above and add/edit/delete any related tests. Commit and push.
We run the load_essential_data
as part of the Heroku release on all environments. This Django loaddata
command. This means that any updates to existing models made in the database that are not reflected in the fixtures will be wiped out on next deploy. If we suspect that data has been modified in the Django interface, we should update the fixtures via steps below before the next deploy.
For more information about fixtures and their intended use, see the Django docs.
Sometimes edits to database objects are made in the admin interface, which causes our committed fixtures (like
user_accounts/fixtures/organizations.json
) to become out-of-date. If we suspect this as happened, we should fetch and commit the latest fixtures to our local repository before the next deploy.
To do so, run:
export $(lpass show --notes "CMR Intake .env.prod" | xargs) && DJANGO_SETTINGS_MODULE=project.settings.prod make db.dump_fixtures && exit
This will close your shell session once complete, to prevent production environment variables from remaining set in your session.
If the script fails, be sure to exit the session, because the environment variables will remain set in the environment.
You will need to have access to the CMR-developers shared LastPass folder.
If you need to update the environment variables in the LastPass note, you can run heroku config -a intake-production > .env.prod
, edit to make bash-compatible, and update note in LastPass.
Users and their preferences are managed entirely via the Django admin interface. See the related page in the wiki for more information.
Before inviting users
- Add the county information to
intake/fixtures/counties.json
- Add the organization's information to
user_accounts/fixtures/organizations .json
. If theis_live
attribute is set tofalse
, then the organization will not be an option on the/apply/
page nor will it be listed on the/partners/
page onintake-production
(but it will be visible onintake-staging
. This can be changed by setting theONLY_SHOW_LIVE_COUNTIES
variable toFalse
). Be sure to also set 'is_accepting_applications' and 'is_checking_notifications' to false. These should be changed on "go live". - List the org name and url in
project/jinja2.py
(Ideally this step will be refactored away eventually). - Add a form specification for the county in
formation/forms.py
. Make sure to list it at the bottom inINPUT_FORM_SPECS
. - Write a method in
intake/tests/mock_county_forms/__init__.py
using the slug given inorganizations.json
. - To load your new county and org, run
./manage.py load_essential_data
- Create new seed data and test fixtures for the county by running
./manage .py new_fixtures
- Add the newly created mock submissions fixture file (in
intake/fixtures/
) toMOCK_APPLICATION_FIXTURES
inproject/fixtures_index.py
. - Run the test suite,
make test
- Manually verify that you can apply to the new county
- Manually verify that you can login as a user at the new county and that reviewing applications or opening PDF printouts shows all the information necessary.
Inviting county/org users
- Follow directions here. Only set "application_reviewers" as the permission group.
On go-live
- In
user_accounts/fixtures/organizations.json
, updateis_receiving_agency
,is_checking_notifications
, andis_live
totrue
. Commit, push, deploy.
- add a class to
formation/fields.py
, and inherit from a field type that matches your needs. If you have a set of options, list them inintake/constants.py
and import them. - Be sure to set a
display_label
value, which is used to label the applicant's input when displayed for org users on the app detail page, in printouts, and in downloaded CSVs of applicant data. By default, display labels are generated from the context key by replacing underscores ("_"
) with spaces and capitalizing the first letter. - List the field it in the correct location in
formation/templates/intake_display.jinja
template, using the_display
suffix. - List the field in
printing/pdf_form_display.py
so that it will be shown in printouts.