How to load development data for the overview pages#
The overview pages answer for many states: a private project, an unpublished dataset, a sample with no measurements, a person with an incomplete profile. You load development data so that you can open each state as a visitor and as a member of a team while you work on a page.
Before you start#
The commands live in the demo portal, in the FairDM repository’s demo/ directory, so you run them from a checkout of that repository. A portal built on the FairDM package does not have them. Write seeds of your own on the pattern of demo/seed/.
The commands refuse to run outside development, because the accounts they create have a password that is written down. Set DJANGO_ENV=development. The accounts are listed in Development accounts.
Steps#
Load the record pages’ data:
DJANGO_ENV=development uv run python manage.py seed_overviews
The command creates the accounts
regular.user,staff.userandsuper.useratexample.comwhen they are missing, with the passwordpassword, and leaves any that exist as they are. It then runs three seeds,ProjectSeed,SampleSeedandMeasurementSeed, indemo/seed/.To load the data for the person and organization pages, run:
DJANGO_ENV=development uv run python manage.py seed_profiles
It builds on the records
seed_overviewscreates, so run that first.Sign in as
staff.userto see the pages as a member of a team.staff.userholds the manage level on every seeded project and dataset, so its pages show the readiness checklist.regular.userholds none. Open the pages signed out to see them as a visitor.Run the command again whenever you want fresh data. It replaces only the records it created, and leaves records someone else made.
The result#
The database holds records that reach each state the pages describe:
projects: one described in full, with datasets, samples, measurements, a large team, funding and identifiers, one brand-new private project with only a name, and one sparse public project with a very long title
samples: one with a full history, an identifier, a location, measurements and subsamples, one that has been destroyed, one with only a name, and one in an unpublished dataset
measurements: one with its procedure, a DOI and a location of its own, one recorded in another team’s dataset, one with nothing else recorded, and one in an unpublished dataset
Types with a template of their own show the extended page, and types without one show the shared page. See How to give a sample or measurement type its own overview page.
Helpers for your own seeds#
demo/seed/common.py has the functions the seeds share:
Function |
What it does |
|---|---|
|
Returns the three example accounts, creating any that are missing. |
|
Returns the accounts the editing pages are tried with. |
|
Creates the missing accounts from |
|
Deletes the projects an earlier run created. |
|
Lists an account at the manage level on the projects and datasets it is given. |
|
Returns the development account that holds the Data Curator role, creating it when missing. |