Skip to content

Commit

Permalink
string representations
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Apr 11, 2024
1 parent 096d6e3 commit 3f78937
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions backend/letter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class GiftDescriptionCategory(DescriptionField, models.Model):
on_delete=models.CASCADE,
)

def __str__(self) -> str:
return f"category {self.category} on {self.gift}"


class GiftDescriptionSender(DescriptionField, models.Model):
"""
Expand All @@ -80,6 +83,9 @@ def clean(self):
if self.gift.source != self.agent.source:
raise ValidationError("Can only link descriptions in the same source text")

def __str__(self):
return f"{self.agent.name} is sender of {self.gift.name} ({self.gift.source})"


class GiftDescriptionAddressee(DescriptionField, models.Model):
"""
Expand All @@ -99,6 +105,11 @@ def clean(self):
if self.gift.source != self.agent.source:
raise ValidationError("Can only link descriptions in the same source text")

def __str__(self):
return (
f"{self.agent.name} is addressee of {self.gift.name} ({self.gift.source})"
)


class LetterDescription(EntityDescription, models.Model):
"""
Expand Down Expand Up @@ -153,6 +164,9 @@ class LetterDescriptionCategory(DescriptionField, models.Model):
on_delete=models.CASCADE,
)

def __str__(self) -> str:
return f"category {self.category} on {self.letter}"


class LetterDescriptionSender(DescriptionField, models.Model):
"""
Expand All @@ -172,6 +186,11 @@ def clean(self):
if self.letter.source != self.agent.source:
raise ValidationError("Can only link descriptions in the same source text")

def __str__(self):
return (
f"{self.agent.name} is sender of {self.letter.name} ({self.letter.source})"
)


class LetterDescriptionAddressee(DescriptionField, models.Model):
"""
Expand All @@ -191,6 +210,9 @@ def clean(self):
if self.letter.source != self.agent.source:
raise ValidationError("Can only link descriptions in the same source text")

def __str__(self):
return f"{self.agent.name} is addressee of {self.letter.name} ({self.letter.source})"


class PreservedLetter(HistoricalEntity, models.Model):
"""
Expand Down

0 comments on commit 3f78937

Please sign in to comment.