Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove calls to django.core.urlsolvers, specify on_delete
Patryk Zawadzki9102140bfc3e
diff --git a/saleor/cart/models.py b/saleor/cart/models.pyindex c205bf5e2b..fe62388be6 100644--- a/saleor/cart/models.py+++ b/saleor/cart/models.py@@ -93,7 +93,8 @@ class Cart(models.Model):pgettext_lazy('Cart field', 'last status change'), auto_now_add=True)user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='carts',- verbose_name=pgettext_lazy('Cart field', 'user'))+ verbose_name=pgettext_lazy('Cart field', 'user'),+ on_delete=models.CASCADE)email = models.EmailField(pgettext_lazy('Cart field', 'email'), blank=True, null=True)token = models.UUIDField(@@ -254,10 +255,12 @@ class CartLine(models.Model, ItemLine):cart = models.ForeignKey(Cart, related_name='lines',- verbose_name=pgettext_lazy('Cart line field', 'cart'))+ verbose_name=pgettext_lazy('Cart line field', 'cart'),+ on_delete=models.CASCADE)variant = models.ForeignKey('product.ProductVariant', related_name='+',- verbose_name=pgettext_lazy('Cart line field', 'product'))+ verbose_name=pgettext_lazy('Cart line field', 'product'),+ on_delete=models.CASCADE)quantity = models.PositiveIntegerField(pgettext_lazy('Cart line field', 'quantity'),validators=[MinValueValidator(0), MaxValueValidator(999)])diff --git a/saleor/cart/views.py b/saleor/cart/views.pyindex b7a5caf787..f877e80477 100644--- a/saleor/cart/views.py+++ b/saleor/cart/views.py@@ -1,19 +1,19 @@"""Cart-related views."""from __future__ import unicode_literals-from django_babel.templatetags.babel import currencyfmt-from django.core.urlresolvers import reversefrom django.http import JsonResponsefrom django.shortcuts import get_object_or_404, redirect, renderfrom django.template.response import TemplateResponse+from django.urls import reverse+from django_babel.templatetags.babel import currencyfmt-from ..core.utils import to_local_currency, get_user_shipping_country+from ..core.utils import get_user_shipping_country, to_local_currencyfrom ..product.models import ProductVariantfrom ..shipping.utils import get_shipment_options-from .forms import ReplaceCartLineForm, CountryForm+from .forms import CountryForm, ReplaceCartLineFormfrom .models import Cart-from .utils import (check_product_availability_and_warn, get_or_empty_db_cart,- get_cart_data)+from .utils import (+ check_product_availability_and_warn, get_cart_data, get_or_empty_db_cart)@get_or_empty_db_cart(cart_queryset=Cart.objects.for_display())diff --git a/saleor/core/context_processors.py b/saleor/core/context_processors.pyindex 51d843247c..b8a1c5fd4c 100644--- a/saleor/core/context_processors.py+++ b/saleor/core/context_processors.py@@ -4,7 +4,7 @@ import jsonfrom django.conf import settingsfrom django.contrib.sites.shortcuts import get_current_site-from django.core.urlresolvers import reverse+from django.urls import reversefrom ..core.utils import build_absolute_urifrom ..product.models import Categorydiff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.pyindex 939908976a..6cd1996766 100644--- a/saleor/dashboard/category/views.py+++ b/saleor/dashboard/category/views.py@@ -1,9 +1,9 @@from django.contrib import messagesfrom django.contrib.auth.decorators import permission_required-from django.core.urlresolvers import reversefrom django.http import JsonResponsefrom django.shortcuts import get_object_or_404, redirectfrom django.template.response import TemplateResponse+from django.urls import reversefrom django.utils.translation import pgettext_lazyfrom ...core.utils import get_paginator_itemsdiff --git a/saleor/discount/models.py b/saleor/discount/models.pyindex ea8356e33f..6d50f31453 100644--- a/saleor/discount/models.py+++ b/saleor/discount/models.py@@ -1,19 +1,20 @@from __future__ import unicode_literals+from datetime import datefrom decimal import Decimalfrom django.conf import settingsfrom django.db import modelsfrom django.db.models import F-from django.utils.translation import pgettext, pgettext_lazyfrom django.utils.encoding import python_2_unicode_compatible, smart_text+from django.utils.translation import pgettext, pgettext_lazyfrom django_countries import countriesfrom django_prices.models import PriceFieldfrom django_prices.templatetags.prices_i18n import net-from prices import FixedDiscount, percentage_discount, Price+from prices import FixedDiscount, Price, percentage_discountfrom ..cart.utils import (- get_product_variants_and_prices, get_category_variants_and_prices)+ get_category_variants_and_prices, get_product_variants_and_prices)class NotApplicable(ValueError):@@ -114,10 +115,12 @@ class Voucher(models.Model):# not mandatory fields, usage depends on typeproduct = models.ForeignKey('product.Product', blank=True, null=True,- verbose_name=pgettext_lazy('Voucher field', 'product'))+ verbose_name=pgettext_lazy('Voucher field', 'product'),+ on_delete=models.CASCADE)category = models.ForeignKey('product.Category', blank=True, null=True,- verbose_name=pgettext_lazy('Voucher field', 'category'))+ verbose_name=pgettext_lazy('Voucher field', 'category'),+ on_delete=models.CASCADE)apply_to = models.CharField(pgettext_lazy('Voucher field', 'apply to'),max_length=20, blank=True, null=True)diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 953e499ff4..8a7ff12eb1 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -5,25 +5,24 @@ from uuid import uuid4from django.conf import settingsfrom django.core.exceptions import ObjectDoesNotExist-from django.core.urlresolvers import reversefrom django.core.validators import MaxValueValidator, MinValueValidatorfrom django.db import models+from django.urls import reversefrom django.utils.encoding import python_2_unicode_compatiblefrom django.utils.timezone import nowfrom django.utils.translation import pgettext_lazyfrom django_prices.models import PriceFieldfrom payments import PaymentStatus, PurchasedItemfrom payments.models import BasePayment-from prices import Price, FixedDiscount+from prices import FixedDiscount, Pricefrom satchless.item import ItemLine, ItemSet+from . import OrderStatus, emailsfrom ..core.utils import build_absolute_urifrom ..discount.models import Voucherfrom ..product.models import Product-from ..userprofile.models import Addressfrom ..search import index-from . import OrderStatus-from . import emails+from ..userprofile.models import Addressclass OrderManager(models.Manager):diff --git a/saleor/product/migrations/0036_auto_20171109_1308.py b/saleor/product/migrations/0036_auto_20171109_1308.pynew file mode 100644index 0000000000..0cb949e8f6--- /dev/null+++ b/saleor/product/migrations/0036_auto_20171109_1308.py@@ -0,0 +1,26 @@+# -*- coding: utf-8 -*-+# Generated by Django 1.11.5 on 2017-11-09 19:08+from __future__ import unicode_literals++from django.db import migrations, models+import django.db.models.deletion+++class Migration(migrations.Migration):++ dependencies = [+ ('product', '0035_auto_20170919_0846'),+ ]++ operations = [+ migrations.AlterField(+ model_name='product',+ name='product_class',+ field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='products', to='product.ProductClass', verbose_name='product class'),+ ),+ migrations.AlterField(+ model_name='stock',+ name='location',+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='product.StockLocation'),+ ),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex ce4108aa72..f474d2c4d6 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -5,25 +5,24 @@ from decimal import Decimalfrom django.conf import settingsfrom django.contrib.postgres.fields import HStoreField-from django.core.urlresolvers import reversefrom django.core.validators import MinValueValidator, RegexValidatorfrom django.db import modelsfrom django.db.models import F, Max, Q+from django.urls import reverse+from django.utils import sixfrom django.utils.encoding import python_2_unicode_compatible, smart_textfrom django.utils.text import slugifyfrom django.utils.translation import pgettext_lazy-from django.utils import sixfrom django_prices.models import Price, PriceFieldfrom mptt.managers import TreeManagerfrom mptt.models import MPTTModelfrom prices import PriceRangefrom satchless.item import InsufficientStock, Item, ItemRangefrom text_unidecode import unidecode-from versatileimagefield.fields import VersatileImageField, PPOIField+from versatileimagefield.fields import PPOIField, VersatileImageFieldfrom ..discount.models import calculate_discounted_pricefrom ..search import index-from ..settings import DEFAULT_CURRENCYfrom .utils import get_attributes_display_map@@ -37,7 +36,8 @@ class Category(MPTTModel):pgettext_lazy('Category field', 'description'), blank=True)parent = models.ForeignKey('self', null=True, blank=True, related_name='children',- verbose_name=pgettext_lazy('Category field', 'parent'))+ verbose_name=pgettext_lazy('Category field', 'parent'),+ on_delete=models.CASCADE)hidden = models.BooleanField(pgettext_lazy('Category field', 'hidden'), default=False)@@ -86,7 +86,8 @@ class ProductClass(models.Model):'product attributes'))variant_attributes = models.ManyToManyField('ProductAttribute', related_name='product_variants_class', blank=True,- verbose_name=pgettext_lazy('Product class field', 'variant attributes'))+ verbose_name=pgettext_lazy(+ 'Product class field', 'variant attributes'))is_shipping_required = models.BooleanField(pgettext_lazy('Product class field', 'is shipping required'),default=False)@@ -113,14 +114,15 @@ class ProductManager(models.Manager):today = datetime.date.today()return self.get_queryset().filter(Q(available_on__lte=today) | Q(available_on__isnull=True)).filter(- is_published=True)+ is_published=True)@python_2_unicode_compatibleclass Product(models.Model, ItemRange, index.Indexed):product_class = models.ForeignKey(ProductClass, related_name='products',- verbose_name=pgettext_lazy('Product field', 'product class'))+ verbose_name=pgettext_lazy('Product field', 'product class'),+ on_delete=models.PROTECT)name = models.CharField(pgettext_lazy('Product field', 'name'), max_length=128)description = models.TextField(@@ -227,7 +229,8 @@ class Product(models.Model, ItemRange, index.Indexed):@python_2_unicode_compatibleclass ProductVariant(models.Model, Item):sku = models.CharField(- pgettext_lazy('Product variant field', 'SKU'), max_length=32, unique=True)+ pgettext_lazy('Product variant field', 'SKU'), max_length=32,+ unique=True)name = models.CharField(pgettext_lazy('Product variant field', 'variant name'), max_length=100,blank=True)@@ -235,7 +238,8 @@ class ProductVariant(models.Model, Item):pgettext_lazy('Product variant field', 'price override'),currency=settings.DEFAULT_CURRENCY, max_digits=12, decimal_places=2,blank=True, null=True)- product = models.ForeignKey(Product, related_name='variants')+ product = models.ForeignKey(+ Product, related_name='variants', on_delete=models.CASCADE)attributes = HStoreField(pgettext_lazy('Product variant field', 'attributes'), default={})images = models.ManyToManyField(@@ -244,8 +248,10 @@ class ProductVariant(models.Model, Item):class Meta:app_label = 'product'- verbose_name = pgettext_lazy('Product variant model', 'product variant')- verbose_name_plural = pgettext_lazy('Product variant model', 'product variants')+ verbose_name = pgettext_lazy(+ 'Product variant model', 'product variant')+ verbose_name_plural = pgettext_lazy(+ 'Product variant model', 'product variants')def __str__(self):return self.name or self.display_variant()@@ -367,8 +373,10 @@ class StockManager(models.Manager):class Stock(models.Model):variant = models.ForeignKey(ProductVariant, related_name='stock',- verbose_name=pgettext_lazy('Stock item field', 'variant'))- location = models.ForeignKey(StockLocation, null=True)+ verbose_name=pgettext_lazy('Stock item field', 'variant'),+ on_delete=models.CASCADE)+ location = models.ForeignKey(+ StockLocation, null=True, on_delete=models.PROTECT)quantity = models.IntegerField(pgettext_lazy('Stock item field', 'quantity'),validators=[MinValueValidator(0)], default=Decimal(1))@@ -405,8 +413,10 @@ class ProductAttribute(models.Model):class Meta:ordering = ('slug', )- verbose_name = pgettext_lazy('Product attribute model', 'product attribute')- verbose_name_plural = pgettext_lazy('Product attribute model', 'product attributes')+ verbose_name = pgettext_lazy(+ 'Product attribute model', 'product attribute')+ verbose_name_plural = pgettext_lazy(+ 'Product attribute model', 'product attributes')def __str__(self):return self.name@@ -429,7 +439,8 @@ class AttributeChoiceValue(models.Model):max_length=7,validators=[RegexValidator('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')],blank=True)- attribute = models.ForeignKey(ProductAttribute, related_name='values')+ attribute = models.ForeignKey(+ ProductAttribute, related_name='values', on_delete=models.CASCADE)class Meta:unique_together = ('name', 'attribute')@@ -455,7 +466,8 @@ class ImageManager(models.Manager):class ProductImage(models.Model):product = models.ForeignKey(Product, related_name='images',- verbose_name=pgettext_lazy('Product image field', 'product'))+ verbose_name=pgettext_lazy('Product image field', 'product'),+ on_delete=models.CASCADE)image = VersatileImageField(upload_to='products', ppoi_field='ppoi', blank=False,verbose_name=pgettext_lazy('Product image field', 'image'))@@ -473,7 +485,8 @@ class ProductImage(models.Model):ordering = ('order', )app_label = 'product'verbose_name = pgettext_lazy('Product image model', 'product image')- verbose_name_plural = pgettext_lazy('Product image model', 'product images')+ verbose_name_plural = pgettext_lazy(+ 'Product image model', 'product images')def get_ordering_queryset(self):return self.product.images.all()@@ -495,10 +508,12 @@ class ProductImage(models.Model):class VariantImage(models.Model):variant = models.ForeignKey('ProductVariant', related_name='variant_images',- verbose_name=pgettext_lazy('Variant image field', 'variant'))+ verbose_name=pgettext_lazy('Variant image field', 'variant'),+ on_delete=models.CASCADE)image = models.ForeignKey(ProductImage, related_name='variant_images',- verbose_name=pgettext_lazy('Variant image field', 'image'))+ verbose_name=pgettext_lazy('Variant image field', 'image'),+ on_delete=models.CASCADE)class Meta:verbose_name = pgettext_lazy(diff --git a/saleor/product/views.py b/saleor/product/views.pyindex a1f8841619..88d3457c5a 100644--- a/saleor/product/views.py+++ b/saleor/product/views.py@@ -3,22 +3,20 @@ from __future__ import unicode_literalsimport datetimeimport json-from django.core.urlresolvers import reversefrom django.http import HttpResponsePermanentRedirect, JsonResponsefrom django.shortcuts import get_object_or_404, redirectfrom django.template.response import TemplateResponse+from django.urls import reverse-from .filters import (get_now_sorted_by, get_sort_by_choices,- ProductFilter)-from .models import Category-from .utils import (products_with_details, products_for_cart,- handle_cart_form, get_availability,- get_product_images, get_variant_picker_data,- get_product_attributes_data,- product_json_ld, products_with_availability)from ..cart.utils import set_cart_cookiefrom ..core.utils import get_paginator_items, serialize_decimalfrom ..settings import PAGINATE_BY+from .filters import ProductFilter, get_now_sorted_by, get_sort_by_choices+from .models import Category+from .utils import (+ get_availability, get_product_attributes_data, get_product_images,+ get_variant_picker_data, handle_cart_form, product_json_ld,+ products_for_cart, products_with_availability, products_with_details)def product_details(request, slug, product_id, form=None):diff --git a/saleor/registration/forms.py b/saleor/registration/forms.pyindex 57bc431675..f7ac59d83d 100644--- a/saleor/registration/forms.py+++ b/saleor/registration/forms.py@@ -1,9 +1,8 @@from django import formsfrom django.contrib.auth import forms as django_forms-from django.core.urlresolvers import reversefrom django.http.request import HttpRequest+from django.urls import reversefrom django.utils.translation import pgettext-from templated_email import send_templated_mailfrom saleor.userprofile.models import Userdiff --git a/saleor/registration/views.py b/saleor/registration/views.pyindex 4f81f35d3a..da0836b8c4 100644--- a/saleor/registration/views.py+++ b/saleor/registration/views.py@@ -1,13 +1,14 @@-from django.core.urlresolvers import reverse_lazyfrom django.conf import settings-from django.contrib import messages, auth+from django.contrib import auth, messagesfrom django.contrib.auth import views as django_viewsfrom django.contrib.auth.decorators import login_requiredfrom django.shortcuts import redirect-from django.utils.translation import ugettext_lazy as _from django.template.response import TemplateResponse+from django.urls import reverse_lazy+from django.utils.translation import ugettext_lazy as _from saleor.cart.utils import find_and_assign_anonymous_cart+from .forms import LoginForm, PasswordSetUpForm, SignupFormdiff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex ee30cf7662..fcc7bcb5f6 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -52,17 +52,20 @@ class ShippingMethodCountryQueryset(models.QuerySet):Q(country_code=country_code) |Q(country_code=ANY_COUNTRY))shipping = shipping.order_by('shipping_method_id')- shipping = shipping.values_list('shipping_method_id', 'id', 'country_code')+ shipping = shipping.values_list(+ 'shipping_method_id', 'id', 'country_code')grouped_shipping = groupby(shipping, itemgetter(0))any_country = ANY_COUNTRYids = []- for shipping_method_id, method_values in grouped_shipping:+ for dummy_method_id, method_values in grouped_shipping:method_values = list(method_values)- # if there is any country choice and specific one remove any country choice+ # if there is any country choice and specific one remove any+ # country choiceif len(method_values) == 2:- method = [val for val in method_values if val[2] != any_country][0]+ method = [+ val for val in method_values if val[2] != any_country][0]else:method = method_values[0]ids.append(method[1])@@ -74,13 +77,16 @@ class ShippingMethodCountry(models.Model):country_code = models.CharField(pgettext_lazy('Shipping method country field', 'country code'),- choices=COUNTRY_CODE_CHOICES, max_length=2, blank=True, default=ANY_COUNTRY)+ choices=COUNTRY_CODE_CHOICES, max_length=2, blank=True,+ default=ANY_COUNTRY)price = PriceField(pgettext_lazy('Shipping method country field', 'price'),currency=settings.DEFAULT_CURRENCY, max_digits=12, decimal_places=2)shipping_method = models.ForeignKey(ShippingMethod, related_name='price_per_country',- verbose_name=pgettext_lazy('Shipping method country field', 'shipping method'),)+ verbose_name=pgettext_lazy(+ 'Shipping method country field', 'shipping method'),+ on_delete=models.CASCADE)objects = ShippingMethodCountryQueryset.as_manager()@@ -93,7 +99,8 @@ class ShippingMethodCountry(models.Model):def __str__(self):# https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_display # noqa- return '%s %s' % (self.shipping_method, self.get_country_code_display())+ return '%s %s' % (+ self.shipping_method, self.get_country_code_display())def get_total(self):return self.price@@ -113,7 +120,7 @@ class ShippingCountryQueryset(models.QuerySet):ids = []- for shipping_method_id, method_values in grouped_shipping:+ for dummy_method_id, method_values in grouped_shipping:method_values = list(method_values)# if there is any country choice and specific one remove any# country choicediff --git a/saleor/site/patch_sites.py b/saleor/site/patch_sites.pyindex cbc45c0a5f..3bc432cf28 100644--- a/saleor/site/patch_sites.py+++ b/saleor/site/patch_sites.py@@ -7,7 +7,7 @@ from __future__ import unicode_literalsimport threading-from django.contrib.sites.models import SiteManager+from django.contrib.sites.models import Site, SiteManagerfrom django.core.exceptions import ImproperlyConfiguredfrom django.http.request import split_domain_port@@ -37,7 +37,7 @@ def new_get_current(self, request=None):return THREADED_SITE_CACHE[host]except Site.DoesNotExist:# Fallback to looking up site after stripping port from the host.- domain, port = split_domain_port(host)+ domain, dummy_port = split_domain_port(host)if domain not in THREADED_SITE_CACHE:with lock:site = self.prefetch_related('settings').filter(diff --git a/saleor/userprofile/i18n.py b/saleor/userprofile/i18n.pyindex 2ba03f9ac3..913fab134a 100644--- a/saleor/userprofile/i18n.py+++ b/saleor/userprofile/i18n.py@@ -3,7 +3,7 @@ from collections import defaultdictimport i18naddressfrom django import formsfrom django.forms.forms import BoundField-from django.utils.translation import pgettext_lazy, pgettext+from django.utils.translation import pgettext, pgettext_lazyfrom django_countries.data import COUNTRIESfrom .models import Addressdiff --git a/saleor/userprofile/views.py b/saleor/userprofile/views.pyindex 3357bc1daf..29c873b793 100755--- a/saleor/userprofile/views.py+++ b/saleor/userprofile/views.py@@ -1,12 +1,13 @@from django.contrib import messagesfrom django.contrib.auth.decorators import login_required-from django.core.urlresolvers import reversefrom django.http import HttpResponseRedirectfrom django.shortcuts import get_object_or_404from django.template.response import TemplateResponse+from django.urls import reversefrom django.utils.translation import pgettext-from .forms import (ChangePasswordForm, get_address_form,- logout_on_password_change)++from .forms import (+ ChangePasswordForm, get_address_form, logout_on_password_change)@login_requireddiff --git a/tests/dashboard/test_customer.py b/tests/dashboard/test_customer.pyindex 1a8a411b36..02d60ec656 100644--- a/tests/dashboard/test_customer.py+++ b/tests/dashboard/test_customer.py@@ -1,6 +1,6 @@from __future__ import unicode_literals-from django.core.urlresolvers import reverse+from django.urls import reversefrom saleor.userprofile.models import Userdiff --git a/tests/dashboard/test_group.py b/tests/dashboard/test_group.pyindex 92479d73d5..8baec6058f 100644--- a/tests/dashboard/test_group.py+++ b/tests/dashboard/test_group.py@@ -1,7 +1,7 @@from __future__ import unicode_literals-from django.core.urlresolvers import reversefrom django.contrib.auth.models import Group+from django.urls import reversefrom saleor.dashboard.group.forms import GroupPermissionsFormdiff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 6e5662dd6d..05c4577523 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -1,13 +1,13 @@from __future__ import unicode_literals-import mockimport pytest-from django.core.urlresolvers import reverse+from django.urls import reverse+from saleor.dashboard.order.forms import ChangeQuantityForm, MoveItemsForm-from saleor.order.models import (Order, OrderHistoryEntry, OrderedItem,- DeliveryGroup)+from saleor.order.models import (+ DeliveryGroup, Order, OrderedItem, OrderHistoryEntry)from saleor.order.utils import add_items_to_delivery_group-from saleor.product.models import Stock, ProductVariant+from saleor.product.models import ProductVariant, Stockfrom tests.utils import get_redirect_location, get_url_pathdiff --git a/tests/dashboard/test_permissions.py b/tests/dashboard/test_permissions.pyindex 068bee8541..6c8f5bbd6c 100644--- a/tests/dashboard/test_permissions.py+++ b/tests/dashboard/test_permissions.py@@ -1,6 +1,6 @@from __future__ import unicode_literals-from django.core.urlresolvers import reverse+from django.urls import reversefrom saleor.userprofile.models import Userdiff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex f56f0df13a..e4217c7de0 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -1,13 +1,14 @@# -*- coding: utf-8 -*-from __future__ import unicode_literals-from io import BytesIOimport json+from io import BytesIO+import pytest-from PIL import Imagefrom django.core.files.uploadedfile import SimpleUploadedFile-from django.core.urlresolvers import reverse+from django.urls import reversefrom django.utils.encoding import smart_text+from PIL import Imagefrom saleor.dashboard.product import ProductBulkActionfrom saleor.dashboard.product.forms import (@@ -16,7 +17,6 @@ from saleor.product.models import (Product, ProductAttribute, ProductClass, ProductImage, ProductVariant,Stock, StockLocation)-HTTP_STATUS_OK = 200HTTP_REDIRECTION = 302diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.pyindex 21e0b39438..0e686eca14 100644--- a/tests/dashboard/test_staff.py+++ b/tests/dashboard/test_staff.py@@ -1,17 +1,16 @@from __future__ import unicode_literals-from django.core import mail-from django.core.urlresolvers import reverse-from django.contrib.auth.tokens import default_token_generatorfrom django.contrib.sites.models import Site+from django.core import mail+from django.urls import reversefrom django.utils.encoding import force_bytesfrom django.utils.http import urlsafe_base64_encodefrom templated_email import send_templated_mailfrom saleor.dashboard.staff.forms import StaffForm-from saleor.userprofile.models import Userfrom saleor.settings import DEFAULT_FROM_EMAIL+from saleor.userprofile.models import Userdef test_staff_form_not_valid(db):diff --git a/tests/dashboard/test_utils.py b/tests/dashboard/test_utils.pyindex 4341749c84..cee28ff8db 100644--- a/tests/dashboard/test_utils.py+++ b/tests/dashboard/test_utils.py@@ -1,6 +1,5 @@-import pytest-from django.core.urlresolvers import reversefrom django.test.client import RequestFactory+from django.urls import reversefrom saleor.dashboard.templatetags.utils import construct_get_query, paginatediff --git a/tests/test_cart.py b/tests/test_cart.pyindex 44755a14d0..22fb632bdc 100644--- a/tests/test_cart.py+++ b/tests/test_cart.py@@ -7,8 +7,8 @@ import pytestfrom django.contrib.auth.models import AnonymousUserfrom django.core import signingfrom django.core.exceptions import ObjectDoesNotExist-from django.core.urlresolvers import reversefrom django.http import HttpResponse+from django.urls import reversefrom django_babel.templatetags.babel import currencyfmtfrom mock import MagicMock, Mockfrom prices import Pricediff --git a/tests/test_checkout_integration.py b/tests/test_checkout_integration.pyindex 8ade191eaa..a805dd8e7a 100644--- a/tests/test_checkout_integration.py+++ b/tests/test_checkout_integration.py@@ -1,4 +1,4 @@-from django.core.urlresolvers import reverse+from django.urls import reversefrom payments import FraudStatus, PaymentStatusfrom saleor.userprofile.models import Userdiff --git a/tests/test_product.py b/tests/test_product.pyindex 8ec9f8d550..4381328b1b 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -1,19 +1,18 @@import datetime-from mock import Mockimport pytest--from django.core.urlresolvers import reverse+from django.urls import reversefrom django.utils.encoding import smart_text+from mock import Mock-from saleor.cart.models import Cartfrom saleor.cart import CartStatus, utils-+from saleor.cart.models import Cartfrom saleor.product import (- models, ProductAvailabilityStatus, VariantAvailabilityStatus)+ ProductAvailabilityStatus, VariantAvailabilityStatus, models)from saleor.product.utils import (- get_attributes_display_map, get_availability, get_variant_picker_data,- get_product_availability_status, get_variant_availability_status)+ get_attributes_display_map, get_availability,+ get_product_availability_status, get_variant_availability_status,+ get_variant_picker_data)from tests.utils import filter_products_by_attribute@@ -454,4 +453,3 @@ def test_get_variant_picker_data_proper_variant_count(product_in_stock):product_in_stock, discounts=None, local_currency=None)assert len(data['variantAttributes'][0]['values']) == 1-diff --git a/tests/test_registration.py b/tests/test_registration.pyindex 343f6444e5..6dfb9c5abe 100644--- a/tests/test_registration.py+++ b/tests/test_registration.py@@ -1,11 +1,11 @@import pytest-from django.contrib.auth import get_user_modelfrom django.contrib.auth.models import AnonymousUser-from django.core.urlresolvers import reverse+from django.urls import reverse-from saleor.registration.forms import LoginForm, SignupFormfrom saleor.registration.backends import BaseBackend+from saleor.registration.forms import LoginForm, SignupForm+from .utils import get_redirect_locationUser = get_user_model()diff --git a/tests/test_site_settings.py b/tests/test_site_settings.pyindex def6d7bde5..4f9b2551f3 100644--- a/tests/test_site_settings.py+++ b/tests/test_site_settings.py@@ -1,14 +1,13 @@import pytest-from django.contrib.sites.models import Site-from django.core.urlresolvers import reversefrom django.db.utils import IntegrityErrorfrom django.test.client import RequestFactory+from django.urls import reversefrom django.utils.encoding import smart_text+from saleor.dashboard.sites.forms import SiteForm, SiteSettingFormfrom saleor.site import utilsfrom saleor.site.models import AuthorizationKey, SiteSettings-from saleor.dashboard.sites.forms import SiteSettingForm, SiteFormdef test_index_view(admin_client, site_settings):