Core models#
This page lists the fields, choices, managers and rules of the two fixed core models, Project and Dataset, and the fields they share with samples and measurements. It does not cover the two models you extend, which are on Sample model and Measurement model, or why the four levels exist, which is in The core data model. Methods are listed by name only. Their signatures are on the Python API page.
Import the models from their own modules:
from fairdm.core.dataset.models import Dataset
from fairdm.core.project.models import Project
fairdm.core.models also re-exports Project, Dataset, Sample and Measurement.
erDiagram
Organization |o--o{ Project : owns
Project |o--o{ Dataset : holds
Dataset ||--o{ Sample : holds
Dataset ||--o{ Measurement : holds
Sample ||--o{ Measurement : "is measured by"
Sample }o--o{ Sample : "SampleRelation"
Fields every record has#
Project, Dataset, Sample and Measurement all inherit these fields. BaseModel in fairdm.core.abstract supplies the first group, and Model in fairdm.db.models supplies added and modified.
Field |
Type |
Default |
What it does |
Accepts |
|---|---|---|---|---|
|
|
Assigned on save |
The database key. |
Not editable. |
|
|
Generated on save |
The identifier used in addresses and the API. A prefix names the kind of record: |
Not editable. Unique. |
|
|
None |
The record’s title. |
Up to 300 characters. Required. |
|
|
|
A picture of the record. The stored source is limited to 2400 by 1600 pixels without cropping. |
An image file. Optional. |
|
|
Empty |
Controlled keywords for discoverability. |
Concepts from any loaded vocabulary. Optional. |
|
|
Empty |
Free words. |
Any text. Optional. |
|
|
|
A place for settings of your own. |
Any JSON value. Optional. |
|
|
The time of creation |
When the record was added. |
Not editable. |
|
|
The time of each save |
When the record was last saved. |
Not editable. |
tracker is a FieldTracker from django-model-utils. It adds no column.
Methods every record has#
Name |
Returns |
|---|---|
|
The record’s |
|
The icon name for the model. A property. |
|
The address of the record’s overview page. |
|
The address of the record’s API detail endpoint. |
|
The contributor’s credit on the record, created or extended with the roles. |
|
Whether the user has a credit on the record. |
|
The people and organizations credited on the record. |
|
The organizations named as affiliations on the record’s credits. |
|
The credited contributors together with those affiliated organizations. |
|
The record’s description of type |
|
The abstract as plain text of at most 400 characters. |
|
The abstract’s full text, or |
|
The record’s descriptions as a list. A cached property. |
|
The model’s names. |
|
The record fetched again as its polymorphic base ( |
Project#
fairdm.core.project.models.Project is a body of research that groups datasets. A dataset may belong to a project but does not have to.
Field |
Type |
Default |
What it does |
Accepts |
|---|---|---|---|---|
|
|
Generated, prefix |
See above. |
Not editable. |
|
|
|
Whether the project is public or private. |
A value of |
|
|
|
The project’s stage. |
A value of |
|
|
|
Funding awards in the shape of DataCite’s funding reference. |
|
|
|
|
The organization that owns the project. Related name |
An organization. Optional. |
|
|
|
The person who created the project. Related name |
Not editable. |
|
|
The project’s credits. |
Each object in funding accepts these keys and no others:
Key |
Required |
Accepts |
|---|---|---|
|
Yes |
Text. |
|
No |
Text. |
|
No |
|
|
No |
Text. |
|
No |
Text. |
|
No |
Text. |
A value that is not a list of such objects fails validation with one of the codes funding_not_list, funding_unknown_key, funding_missing_funder_name, funding_invalid_type or funding_invalid_identifier_type.
Class attributes#
Name |
Value |
|---|---|
|
|
|
The address of the project collection of the contributor roles. |
|
The address of the project collection of the date types. |
|
The address of the project collection of the description types. |
|
|
|
|
|
The theme colour name of each status on a project card. |
Properties and methods#
Name |
Returns |
|---|---|
|
Whether the status is |
|
The colour name for the status badge. |
|
The box that holds the locations the viewer may see in the project’s datasets, or |
Deletion#
Deleting a project deletes its datasets. A project that still has a public dataset cannot be deleted. The attempt raises PublicDatasetsProtect, which carries the blocking datasets.
Dataset#
fairdm.core.dataset.models.Dataset is the unit a portal cites and distributes. Samples and measurements hang beneath it.
Field |
Type |
Default |
What it does |
Accepts |
|---|---|---|---|---|
|
|
Generated, prefix |
See above. |
Not editable. |
|
|
|
Whether the dataset’s metadata is shown to everyone. |
A value of |
|
|
|
Whether the data beneath the dataset may be shown publicly. It is independent of |
|
|
|
|
The project the dataset belongs to. Related name |
A project. Optional. |
|
|
|
The data publication for the dataset. |
A literature item. Optional. |
|
|
Empty |
Literature related to the dataset. |
Literature items. Optional. |
|
|
The licence named by |
The licence the dataset’s data is published under. |
A licence. Optional. |
|
|
|
The person who created the dataset. Related name |
Not editable. |
|
|
The dataset’s credits. |
FAIRDM_DEFAULT_LICENSE is described on Settings. The default is read when a dataset is created. If the portal has not loaded its licences yet, the default is empty.
Class attributes#
Name |
Value |
|---|---|
|
|
|
The address of the dataset collection of the contributor roles. |
|
The address of the dataset collection of the date types. |
|
The address of the dataset collection of the description types. |
|
The address of the dataset collection of the identifier types. |
|
|
Properties and methods#
Name |
Returns |
|---|---|
|
Whether the visibility is public and the dataset is published. |
|
Whether any sample or measurement hangs beneath the dataset. A cached property. |
|
The box that holds the locations the viewer may see in the dataset’s samples and measurements, or |
clean() refuses to move a dataset to a project when that would leave nobody able to manage it.
Managers#
Manager |
Returns |
|---|---|
|
Every dataset that is not private. |
|
Every dataset. |
Use all_objects whenever you need private datasets. Following a relation to a dataset and cascading a deletion are not narrowed by objects. The reasoning for the separate publication flag is in ADR 0014.
DatasetLiteratureRelation#
DatasetLiteratureRelation links a dataset to a literature item with a DataCite relation type.
Field |
Type |
Default |
What it does |
Accepts |
|---|---|---|---|---|
|
|
None |
The dataset. Related name |
A dataset. |
|
|
None |
The literature item. Related name |
A literature item. |
|
|
None |
How the dataset relates to the item. |
One of the 34 relation types of DataCite Metadata Schema 4.4, such as |
The combination of dataset, item and type is unique.
Choices#
Name |
Members |
|---|---|
|
|
|
|
Querysets#
Both models have a queryset with these methods.
Method |
Project |
Dataset |
Returns |
|---|---|---|---|
|
Yes |
Yes |
For a project, the public projects. For a dataset, the public datasets that are not inside a private project. |
|
No |
Yes |
The datasets whose |
|
Yes |
Yes |
The records with their credits loaded. |
|
Yes |
Yes |
The records with descriptions, dates, identifiers, credits and keywords loaded. A project also loads its owner. |
|
No |
Yes |
The records with project and credits loaded. |
|
Yes |
Yes |
The records with what a list card draws loaded, and a count. A project gets |
|
Yes |
Yes |
The records on which the user holds at least a level. |
|
Yes |
Yes |
The records the user may act on at a level, which is every record for a user with the matching portal-wide right. |
The two level methods are described on Contribution levels and record access.
Descriptions, dates and identifiers#
A project and a dataset each carry typed rows. A row model exists for each pair, such as ProjectDescription and DatasetDate. Every row model links back to its record by related and is reached from the record by descriptions, dates or identifiers.
Rows |
|
|
Rules |
|---|---|---|---|
Descriptions |
The description types |
Text of at most 20,000 characters. |
One row of each type for each record. |
Dates |
The date types |
A partial date: a year, a year and month, or a full date. See Model fields. |
One row of each type for each record. The end may not be before the start. |
Identifiers |
The identifier types |
Text of at most 255 characters. |
One row of each type for each record. The value is unique across every kind of record. |
type is a ConceptField limited to the record’s collection of the vocabulary, and holds the concept’s address: the vocabulary’s address, a slash and the identifier listed below. The start and end types are start and end for a project, ProjectDate.START_TYPE and ProjectDate.END_TYPE, and collection-start and collection-end for a dataset. The end is compared with the start at the coarser of their two precisions.
The types each record accepts, by identifier, in the order its collection lists them:
Record |
Descriptions |
Dates |
Identifiers |
|---|---|---|---|
Project |
|
|
|
Dataset |
|
|
|
The roles a person or organization can hold on a record come from the contributor roles vocabulary, by identifier:
Record |
Roles |
|---|---|
Project |
|
Dataset |
|
The vocabularies’ addresses are constants in fairdm.core.vocabularies, and get_type_concepts() on a row model returns the concepts its collection offers. See Controlled vocabularies.
Permissions#
Both models declare these permissions beside Django’s four. Who holds them on a record is decided by the level a person has on it, as described in How access to a record is decided.
Model |
Permissions |
|---|---|
Project |
|
Dataset |
|
Both are ordered by -modified and indexed on modified.