backend/image_markuper/dicom/models/base.py

34 lines
979 B
Python
Raw Normal View History

2022-10-26 23:22:04 +03:00
from django.contrib.auth import get_user_model
from django.db import models
2022-10-28 22:17:29 +03:00
from django.urls import reverse
2022-10-26 23:22:04 +03:00
from utils.files import media_upload_path
User = get_user_model()
2022-10-29 22:46:19 +03:00
class ListOfDicom(models.Model):
pass
2022-10-26 23:22:04 +03:00
class Dicom(models.Model):
2022-10-28 22:17:29 +03:00
class PathologyType(models.IntegerChoices):
no_pathology = 0, "Без патологий"
covid_pathology = 1, "Covid"
2022-10-26 23:22:04 +03:00
user = models.ForeignKey(User, related_name="files", on_delete=models.CASCADE)
slug = models.SlugField()
file = models.FileField(upload_to=media_upload_path)
uploaded = models.DateTimeField(auto_now_add=True)
2022-10-29 22:46:19 +03:00
pathology_type = models.IntegerField(choices=PathologyType.choices, default=0)
list = models.ForeignKey(
ListOfDicom, related_name="files", null=True, on_delete=models.SET_NULL
)
2022-10-28 22:17:29 +03:00
2022-10-26 23:22:04 +03:00
def __str__(self):
return self.file.name
2022-10-28 22:17:29 +03:00
def get_absolute_url(self):
return reverse("get_update_delete_dicom", kwargs={"slug": self.slug})