feat: Add basic flow to add adoption notices

This commit is contained in:
2024-03-19 18:18:55 +01:00
parent dda400f3ba
commit 8488768687
15 changed files with 94 additions and 236 deletions

View File

@@ -63,6 +63,25 @@ class RescueOrganization(models.Model):
website = models.URLField(null=True, blank=True, verbose_name=_('Website'))
class AdoptionNotice(models.Model):
def __str__(self):
return f"{self.name}"
created_at = models.DateField(verbose_name=_('Created at'), default=datetime.now)
searching_since = models.DateField(verbose_name=_('Searching for a home since'))
name = models.CharField(max_length=200)
description = models.TextField(null=True, blank=True, verbose_name=_('Description'))
organization = models.ForeignKey(RescueOrganization, blank=True, null=True, on_delete=models.SET_NULL,
verbose_name=_('Organization'))
further_information = models.URLField(null=True, blank=True, verbose_name=_('Link to further information'))
group_only = models.BooleanField(default=False, verbose_name=_('Only group adoption'))
photos = models.ManyToManyField(Image, blank=True)
@property
def animals_list(self):
return self.animals.all()
class Animal(models.Model):
MALE_NEUTERED = "M_N"
MALE = "M"
@@ -81,6 +100,7 @@ class Animal(models.Model):
species = models.ForeignKey(Species, on_delete=models.PROTECT)
photos = models.ManyToManyField(Image, blank=True)
sex = models.CharField(max_length=20, choices=SEX_CHOICES, )
adoption_notice = models.ForeignKey(AdoptionNotice, on_delete=models.CASCADE)
def __str__(self):
return f"{self.name}"
@@ -99,26 +119,6 @@ class Animal(models.Model):
return reverse('animal-detail', args=[str(self.id)])
class AdoptionNotice(models.Model):
def __str__(self):
return f"{self.name}"
created_at = models.DateField(verbose_name=_('Created at'))
searching_since = models.DateField(verbose_name=_('Searching for a home since'))
name = models.CharField(max_length=200)
description = models.TextField(null=True, blank=True, verbose_name=_('Description'))
organization = models.ForeignKey(RescueOrganization, blank=True, null=True, on_delete=models.SET_NULL,
verbose_name=_('Organization'))
further_information = models.URLField(null=True, blank=True, verbose_name=_('Link to further information'))
group_only = models.BooleanField(default=False, verbose_name=_('Only group adoption'))
animals = models.ManyToManyField(Animal)
photos = models.ManyToManyField(Image, blank=True)
@property
def animals_list(self):
return self.animals.all()
class MarkdownContent(models.Model):
"""
Base class to store markdown content