mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
Modernize property definitions in SplitText
This commit is contained in:
parent
994d6c1c42
commit
d1325d1d5b
1 changed files with 4 additions and 7 deletions
|
|
@ -196,7 +196,6 @@ class SplitText:
|
|||
self.field_name = field_name
|
||||
self.excerpt_field_name = excerpt_field_name
|
||||
|
||||
# content is read/write
|
||||
@property
|
||||
def content(self):
|
||||
return self.instance.__dict__[self.field_name]
|
||||
|
|
@ -205,15 +204,13 @@ class SplitText:
|
|||
def content(self, val):
|
||||
setattr(self.instance, self.field_name, val)
|
||||
|
||||
# excerpt is a read only property
|
||||
def _get_excerpt(self):
|
||||
@property
|
||||
def excerpt(self):
|
||||
return getattr(self.instance, self.excerpt_field_name)
|
||||
excerpt = property(_get_excerpt)
|
||||
|
||||
# has_more is a boolean property
|
||||
def _get_has_more(self):
|
||||
@property
|
||||
def has_more(self):
|
||||
return self.excerpt.strip() != self.content.strip()
|
||||
has_more = property(_get_has_more)
|
||||
|
||||
def __str__(self):
|
||||
return self.content
|
||||
|
|
|
|||
Loading…
Reference in a new issue