fields#
check_child_model_serializer#
URLReferencedModelListField#
Bases: ListField
Custom field for a model list.
Allows user to represent targets using the 'url' key.
The 'child' parameter in 'serializers.ListField' is used for serializing the list in the response.
Source code in src/apps/common/serializers/fields.py
ReferenceDataCache#
Helper class for caching reference data in serializer context.
Source code in src/apps/common/serializers/fields.py
add_url(url)
#
get(url)
#
Get entry from cache or query entry from DB.
Source code in src/apps/common/serializers/fields.py
URLReferencedModelField#
Bases: RelatedField
Serialized RelatedField for URL-referenced concepts.
Accepts input data in the format { "url": ... } which is then used to fetch a model instance. The instance is serialized using a model serializer. The serializer is expected to have a "url" field.
The field is essentially a wrapper around a concept serializer. Using a non-serializer field here prevents the parent serializer from complaining about unsupported writable nested serializers.
Source code in src/apps/common/serializers/fields.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
get_choices(cutoff=None)
#
Modified get_choices that converts dict to json for DRF forms.
Source code in src/apps/common/serializers/fields.py
get_value(dictionary)
#
Convert DRF forms input from json to dict.
many_init(**kwargs)
classmethod
#
For many=True use custom list field that retrieves multiple urls at once.
preprocess(data)
#
Collect urls in a "refdata" dict in context.
Source code in src/apps/common/serializers/fields.py
ChecksumField#
Bases: CharField
Source code in src/apps/common/serializers/fields.py
RemoteResourceChecksumField#
ListValidChoicesField#
Bases: ChoiceField
ChoiceField that lists valid choices in the 'invalid choice' error message.
Source code in src/apps/common/serializers/fields.py
MediaTypeField#
Bases: CharField
Source code in src/apps/common/serializers/fields.py
WKTField#
Bases: CharField
Serializer field that accepts a WKT string and normalizes it.
Source code in src/apps/common/serializers/fields.py
MultiLanguageField#
Bases: HStoreField
Serializer field for MultiLanguageField model fields.
Languages with null
or "" as translation are removed from the object.
Disallows empty objects {}
by default.
Source code in src/apps/common/serializers/fields.py
NullableCharField#
Bases: CharField
CharField that converts empty strings to nulls if allowed.
Source code in src/apps/common/serializers/fields.py
PrivateEmailValue#
Value container for email addresses.
Can be cached. Intentionally not JSON serializable by default to reduce chance of accidentally leaking values. Needs to be removed or converted into string before rendering.
Source code in src/apps/common/serializers/fields.py
handle_private_emails#
Convert PrivateEmailValues into strings or hide them recursively.
Source code in src/apps/common/serializers/fields.py
PrivateEmailField#
Bases: EmailField
Email field that is hidden by CommonModelSerializer by default.
Source code in src/apps/common/serializers/fields.py
NoopField#
Bases: Field
Field that ignores its input and does not produce output.
The field is visible in Swagger (and can have help text) and does not cause an "invalid field" error when someone tries to write a value.
Source code in src/apps/common/serializers/fields.py
ConstantField#
Bases: Field
Read-only field that always returns constant value.
Source code in src/apps/common/serializers/fields.py
CommaSeparatedListField#
Bases: ListField
ListField that serializes into a comma-separated string.