Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Refactor `input` (`raw_input`) to `data` to avoid python2 confusions

NyanKiyoshi9b5ad2dd3487
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index 3c551f6aff..ce49783680 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -128,10 +128,10 @@ class CustomerCreate(ModelMutation, I18nMixin):
return user.has_perm('account.manage_users')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- shipping_address_data = raw_input.pop(SHIPPING_ADDRESS_FIELD, None)
- billing_address_data = raw_input.pop(BILLING_ADDRESS_FIELD, None)
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ shipping_address_data = data.pop(SHIPPING_ADDRESS_FIELD, None)
+ billing_address_data = data.pop(BILLING_ADDRESS_FIELD, None)
+ cleaned_input = super().clean_input(info, instance, data)
if shipping_address_data:
shipping_address = cls.validate_address(
@@ -234,8 +234,8 @@ class StaffCreate(ModelMutation):
return user.has_perm('account.manage_staff')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
# set is_staff to True to create a staff user
cleaned_input['is_staff'] = True
@@ -279,8 +279,8 @@ class StaffUpdate(StaffCreate):
'is_active': 'Cannot deactivate superuser\'s account.'})
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
is_active = cleaned_input.get('is_active')
if is_active is not None:
cls.clean_is_active(is_active, instance, info.context.user)
@@ -338,8 +338,8 @@ class SetPassword(ModelMutation):
model = models.User
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
token = cleaned_input.pop('token')
if not default_token_generator.check_token(instance, token):
raise ValidationError({'token': SetPassword.INVALID_TOKEN})
@@ -448,12 +448,12 @@ class AddressUpdate(ModelMutation):
exclude = ['user_addresses']
@classmethod
- def clean_input(cls, info, instance, raw_input):
+ def clean_input(cls, info, instance, data):
# Method user_is_allowed cannot be used for permission check, because
# it doesn't have the address instance.
if not can_edit_address(info.context.user, instance):
raise PermissionDenied()
- return super().clean_input(info, instance, raw_input)
+ return super().clean_input(info, instance, data)
@classmethod
def perform_mutation(cls, root, info, **data):
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index ecdc2c4fc7..4da9524332 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -106,10 +106,10 @@ class CheckoutCreate(ModelMutation, I18nMixin):
return_field_name = 'checkout'
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
user = info.context.user
- lines = raw_input.pop('lines', None)
+ lines = data.pop('lines', None)
if lines:
variant_ids = [line.get('variant_id') for line in lines]
variants = cls.get_nodes_or_error(
@@ -127,23 +127,23 @@ class CheckoutCreate(ModelMutation, I18nMixin):
default_billing_address = user.default_billing_address
default_shipping_address = user.default_shipping_address
- if 'shipping_address' in raw_input:
+ if 'shipping_address' in data:
shipping_address = cls.validate_address(
- raw_input['shipping_address'])
+ data['shipping_address'])
cleaned_input['shipping_address'] = shipping_address
else:
cleaned_input['shipping_address'] = default_shipping_address
- if 'billing_address' in raw_input:
+ if 'billing_address' in data:
billing_address = cls.validate_address(
- raw_input['billing_address'])
+ data['billing_address'])
cleaned_input['billing_address'] = billing_address
else:
cleaned_input['billing_address'] = default_billing_address
# Use authenticated user's email as default email
if user.is_authenticated:
- email = raw_input.pop('email', None)
+ email = data.pop('email', None)
cleaned_input['email'] = email or user.email
return cleaned_input
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index b3e8b79fec..ab36e006a4 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -221,7 +221,7 @@ class ModelMutation(BaseMutation):
arguments=arguments, fields=fields)
@classmethod
- def clean_input(cls, info, instance, raw_input):
+ def clean_input(cls, info, instance, data):
"""Clean input data received from mutation arguments.
Fields containing IDs or lists of IDs are automatically resolved into
@@ -253,8 +253,8 @@ class ModelMutation(BaseMutation):
cleaned_input = {}
for field_name, field_item in input_cls._meta.fields.items():
- if field_name in raw_input:
- value = raw_input[field_name]
+ if field_name in data:
+ value = data[field_name]
# handle list of IDs field
if value is not None and is_list_of_ids(field_item):
@@ -327,8 +327,8 @@ class ModelMutation(BaseMutation):
created based on the model associated with this mutation.
"""
instance = cls.get_instance(info, **data)
- raw_input = data.get('input')
- cleaned_input = cls.clean_input(info, instance, raw_input)
+ data = data.get('input')
+ cleaned_input = cls.clean_input(info, instance, data)
instance = cls.construct_instance(instance, cleaned_input)
cls.clean_instance(instance)
cls.save(info, instance, cleaned_input)
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
index 684f2f074e..557298fa0f 100644
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -109,11 +109,11 @@ class VoucherCreate(ModelMutation):
return user.has_perm('discount.manage_discounts')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- code = raw_input.get('code', None)
+ def clean_input(cls, info, instance, data):
+ code = data.get('code', None)
if code == '':
- raw_input['code'] = generate_voucher_code()
- cleaned_input = super().clean_input(info, instance, raw_input)
+ data['code'] = generate_voucher_code()
+ cleaned_input = super().clean_input(info, instance, data)
return cleaned_input
diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.py
index d214b6bb9a..bd3331ac17 100644
--- a/saleor/graphql/menu/mutations.py
+++ b/saleor/graphql/menu/mutations.py
@@ -57,8 +57,8 @@ class MenuCreate(ModelMutation):
return user.has_perm('menu.manage_menus')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
items = []
for item in cleaned_input.get('items', []):
category = item.get('category')
@@ -143,8 +143,8 @@ class MenuItemCreate(ModelMutation):
return user.has_perm('menu.manage_menus')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
items = [
cleaned_input.get('page'), cleaned_input.get('collection'),
cleaned_input.get('url'), cleaned_input.get('category')]
diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.py
index 641f830f0a..fa9b9b148e 100644
--- a/saleor/graphql/order/mutations/draft_orders.py
+++ b/saleor/graphql/order/mutations/draft_orders.py
@@ -64,12 +64,12 @@ class DraftOrderCreate(ModelMutation, I18nMixin):
model = models.Order
@classmethod
- def clean_input(cls, info, instance, raw_input):
- shipping_address = raw_input.pop('shipping_address', None)
- billing_address = raw_input.pop('billing_address', None)
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ shipping_address = data.pop('shipping_address', None)
+ billing_address = data.pop('billing_address', None)
+ cleaned_input = super().clean_input(info, instance, data)
- lines = raw_input.pop('lines', None)
+ lines = data.pop('lines', None)
if lines:
variant_ids = [line.get('variant_id') for line in lines]
variants = cls.get_nodes_or_error(
@@ -310,12 +310,12 @@ class DraftOrderLineUpdate(ModelMutation):
return user.has_perm('order.manage_orders')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
if instance.order.status != OrderStatus.DRAFT:
raise ValidationError({'id': 'Only draft orders can be edited.'})
- quantity = raw_input['quantity']
+ quantity = data['quantity']
if quantity <= 0:
raise ValidationError({
'quantity':
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.py
index c765990a03..9376648fbc 100644
--- a/saleor/graphql/order/mutations/fulfillments.py
+++ b/saleor/graphql/order/mutations/fulfillments.py
@@ -80,8 +80,8 @@ class FulfillmentCreate(BaseMutation):
raise ValidationError({'order_line_id': msg})
@classmethod
- def clean_input(cls, raw_input):
- lines = raw_input['lines']
+ def clean_input(cls, data):
+ lines = data['lines']
quantities = [line['quantity'] for line in lines]
lines_ids = [line['order_line_id'] for line in lines]
order_lines = cls.get_nodes_or_error(
@@ -93,9 +93,9 @@ class FulfillmentCreate(BaseMutation):
raise ValidationError({
'lines': 'Total quantity must be larger than 0.'})
- raw_input['order_lines'] = order_lines
- raw_input['quantities'] = quantities
- return raw_input
+ data['order_lines'] = order_lines
+ data['quantities'] = quantities
+ return data
@classmethod
def save(cls, user, fulfillment, order, cleaned_input):
@@ -131,11 +131,11 @@ class FulfillmentCreate(BaseMutation):
def perform_mutation(cls, root, info, order, **data):
order = cls.get_node_or_error(
info, order, field='order', only_type=Order)
- raw_input = data.get('input')
+ data = data.get('input')
fulfillment = models.Fulfillment(
- tracking_number=raw_input.pop('tracking_number', None) or '',
+ tracking_number=data.pop('tracking_number', None) or '',
order=order)
- cleaned_input = cls.clean_input(raw_input)
+ cleaned_input = cls.clean_input(data)
fulfillment = cls.save(
info.context.user, fulfillment, order, cleaned_input)
return FulfillmentCreate(
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index 6935501879..930509e3c4 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -121,9 +121,9 @@ class OrderUpdateShipping(BaseMutation):
def perform_mutation(cls, _root, info, **data):
order = cls.get_node_or_error(
info, data.get('id'), only_type=Order)
- raw_input = data.get('input')
+ data = data.get('input')
- if not raw_input['shipping_method']:
+ if not data['shipping_method']:
if not order.is_draft() and order.is_shipping_required():
raise ValidationError({
'shipping_method':
@@ -139,7 +139,7 @@ class OrderUpdateShipping(BaseMutation):
return OrderUpdateShipping(order=order)
method = cls.get_node_or_error(
- info, raw_input['shipping_method'], field='shipping_method',
+ info, data['shipping_method'], field='shipping_method',
only_type=ShippingMethod)
clean_order_update_shipping(order, method)
diff --git a/saleor/graphql/page/mutations.py b/saleor/graphql/page/mutations.py
index 76acbe261a..a75094bdf9 100644
--- a/saleor/graphql/page/mutations.py
+++ b/saleor/graphql/page/mutations.py
@@ -36,8 +36,8 @@ class PageCreate(ModelMutation):
return user.has_perm('page.manage_pages')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
slug = cleaned_input.get('slug', '')
if not slug:
cleaned_input['slug'] = slugify(cleaned_input['title'])
diff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.py
index cf326f65a6..f7d7979dbf 100644
--- a/saleor/graphql/payment/mutations.py
+++ b/saleor/graphql/payment/mutations.py
@@ -58,10 +58,10 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
checkout = cls.get_node_or_error(
info, checkout_id, field='checkout_id', only_type=Checkout)
- raw_input = data.get('input')
+ data = data.get('input')
billing_address = checkout.billing_address
- if 'billing_address' in raw_input:
- billing_address = cls.validate_address(raw_input['billing_address'])
+ if 'billing_address' in data:
+ billing_address = cls.validate_address(data['billing_address'])
if billing_address is None:
raise ValidationError({
'billing_address':
@@ -70,7 +70,7 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
checkout_total = checkout.get_total(
discounts=info.context.discounts,
taxes=get_taxes_for_address(checkout.billing_address))
- amount = raw_input.get('amount', checkout_total)
+ amount = data.get('amount', checkout_total)
if amount < checkout_total.gross.amount:
raise ValidationError({
'amount':
@@ -81,8 +81,8 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
'customer_user_agent': info.context.META.get('HTTP_USER_AGENT')}
payment = create_payment(
- gateway=raw_input['gateway'],
- payment_token=raw_input['token'],
+ gateway=data['gateway'],
+ payment_token=data['token'],
total=amount,
currency=settings.DEFAULT_CURRENCY,
email=checkout.email,
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.py
index 1802b512d7..04fc30467f 100644
--- a/saleor/graphql/product/mutations/attributes.py
+++ b/saleor/graphql/product/mutations/attributes.py
@@ -260,8 +260,8 @@ class AttributeValueCreate(ModelMutation):
model = models.AttributeValue
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
cleaned_input['slug'] = slugify(cleaned_input['name'])
return cleaned_input
@@ -305,8 +305,8 @@ class AttributeValueUpdate(ModelMutation):
return user.has_perm('product.manage_products')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
if 'name' in cleaned_input:
cleaned_input['slug'] = slugify(cleaned_input['name'])
return cleaned_input
diff --git a/saleor/graphql/product/mutations/digital_contents.py b/saleor/graphql/product/mutations/digital_contents.py
index c6bf704699..1c7c543595 100644
--- a/saleor/graphql/product/mutations/digital_contents.py
+++ b/saleor/graphql/product/mutations/digital_contents.py
@@ -56,26 +56,26 @@ class DigitalContentCreate(BaseMutation):
@classmethod
@permission_required('product.manage_products')
- def clean_input(cls, info, raw_input, instance):
+ def clean_input(cls, info, data, instance):
if hasattr(instance, 'digital_content'):
instance.digital_content.delete()
- use_default_settings = raw_input.get('use_default_settings')
+ use_default_settings = data.get('use_default_settings')
if use_default_settings:
- return raw_input
+ return data
required_fields = [
'max_downloads', 'url_valid_days', 'automatic_fulfillment']
- if not all(field in raw_input for field in required_fields):
+ if not all(field in data for field in required_fields):
msg = ('Use default settings is disabled. Provide all '
'missing configuration fields: ')
- missing_fields = set(required_fields).difference(set(raw_input))
+ missing_fields = set(required_fields).difference(set(data))
if missing_fields:
msg += '{}, ' * len(missing_fields)
raise ValidationError(msg.format(*missing_fields))
- return raw_input
+ return data
@classmethod
@permission_required('product.manage_products')
@@ -146,23 +146,23 @@ class DigitalContentUpdate(BaseMutation):
@classmethod
@permission_required('product.manage_products')
- def clean_input(cls, info, raw_input):
- use_default_settings = raw_input.get('use_default_settings')
+ def clean_input(cls, info, data):
+ use_default_settings = data.get('use_default_settings')
if use_default_settings:
return {'use_default_settings': use_default_settings}
required_fields = [
'max_downloads', 'url_valid_days', 'automatic_fulfillment']
- if not all(field in raw_input for field in required_fields):
+ if not all(field in data for field in required_fields):
msg = ('Use default settings is disabled. Provide all '
'missing configuration fields: ')
- missing_fields = set(required_fields).difference(set(raw_input))
+ missing_fields = set(required_fields).difference(set(data))
if missing_fields:
msg += '{}, ' * len(missing_fields)
raise ValidationError(msg.format(*missing_fields))
- return raw_input
+ return data
@classmethod
@permission_required('product.manage_products')
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 4cc7e67f23..e5b24b7c5c 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -48,17 +48,17 @@ class CategoryCreate(ModelMutation):
model = models.Category
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
if 'slug' not in cleaned_input and 'name' in cleaned_input:
cleaned_input['slug'] = slugify(cleaned_input['name'])
- parent_id = raw_input['parent_id']
+ parent_id = data['parent_id']
if parent_id:
parent = cls.get_node_or_error(
info, parent_id, field='parent', only_type=Category)
cleaned_input['parent'] = parent
- if raw_input.get('background_image'):
- image_data = info.context.FILES.get(raw_input['background_image'])
+ if data.get('background_image'):
+ image_data = info.context.FILES.get(data['background_image'])
validate_image_file(image_data, 'background_image')
clean_seo_fields(cleaned_input)
return cleaned_input
@@ -151,12 +151,12 @@ class CollectionCreate(ModelMutation):
return user.has_perm('product.manage_products')
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
if 'slug' not in cleaned_input and 'name' in cleaned_input:
cleaned_input['slug'] = slugify(cleaned_input['name'])
- if raw_input.get('background_image'):
- image_data = info.context.FILES.get(raw_input['background_image'])
+ if data.get('background_image'):
+ image_data = info.context.FILES.get(data['background_image'])
validate_image_file(image_data, 'background_image')
clean_seo_fields(cleaned_input)
return cleaned_input
@@ -321,8 +321,8 @@ class ProductCreate(ModelMutation):
model = models.Product
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
# Attributes are provided as list of `AttributeValueInput` objects.
# We need to transform them into the format they're stored in the
# `Product` model, which is HStore field that maps attribute's PK to
@@ -493,15 +493,15 @@ class ProductVariantCreate(ModelMutation):
fieldname: 'This field cannot be blank.'})
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
# Attributes are provided as list of `AttributeValueInput` objects.
# We need to transform them into the format they're stored in the
# `Product` model, which is HStore field that maps attribute's PK to
# the value's PK.
- if 'attributes' in raw_input:
+ if 'attributes' in data:
attributes_input = cleaned_input.pop('attributes')
product = instance.product if instance.pk else cleaned_input.get(
'product')
@@ -672,14 +672,14 @@ class ProductImageCreate(BaseMutation):
@classmethod
def perform_mutation(cls, _root, info, **data):
- raw_input = data.get('input')
+ data = data.get('input')
product = cls.get_node_or_error(
- info, raw_input['product'], field='product', only_type=Product)
- image_data = info.context.FILES.get(raw_input['image'])
+ info, data['product'], field='product', only_type=Product)
+ image_data = info.context.FILES.get(data['image'])
validate_image_file(image_data, 'image')
image = product.images.create(
- image=image_data, alt=raw_input.get('alt', ''))
+ image=image_data, alt=data.get('alt', ''))
create_product_thumbnails.delay(image.pk)
return ProductImageCreate(product=product, image=image)
diff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.py
index 4b7a3c36d1..97c75e1f5f 100644
--- a/saleor/graphql/shipping/mutations.py
+++ b/saleor/graphql/shipping/mutations.py
@@ -44,8 +44,8 @@ class ShippingZoneInput(graphene.InputObjectType):
class ShippingZoneMixin:
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
default = cleaned_input.get('default')
if default:
if default_shipping_zone_exists(instance.pk):
@@ -112,8 +112,8 @@ class ShippingZoneDelete(ModelDeleteMutation):
class ShippingPriceMixin:
@classmethod
- def clean_input(cls, info, instance, raw_input):
- cleaned_input = super().clean_input(info, instance, raw_input)
+ def clean_input(cls, info, instance, data):
+ cleaned_input = super().clean_input(info, instance, data)
cleaned_type = cleaned_input.get('type')
if cleaned_type:
if cleaned_type == ShippingMethodTypeEnum.PRICE.value:
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.py
index 9dc6ff828c..54705e4f22 100644
--- a/saleor/graphql/shop/mutations.py
+++ b/saleor/graphql/shop/mutations.py
@@ -54,8 +54,8 @@ class ShopSettingsUpdate(BaseMutation):
@classmethod
def perform_mutation(cls, _root, info, **data):
instance = info.context.site.settings
- raw_input = data.get('input')
- for field_name, desired_value in raw_input.items():
+ data = data.get('input')
+ for field_name, desired_value in data.items():
current_value = getattr(instance, field_name)
if current_value != desired_value:
setattr(instance, field_name, desired_value)
@@ -80,9 +80,9 @@ class ShopDomainUpdate(BaseMutation):
@classmethod
def perform_mutation(cls, _root, info, **data):
site = info.context.site
- raw_input = data.get('input')
- domain = raw_input.get('domain')
- name = raw_input.get('name')
+ data = data.get('input')
+ domain = data.get('domain')
+ name = data.get('name')
if domain is not None:
site.domain = domain
if name is not None: