Skip to content

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

Remove obsolete forms

akjanik286d1b3e321d
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index 8ce7551d2d..bbaecd22b0 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -80,7 +80,7 @@ class ModelMutation(BaseMutation):
def add_error(cls, errors, field, message):
"""Add an error to the errors list.
- `errors` is the list of errors that happend during execution of the
+ `errors` is the list of errors that happened during execution of the
mutation. `field` is the name of model field the error is related
to. `None` is allowed and it indicates that the error is a general one
and not related to any of the model fields. `message` is the actual
diff --git a/saleor/graphql/menu/forms.py b/saleor/graphql/menu/forms.py
deleted file mode 100644
index 8f160292cf..0000000000
--- a/saleor/graphql/menu/forms.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from django import forms
-
-from ...menu.models import Menu, MenuItem
-
-
-class MenuForm(forms.ModelForm):
- class Meta:
- model = Menu
- fields = ['name']
-
-
-class MenuItemForm(forms.ModelForm):
- class Meta:
- model = MenuItem
- fields = [
- 'menu', 'name', 'parent', 'url', 'category', 'collection', 'page']
diff --git a/saleor/graphql/menu/mutations.py b/saleor/graphql/menu/mutations.py
index ed55f920fd..b8629a82ad 100644
--- a/saleor/graphql/menu/mutations.py
+++ b/saleor/graphql/menu/mutations.py
@@ -90,13 +90,12 @@ class MenuItemCreate(ModelMutation):
items = list(filter(None.__ne__, items))
if len(items) > 1:
field = 'items'
- msg = 'More than one item provided'
- errors.append(
- Error(field=field, message=msg))
+ msg = 'More than one item provided.'
+ cls.add_error(field=field, message=msg)
return cleaned_input
-class MenuItemUpdate(ModelMutation):
+class MenuItemUpdate(MenuItemCreate):
class Arguments:
id = graphene.ID(
required=True, description='ID of a menu item to update.')
@@ -112,20 +111,6 @@ class MenuItemUpdate(ModelMutation):
def user_is_allowed(cls, user, input):
return user.has_perm('menu.edit_menu')
- @classmethod
- def clean_input(cls, info, instance, input, errors):
- cleaned_input = super().clean_input(info, instance, input, errors)
- items = [
- cleaned_input.get('page'), cleaned_input.get('collection'),
- cleaned_input.get('url'), cleaned_input.get('category')]
- items = list(filter(None.__ne__, items))
- if len(items) > 1:
- field = 'items'
- msg = 'More than one item provided'
- errors.append(
- Error(field=field, message=msg))
- return cleaned_input
-
@classmethod
def construct_instance(cls, instance, cleaned_data):
# Only one item can be assigned per menu item