feat: add sex coding
This commit is contained in:
parent
98d67381c6
commit
2212df4729
@ -217,6 +217,24 @@ class AdoptionNotice(models.Model):
|
|||||||
def animals(self):
|
def animals(self):
|
||||||
return Animal.objects.filter(adoption_notice=self)
|
return Animal.objects.filter(adoption_notice=self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sexes(self):
|
||||||
|
sexes = set()
|
||||||
|
for animal in self.animals:
|
||||||
|
sexes.update(animal.sex)
|
||||||
|
return sexes
|
||||||
|
|
||||||
|
def sex_code(self):
|
||||||
|
if len(self.sexes) > 1:
|
||||||
|
return "mixed"
|
||||||
|
elif self.sexes.pop() == Animal.MALE:
|
||||||
|
return "male"
|
||||||
|
elif self.sexes.pop() == Animal.FEMALE:
|
||||||
|
return "female"
|
||||||
|
else:
|
||||||
|
return "mixed"
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def comments(self):
|
def comments(self):
|
||||||
return Comment.objects.filter(adoption_notice=self)
|
return Comment.objects.filter(adoption_notice=self)
|
||||||
@ -421,7 +439,6 @@ class AdoptionNoticeStatus(models.Model):
|
|||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Animal(models.Model):
|
class Animal(models.Model):
|
||||||
MALE_NEUTERED = "M_N"
|
MALE_NEUTERED = "M_N"
|
||||||
MALE = "M"
|
MALE = "M"
|
||||||
@ -565,7 +582,6 @@ class ModerationAction(models.Model):
|
|||||||
private_comment = models.TextField(blank=True)
|
private_comment = models.TextField(blank=True)
|
||||||
report = models.ForeignKey(Report, on_delete=models.CASCADE)
|
report = models.ForeignKey(Report, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"[{self.action}]: {self.public_comment}"
|
return f"[{self.action}]: {self.public_comment}"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user