Skip to content

Commit

Permalink
Auto-generate segment title if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Oct 25, 2023
1 parent 1814b24 commit bf7b7bd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Tekst-API/tekst/models/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ class ClientSegment(ModelBase, ModelFactoryMixin):
] = ""

@model_validator(mode="after")
def determine_if_system_segment(self) -> "ClientSegment":
def auto_generate_values(self) -> "ClientSegment":
# check if this is a system segment
if self.key and self.key.startswith("system_"):
self.is_system_segment = True
# set title to key if it's missing
if not len(self.title):
self.title = self.key
return self


Expand Down

0 comments on commit bf7b7bd

Please sign in to comment.