feat(models): add Tag.display_name @property
Single source of truth for human-readable tag rendering. Falls back to tag.name when no fandom is attached, preserving pre-migration data shapes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,19 @@ class Tag(db.Model):
|
|||||||
passive_deletes=True,
|
passive_deletes=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def display_name(self) -> str:
|
||||||
|
"""Human-readable rendering of this tag.
|
||||||
|
|
||||||
|
After the bare-name refactor, `name` holds the display text directly for
|
||||||
|
every kind except character+fandom, which gets the '(Fandom)' suffix
|
||||||
|
appended here. Pre-migration data (with 'kind:' prefix in name) still
|
||||||
|
renders sanely via the else branch — callers see the raw stored string.
|
||||||
|
"""
|
||||||
|
if self.kind == 'character' and self.fandom is not None:
|
||||||
|
return f"{self.name} ({self.fandom.name})"
|
||||||
|
return self.name
|
||||||
|
|
||||||
class ArchiveRecord(db.Model):
|
class ArchiveRecord(db.Model):
|
||||||
"""
|
"""
|
||||||
Tracks archives we've processed so we can skip re-importing the same large file.
|
Tracks archives we've processed so we can skip re-importing the same large file.
|
||||||
|
|||||||
Reference in New Issue
Block a user