serializers
A module that contains serializers of the files package.
Classes
FileSerializer
: A class that serializer the File model.
FileSerializer
Bases: ModelSerializer
Serializer for the File model.
Attributes:
Name | Type | Description |
---|---|---|
html_file |
SerializerMethodField
|
The html file path |
pdf_file |
SerializerMethodField
|
The pdf file path |
Methods
get_html_file(file)
: A method to get the html file urlget_pdf_file(file)
: A method to get the pdf file url
Source code in backend/api/files/serializers.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
Meta
Metaclass for FileSerializer.
Attributes:
Name | Type | Description |
---|---|---|
model |
The File model |
|
fields |
A list of File fields that need to be serialized |
Source code in backend/api/files/serializers.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
get_html_file(file)
Get the URL for a File object's html_file field as a hyperlink.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
File
|
A File object. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL for the File object's html_file field as a hyperlink. |
Source code in backend/api/files/serializers.py
47 48 49 50 51 52 53 54 55 56 57 58 |
|
get_pdf_file(file)
Get the URL for a File object's pdf_file field as a hyperlink.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
File
|
A File object. |
required |
Returns:
Type | Description |
---|---|
str
|
The URL for the File object's pdf_file field as a hyperlink. |
Source code in backend/api/files/serializers.py
60 61 62 63 64 65 66 67 68 69 70 71 |
|