Skip to content

Commit

Permalink
BE-1273 fixed comments on pr
Browse files Browse the repository at this point in the history
  • Loading branch information
tom committed May 18, 2021
1 parent b011881 commit 0e8dda4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
12 changes: 3 additions & 9 deletions livestyled/models/form.py
Expand Up @@ -62,10 +62,8 @@ def __init__(
self.show_completion_date = show_completion_date
self.allow_update = allow_update
self.refresh_on_success = refresh_on_success
if fields:
self.fields = [FormField(**field) for field in fields]
if translations:
self.fields = [FormTranslation(**translation) for translation in translations]
self.fields = fields and [FormField(**field) for field in fields]
self.fields = translations and [FormTranslation(**translation) for translation in translations]
self.requires_login = requires_login
self.validation_integration = validation_integration

Expand Down Expand Up @@ -107,15 +105,11 @@ def __repr__(self):
return '<Form(id={self.id!r})>'.format(self=self)

def diff(self, other):
differences = {}
fields = (
'data', 'reference', 'image_url', 'completion_button_url', 'completion_button_title', 'show_completion_date',
'allow_update', 'refresh_on_success', 'fields', 'translations', 'requires_login', 'validation_integration'
)
for field in fields:
if getattr(self, field) != getattr(other, field):
differences[field] = getattr(self, field)
return differences
return {field: getattr(self, field) for field in fields if getattr(self, field) != getattr(other, field)}

@classmethod
def placeholder(
Expand Down
9 changes: 2 additions & 7 deletions livestyled/models/form_field.py
Expand Up @@ -48,8 +48,7 @@ def __init__(
self.select_options = select_options
self.sort_id = sort_id
self.auto_fill = auto_fill
if translations:
self.fields = [FormFieldTranslation(**translation) for translation in translations]
self.translations = translations and [FormFieldTranslation(**translation) for translation in translations]

@classmethod
def create_new(
Expand Down Expand Up @@ -83,14 +82,10 @@ def __repr__(self):
return '<FormField(id={self.id!r})>'.format(self=self)

def diff(self, other):
differences = {}
fields = (
'data', 'type', 'key', 'required', 'translations', 'sort_id', 'validation_regex', 'select_options', 'auto_fill'
)
for field in fields:
if getattr(self, field) != getattr(other, field):
differences[field] = getattr(self, field)
return differences
return {field: getattr(self, field) for field in fields if getattr(self, field) != getattr(other, field)}

@classmethod
def placeholder(
Expand Down

0 comments on commit 0e8dda4

Please sign in to comment.