Files
xav-portfolio/showcase/models.py
T

50 lines
1.4 KiB
Python

from django.db import models
class Region(models.Model):
class Level(models.TextChoices):
COUNTRY = "country", "Country"
SUBDIVISION = "subdivision", "Subdivision"
code = models.CharField(max_length=8, primary_key=True)
name = models.CharField(max_length=120)
level = models.CharField(max_length=16, choices=Level.choices)
parent = models.ForeignKey(
"self",
blank=True,
null=True,
on_delete=models.CASCADE,
related_name="subdivisions",
)
class Meta:
ordering = ("name",)
def __str__(self):
return self.name
class PortfolioEntry(models.Model):
class EntryType(models.TextChoices):
WORK = "work", "Work"
CV = "cv", "CV"
entry_type = models.CharField(max_length=8, choices=EntryType.choices)
title = models.CharField(max_length=160)
organization = models.CharField(max_length=160, blank=True)
start_date = models.DateField(blank=True, null=True)
end_date = models.DateField(blank=True, null=True)
summary = models.TextField()
url = models.URLField(blank=True)
is_published = models.BooleanField(default=False)
display_order = models.PositiveIntegerField(default=0)
regions = models.ManyToManyField(Region, related_name="entries")
class Meta:
ordering = ("display_order", "-start_date", "title")
verbose_name_plural = "portfolio entries"
def __str__(self):
return self.title