io_resources
main.io_resources
¤
Django import / export Resource classes for facillitating DB Import and Export.
Classes¤
CompetencyDomainResource
¤
CompetencyResource
¤
LearningResourceResource
¤
MultipleChoiceWidget(separator='|', **kwargs)
¤
Bases: CharWidget
A CharWidget that allows for multiple values to work with MultiSelectField.
Override the constructor to set a separator, defaults to |.
Source code in main/io_resources.py
90 91 92 93 | |
Methods:¤
clean(value, row=None, **kwargs)
¤
Override the clean method to make the choices comma-separated.
This is required for the MultiSelectField to work.
Source code in main/io_resources.py
95 96 97 98 99 100 101 102 | |
render(value, obj=None, **kwargs)
¤
Override the render method so the correct separator is used on export.
Source code in main/io_resources.py
104 105 106 | |
ProviderResource
¤
SkillLevelResource
¤
SkillResource
¤
Bases: ModelResource
A ModelResource to facilitate importing and exporting Skills.
Classes¤
Meta
¤
Meta options for SkillResource.
Methods:¤
after_import(dataset, result, **kwargs)
¤
Override the after_import method to ensure that related_skills are linked.
This approach was inspired by https://github.com/django-import-export/django-import-export/issues/397#issuecomment-1034928530
Source code in main/io_resources.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
SluggedFKWidget(model, column_name, **kwargs)
¤
Bases: ForeignKeyWidget
A ForeignKeyWidget that always uses slug as the field.
Override the constructor to set the field to slug.
Source code in main/io_resources.py
30 31 32 33 34 35 | |
Methods:¤
clean(value, row=None, **kwargs)
¤
Overwrite the clean method so that it raises and error on missing objects.
Source code in main/io_resources.py
37 38 39 40 41 42 43 44 | |
SluggedM2MWidget(model, column_name, ignore_missing=False, **kwargs)
¤
Bases: ManyToManyWidget
A ManyToManyWidget that always uses slug as the field, separated by |.
Override the constructor to set the field to slug and the separator to |.
Source code in main/io_resources.py
50 51 52 53 54 55 56 57 58 59 60 | |
Methods:¤
clean(value, row=None, **kwargs)
¤
Overwrite the clean method so that it raises and error on missing objects.
This does not prevent the instance from being saved if dry_run=False on import!
Source code in main/io_resources.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
ToolLanguageMethodologyResource
¤
Functions:¤
export_framework()
¤
Exports the core framework into one dictionary with each model as a key.
Returns:
| Type | Description |
|---|---|
dict[str, list[dict[str, str]]]
|
A dictionary containing the entire framework. Each model is labelled by a key and is a list of dictionaries. This is JSON compatible. |
Source code in main/io_resources.py
262 263 264 265 266 267 268 269 270 271 272 273 274 | |