Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard-1 no longer fails when updating an order address phone number #4061

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Remove unused decorator - #4036 by @maarcingebala
- Overall improvement of the GraphQL performances, especially on single nodes - #3968 @NyanKiyoshi
- Remove unnecessary dedents from GraphQL schema so new Playground can work - #4045 by @salwator
- Fix crash on dashboard 1.0 when updating an order address's phone number - #4061 by @NyanKiyoshi


## 2.5.0
Expand Down
10 changes: 1 addition & 9 deletions saleor/dashboard/order/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from django.utils.translation import npgettext_lazy, pgettext_lazy

from ...account.i18n import (
AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField,
clean_phone_for_country)
AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField)
from ...account.models import User
from ...checkout.forms import QuantityField
from ...core.exceptions import InsufficientStock
Expand Down Expand Up @@ -591,13 +590,6 @@ class AddressForm(StorefrontAddressForm):

def clean(self):
data = super().clean()
phone = data.get('phone')
country = data.get('country')
if phone:
try:
data['phone'] = clean_phone_for_country(phone, country)
except forms.ValidationError as error:
self.add_error('phone', error)
return data


Expand Down
28 changes: 28 additions & 0 deletions tests/dashboard/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
from django.urls import reverse
from phonenumber_field.phonenumber import PhoneNumber
from prices import Money

from saleor.checkout import AddressType
Expand Down Expand Up @@ -750,6 +751,33 @@ def test_view_order_shipping_edit_not_draft_order(
assert response.status_code == 404


def test_view_order_address_edit(
admin_client, order_with_lines, address_other_country):

order = order_with_lines
new_address = address_other_country

new_address.phone = PhoneNumber.from_string(
region=new_address.country.code, phone_number='+33.600000000')

address_data = new_address.as_data()
address_data.pop('phone')

address_data.update({
'phone_0': '+33',
'phone_1': '600000000'})

url = reverse(
'dashboard:address-edit',
kwargs={'order_pk': order.pk, 'address_type': 'shipping'})

response = admin_client.post(url, address_data)
assert response.status_code == 302

order.refresh_from_db(fields=['shipping_address'])
assert new_address.as_data() == order.shipping_address.as_data()


def test_view_order_shipping_remove(admin_client, draft_order):
url = reverse(
'dashboard:order-shipping-remove', kwargs={'order_pk': draft_order.pk})
Expand Down