Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move BaseNote content to CustomerNote
Pacu29184564ee5f9
diff --git a/saleor/account/models.py b/saleor/account/models.pyindex 6f46580892..e889e9da83 100644--- a/saleor/account/models.py+++ b/saleor/account/models.py@@ -11,7 +11,6 @@ from django.utils.translation import pgettext_lazyfrom django_countries.fields import Country, CountryFieldfrom phonenumber_field.modelfields import PhoneNumber, PhoneNumberField-from ..core.models import BaseNotefrom .validators import validate_possible_number@@ -153,7 +152,13 @@ class User(PermissionsMixin, AbstractBaseUser):return self.email-class CustomerNote(BaseNote):+class CustomerNote(models.Model):+ user = models.ForeignKey(+ settings.AUTH_USER_MODEL, blank=True, null=True,+ on_delete=models.SET_NULL)+ date = models.DateTimeField(db_index=True, auto_now_add=True)+ content = models.TextField()+ is_public = models.BooleanField(default=True)customer = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='notes',on_delete=models.CASCADE)diff --git a/saleor/core/models.py b/saleor/core/models.pyindex 6802055350..70cf9945c4 100644--- a/saleor/core/models.py+++ b/saleor/core/models.py@@ -3,18 +3,6 @@ from django.db import modelsfrom django.db.models import F, Max-class BaseNote(models.Model):- user = models.ForeignKey(- settings.AUTH_USER_MODEL, blank=True, null=True,- on_delete=models.SET_NULL)- date = models.DateTimeField(db_index=True, auto_now_add=True)- content = models.TextField()- is_public = models.BooleanField(default=True)-- class Meta:- abstract = True--class SortableModel(models.Model):sort_order = models.PositiveIntegerField(editable=False, db_index=True)diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.pyindex 521be66d15..67fee4475a 100644--- a/saleor/graphql/account/mutations.py+++ b/saleor/graphql/account/mutations.py@@ -45,13 +45,6 @@ class CustomerInput(UserInput):description='Shipping address of the customer.')-class CustomerInput(UserInput):- default_billing_address = AddressInput(- description='Billing address of the customer.')- default_shipping_address = AddressInput(- description='Shipping address of the customer.')--class UserCreateInput(CustomerInput):send_password_email = graphene.Boolean(description='Send an email with a link to set a password')diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.pyindex db07c83dae..8d70e1eb7d 100644--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@ -9,7 +9,7 @@ from ...account.types import AddressInputfrom ...core.mutations import BaseMutation, ModelMutationfrom ...core.types.common import Decimal, Errorfrom ...order.mutations.draft_orders import DraftOrderUpdate-from ...order.types import Order, OrderEventsEnum+from ...order.types import Orderdef try_payment_action(action, money, errors):@@ -63,52 +63,21 @@ class OrderUpdate(DraftOrderUpdate):class OrderAddNoteInput(graphene.InputObjectType):- order = graphene.ID(description='ID of the order.', name='order')user = graphene.ID(- description='ID of the user who added note.', name='user')- content = graphene.String(description='Note content.')+ description='ID of the user who added the note.', name='user')+ content = graphene.String(description='Note content.', name='content')+ order = graphene.ID(description='ID of the order.', name='order')class OrderAddNote(ModelMutation):- class Arguments:- input = OrderAddNoteInput(- required=True,- description='Fields required to add note to order.')-class Meta:description = 'Adds note to order.'model = models.OrderEvent+ exclude = ['date', 'type', 'order']- @classmethod- def user_is_allowed(cls, user, input):- return user.has_perm('order.manage_orders')-- @classmethod- def save(cls, info, instance, cleaned_input):- super().save(info, instance, cleaned_input)- instance.order.events.create(- type=OrderEvents.NOTE_ADDED.value,- user=info.context.user)---class OrderAddEventInput(graphene.InputObjectType):- order = graphene.ID(description='ID of the order.', name='order')- user = graphene.ID(- description='ID of the user who performed the changes.',- name='user')- content = graphene.String(description='Note content.')- event = OrderEventsEnum(description='Type of an event.')---class OrderAddEvent(ModelMutation):class Arguments:input = OrderAddNoteInput(- required=True,- description='Fields required to add note to order.')-- class Meta:- description = 'Adds note to order.'- model = models.OrderEvent+ description='Fields required to add note to the order.')@classmethoddef user_is_allowed(cls, user, input):@@ -116,10 +85,11 @@ class OrderAddEvent(ModelMutation):@classmethoddef save(cls, info, instance, cleaned_input):+ cleaned_input['type'] = OrderEvents.NOTE_ADDED.value+ cleaned_input['user'] = info.context.user+ cleaned_input['parameters'] = {+ 'message': cleaned_input.pop('content', 'KURWA')}super().save(info, instance, cleaned_input)- instance.order.events.create(- type=OrderEvents.NOTE_ADDED.value,- user=info.context.user)class OrderCancel(BaseMutation):