refactor: add guard clause for readability
Both functions only execute based on a condition. In such cases condition should immediately exit the function, this is called "guard clause" and helps in readability (less indent, and easy to "exit" when reading the code.
This commit is contained in:
parent
4b484d741d
commit
c229ac9322
@ -359,7 +359,9 @@ class Item(WebsiteGenerator):
|
||||
context.update(get_slideshow(self))
|
||||
|
||||
def set_attribute_context(self, context):
|
||||
if self.has_variants:
|
||||
if not self.has_variants:
|
||||
return
|
||||
|
||||
attribute_values_available = {}
|
||||
context.attribute_values = {}
|
||||
context.selected_attributes = {}
|
||||
@ -736,7 +738,9 @@ class Item(WebsiteGenerator):
|
||||
|
||||
def update_template_item(self):
|
||||
"""Set Show in Website for Template Item if True for its Variant"""
|
||||
if self.variant_of:
|
||||
if not self.variant_of:
|
||||
return
|
||||
|
||||
if self.show_in_website:
|
||||
self.show_variant_in_website = 1
|
||||
self.show_in_website = 0
|
||||
|
Loading…
Reference in New Issue
Block a user