mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-17 04:10:24 +00:00
Fix E30X too-few line spacing errors.
This commit is contained in:
parent
600ddc8dc5
commit
da65d0be32
2 changed files with 11 additions and 3 deletions
|
|
@ -141,6 +141,7 @@ SPLIT_DEFAULT_PARAGRAPHS = getattr(settings, 'SPLIT_DEFAULT_PARAGRAPHS', 2)
|
|||
|
||||
_excerpt_field_name = lambda name: '_%s_excerpt' % name
|
||||
|
||||
|
||||
def get_excerpt(content):
|
||||
excerpt = []
|
||||
default_excerpt = []
|
||||
|
|
@ -156,6 +157,7 @@ def get_excerpt(content):
|
|||
|
||||
return '\n'.join(default_excerpt)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SplitText(object):
|
||||
def __init__(self, instance, field_name, excerpt_field_name):
|
||||
|
|
@ -166,11 +168,13 @@ class SplitText(object):
|
|||
self.excerpt_field_name = excerpt_field_name
|
||||
|
||||
# content is read/write
|
||||
def _get_content(self):
|
||||
@property
|
||||
def content(self):
|
||||
return self.instance.__dict__[self.field_name]
|
||||
def _set_content(self, val):
|
||||
|
||||
@content.setter
|
||||
def content(self, val):
|
||||
setattr(self.instance, self.field_name, val)
|
||||
content = property(_get_content, _set_content)
|
||||
|
||||
# excerpt is a read only property
|
||||
def _get_excerpt(self):
|
||||
|
|
@ -185,6 +189,7 @@ class SplitText(object):
|
|||
def __str__(self):
|
||||
return self.content
|
||||
|
||||
|
||||
class SplitDescriptor(object):
|
||||
def __init__(self, field):
|
||||
self.field = field
|
||||
|
|
@ -205,6 +210,7 @@ class SplitDescriptor(object):
|
|||
else:
|
||||
obj.__dict__[self.field.name] = value
|
||||
|
||||
|
||||
class SplitField(models.TextField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# for South FakeORM compatibility: the frozen version of a
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ class FieldTracker(object):
|
|||
|
||||
def patch_save(self, instance):
|
||||
original_save = instance.save
|
||||
|
||||
def save(**kwargs):
|
||||
ret = original_save(**kwargs)
|
||||
update_fields = kwargs.get('update_fields')
|
||||
|
|
@ -251,6 +252,7 @@ class FieldTracker(object):
|
|||
fields=fields
|
||||
)
|
||||
return ret
|
||||
|
||||
instance.save = save
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
|
|
|
|||
Loading…
Reference in a new issue