Skip to content

models

A module that contains models of the files package.

Classes
  • File: A class that creating the file model.

File

Bases: models.Model

A model representing an uploaded file and its converted version.

Attributes:

Name Type Description
file_id models.UUIDField

The id of the file

html_file models.FileField

The html file that uploaded for conversion

pdf_file models.FileField

The pdf file path that converted

uploaded_at models.DateTimeField

The datetime when uploading the file

converted_at models.DateTimeField

The datetime when converting the file

created_at models.DateTimeField

The datetime when the file is created

updated_at models.DateTimeField

The updated datatime when updating the file

user

A foreign key to AuthUser model

Source code in backend/api/files/models.py
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
class File(models.Model):
    """A model representing an uploaded file and its converted version.

    Attributes:
        file_id: The id of the file
        html_file: The html file that uploaded for conversion
        pdf_file: The pdf file path that converted
        uploaded_at: The datetime when uploading the file
        converted_at: The datetime when converting the file
        created_at: The datetime when the file is created
        updated_at: The updated datatime when updating the file
        user: A foreign key to AuthUser model
    """

    class Meta:
        """Metaclass for File model.

        Attributes:
            db_table: the table name
        """

        db_table: str = "api_files"

    file_id: models.UUIDField = models.UUIDField(primary_key=True, default=uuid4, editable=False, db_index=True)

    html_file: models.FileField = models.FileField(upload_to="html_files/", max_length=255, storage=OverwriteStorage(), null=True)
    pdf_file: models.FileField = models.FileField(upload_to="pdf_files/", max_length=255, storage=OverwriteStorage(), null=True)

    uploaded_at: models.DateTimeField = models.DateTimeField(max_length=255, null=True)
    converted_at: models.DateTimeField = models.DateTimeField(max_length=255, null=True)

    created_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
    updated_at: models.DateTimeField = models.DateTimeField(auto_now=True, null=True)

    user = models.ForeignKey(
        AuthUser,
        related_name='files',
        on_delete=models.CASCADE,
        null=True,
    )

Meta

Metaclass for File model.

Attributes:

Name Type Description
db_table str

the table name

Source code in backend/api/files/models.py
30
31
32
33
34
35
36
37
class Meta:
    """Metaclass for File model.

    Attributes:
        db_table: the table name
    """

    db_table: str = "api_files"