backend/checker/models.py

38 lines
1003 B
Python
Raw Normal View History

2022-08-26 20:04:45 +03:00
import uuid as uuid
2022-08-26 17:00:34 +03:00
from django.db import models
# Create your models here.
2022-08-27 07:38:54 +03:00
from checker.services.file import media_upload_path
2022-08-26 20:04:45 +03:00
class Docx(models.Model):
uuid = models.UUIDField(
default=uuid.uuid4, editable=False, unique=True, primary_key=True
)
2022-08-27 07:38:54 +03:00
file = models.FileField(upload_to=media_upload_path)
created = models.DateTimeField(auto_now_add=True)
paragraphs_processed = models.IntegerField(default=0)
paragraphs_loaded = models.IntegerField(default=0)
def __str__(self):
2022-08-27 07:38:54 +03:00
return str(self.uuid)
class Meta:
ordering = ["-created"]
class ParagraphType(models.Model):
name = models.CharField(max_length=200)
def __str__(self):
return f"{self.id} - {self.name}"
class Paragraph(models.Model):
text = models.TextField()
type = models.ForeignKey(
ParagraphType, related_name="paragraphs", on_delete=models.CASCADE
)
docx = models.ForeignKey(Docx, related_name="paragraphs", on_delete=models.CASCADE)