Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop Djanog Auth
fowczrek72c120ae8eeb
diff --git a/saleor/account/migrations/0055_alter_user_options.py b/saleor/account/migrations/0055_alter_user_options.pyindex a55734be2e..ec5e58f7ba 100644--- a/saleor/account/migrations/0055_alter_user_options.py+++ b/saleor/account/migrations/0055_alter_user_options.py@@ -4,10 +4,11 @@ from django.db import migrationsfrom django.db.models.signals import post_migrate-def assing_permissions(apps, schema_editor):+def assign_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Group = apps.get_model("auth", "Group")- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Group = apps.get_model("account", "Group")+ Permission = apps.get_model("permission", "Permission")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(app_label="account", model="user")@@ -44,5 +45,5 @@ class Migration(migrations.Migration):),},),- migrations.RunPython(assing_permissions, migrations.RunPython.noop),+ migrations.RunPython(assign_permissions, migrations.RunPython.noop),]diff --git a/saleor/account/migrations/0071_group.py b/saleor/account/migrations/0071_group.pyindex 37c3cd36a0..45c52aa665 100644--- a/saleor/account/migrations/0071_group.py+++ b/saleor/account/migrations/0071_group.py@@ -5,13 +5,13 @@ import saleor.account.models# Forward helpersdef rename_group_tables(apps, schema_editor):- Permission = apps.get_model("auth", "Group")+ Group = apps.get_model("auth", "Group")schema_editor.alter_db_table(- Permission,+ Group,"auth_group","account_group",)- PermissionGroup = Permission.permissions.through+ PermissionGroup = Group.permissions.throughschema_editor.alter_db_table(PermissionGroup,"auth_group_permissions",@@ -33,13 +33,13 @@ ALTER INDEX IF EXISTS auth_group_name_a6ea08ec_like# Reverse helpersdef rename_group_tables_reverse(apps, schema_editor):- Permission = apps.get_model("auth", "Group")+ Group = apps.get_model("auth", "Group")schema_editor.alter_db_table(- Permission,+ Group,"account_group","auth_group",)- PermissionGroup = Permission.permissions.through+ PermissionGroup = Group.permissions.throughschema_editor.alter_db_table(PermissionGroup,"account_group_permissions",diff --git a/saleor/account/models.py b/saleor/account/models.pyindex 486a09188a..5166bc4ef2 100644--- a/saleor/account/models.py+++ b/saleor/account/models.py@@ -3,8 +3,7 @@ from typing import Iterable, Unionfrom uuid import uuid4from django.conf import settings-from django.contrib.auth.models import _user_has_perm # type: ignore-from django.contrib.auth.models import AbstractBaseUser, BaseUserManager+from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManagerfrom django.contrib.postgres.indexes import GinIndexfrom django.db import modelsfrom django.db.models import JSONField # type: ignore@@ -21,7 +20,7 @@ from ..core.models import ModelWithExternalReference, ModelWithMetadatafrom ..core.permissions import AccountPermissions, BasePermissionEnum, get_permissionsfrom ..core.utils.json_serializer import CustomJsonEncoderfrom ..order.models import Order-from ..permission.models import Permission, PermissionsMixin+from ..permission.models import Permission, PermissionsMixin, _user_has_permfrom . import CustomerEventsfrom .validators import validate_possible_numberdiff --git a/saleor/app/migrations/0014_alter_app_options.py b/saleor/app/migrations/0014_alter_app_options.pyindex 7894a65c39..0effb26e20 100644--- a/saleor/app/migrations/0014_alter_app_options.py+++ b/saleor/app/migrations/0014_alter_app_options.py@@ -6,8 +6,9 @@ from django.db.models.signals import post_migratedef assign_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Group = apps.get_model("auth", "Group")- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Group = apps.get_model("account", "Group")+ Permission = apps.get_model("permission", "Permission")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(app_label="app", model="app")diff --git a/saleor/auth/__init__.py b/saleor/auth/__init__.pynew file mode 100644index 0000000000..564bc0537b--- /dev/null+++ b/saleor/auth/__init__.py@@ -0,0 +1,2 @@+# This module was created to be able to handle the migration process after we move+# the part of Django Auth directly to Saleor.diff --git a/saleor/auth/migrations/0001_initial.py b/saleor/auth/migrations/0001_initial.pynew file mode 100644index 0000000000..71bbceaae0--- /dev/null+++ b/saleor/auth/migrations/0001_initial.py@@ -0,0 +1,200 @@+from django.contrib.auth import validators+from django.db import migrations, models+from django.utils import timezone++from saleor.permission.models import PermissionManager+from saleor.account.models import GroupManager, UserManager+++class Migration(migrations.Migration):++ dependencies = [+ ("contenttypes", "__first__"),+ ]++ operations = [+ migrations.CreateModel(+ name="Permission",+ fields=[+ (+ "id",+ models.AutoField(+ verbose_name="ID",+ serialize=False,+ auto_created=True,+ primary_key=True,+ ),+ ),+ ("name", models.CharField(max_length=50, verbose_name="name")),+ (+ "content_type",+ models.ForeignKey(+ to="contenttypes.ContentType",+ on_delete=models.CASCADE,+ to_field="id",+ verbose_name="content type",+ ),+ ),+ ("codename", models.CharField(max_length=100, verbose_name="codename")),+ ],+ options={+ "ordering": [+ "content_type__app_label",+ "content_type__model",+ "codename",+ ],+ "unique_together": {("content_type", "codename")},+ "verbose_name": "permission",+ "verbose_name_plural": "permissions",+ },+ managers=[+ ("objects", PermissionManager()),+ ],+ ),+ migrations.CreateModel(+ name="Group",+ fields=[+ (+ "id",+ models.AutoField(+ verbose_name="ID",+ serialize=False,+ auto_created=True,+ primary_key=True,+ ),+ ),+ (+ "name",+ models.CharField(unique=True, max_length=80, verbose_name="name"),+ ),+ (+ "permissions",+ models.ManyToManyField(+ to="auth.Permission", verbose_name="permissions", blank=True+ ),+ ),+ ],+ options={+ "verbose_name": "group",+ "verbose_name_plural": "groups",+ },+ managers=[+ ("objects", GroupManager()),+ ],+ ),+ migrations.CreateModel(+ name="User",+ fields=[+ (+ "id",+ models.AutoField(+ verbose_name="ID",+ serialize=False,+ auto_created=True,+ primary_key=True,+ ),+ ),+ ("password", models.CharField(max_length=128, verbose_name="password")),+ (+ "last_login",+ models.DateTimeField(+ default=timezone.now, verbose_name="last login"+ ),+ ),+ (+ "is_superuser",+ models.BooleanField(+ default=False,+ help_text="Designates that this user has all permissions without explicitly assigning them.", # noqa: E501+ verbose_name="superuser status",+ ),+ ),+ (+ "username",+ models.CharField(+ help_text="Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.", # noqa: E501+ unique=True,+ max_length=30,+ verbose_name="username",+ validators=[validators.UnicodeUsernameValidator()],+ ),+ ),+ (+ "first_name",+ models.CharField(+ max_length=30, verbose_name="first name", blank=True+ ),+ ),+ (+ "last_name",+ models.CharField(+ max_length=30, verbose_name="last name", blank=True+ ),+ ),+ (+ "email",+ models.EmailField(+ max_length=75, verbose_name="email address", blank=True+ ),+ ),+ (+ "is_staff",+ models.BooleanField(+ default=False,+ help_text="Designates whether the user can log into this admin site.", # noqa: E501+ verbose_name="staff status",+ ),+ ),+ (+ "is_active",+ models.BooleanField(+ default=True,+ verbose_name="active",+ help_text=(+ "Designates whether this user should be treated as active. Unselect this instead of deleting " # noqa: E501+ "accounts."+ ),+ ),+ ),+ (+ "date_joined",+ models.DateTimeField(+ default=timezone.now, verbose_name="date joined"+ ),+ ),+ (+ "groups",+ models.ManyToManyField(+ to="auth.Group",+ verbose_name="groups",+ blank=True,+ related_name="user_set",+ related_query_name="user",+ help_text=(+ "The groups this user belongs to. A user will get all permissions granted to each of their " # noqa: E501+ "groups."+ ),+ ),+ ),+ (+ "user_permissions",+ models.ManyToManyField(+ to="auth.Permission",+ verbose_name="user permissions",+ blank=True,+ help_text="Specific permissions for this user.",+ related_name="user_set",+ related_query_name="user",+ ),+ ),+ ],+ options={+ "swappable": "AUTH_USER_MODEL",+ "verbose_name": "user",+ "verbose_name_plural": "users",+ },+ managers=[+ ("objects", UserManager()),+ ],+ ),+ ]diff --git a/saleor/auth/migrations/0002_alter_permission_name_max_length.py b/saleor/auth/migrations/0002_alter_permission_name_max_length.pynew file mode 100644index 0000000000..a9ca6f51a9--- /dev/null+++ b/saleor/auth/migrations/0002_alter_permission_name_max_length.py@@ -0,0 +1,16 @@+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0001_initial"),+ ]++ operations = [+ migrations.AlterField(+ model_name="permission",+ name="name",+ field=models.CharField(max_length=255, verbose_name="name"),+ ),+ ]diff --git a/saleor/auth/migrations/0003_alter_user_email_max_length.py b/saleor/auth/migrations/0003_alter_user_email_max_length.pynew file mode 100644index 0000000000..8a57548460--- /dev/null+++ b/saleor/auth/migrations/0003_alter_user_email_max_length.py@@ -0,0 +1,18 @@+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0002_alter_permission_name_max_length"),+ ]++ operations = [+ migrations.AlterField(+ model_name="user",+ name="email",+ field=models.EmailField(+ max_length=254, verbose_name="email address", blank=True+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0004_alter_user_username_opts.py b/saleor/auth/migrations/0004_alter_user_username_opts.pynew file mode 100644index 0000000000..00cf9e54fe--- /dev/null+++ b/saleor/auth/migrations/0004_alter_user_username_opts.py@@ -0,0 +1,25 @@+from django.contrib.auth import validators+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0003_alter_user_email_max_length"),+ ]++ # No database changes; modifies validators and error_messages (#13147).+ operations = [+ migrations.AlterField(+ model_name="user",+ name="username",+ field=models.CharField(+ error_messages={"unique": "A user with that username already exists."},+ max_length=30,+ validators=[validators.UnicodeUsernameValidator()],+ help_text="Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.", # noqa: E501+ unique=True,+ verbose_name="username",+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0005_alter_user_last_login_null.py b/saleor/auth/migrations/0005_alter_user_last_login_null.pynew file mode 100644index 0000000000..8407e2d822--- /dev/null+++ b/saleor/auth/migrations/0005_alter_user_last_login_null.py@@ -0,0 +1,18 @@+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0004_alter_user_username_opts"),+ ]++ operations = [+ migrations.AlterField(+ model_name="user",+ name="last_login",+ field=models.DateTimeField(+ null=True, verbose_name="last login", blank=True+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0006_require_contenttypes_0002.py b/saleor/auth/migrations/0006_require_contenttypes_0002.pynew file mode 100644index 0000000000..b4e816a56f--- /dev/null+++ b/saleor/auth/migrations/0006_require_contenttypes_0002.py@@ -0,0 +1,14 @@+from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0005_alter_user_last_login_null"),+ ("contenttypes", "0002_remove_content_type_name"),+ ]++ operations = [+ # Ensure the contenttypes migration is applied before sending+ # post_migrate signals (which create ContentTypes).+ ]diff --git a/saleor/auth/migrations/0007_alter_validators_add_error_messages.py b/saleor/auth/migrations/0007_alter_validators_add_error_messages.pynew file mode 100644index 0000000000..38ce69836b--- /dev/null+++ b/saleor/auth/migrations/0007_alter_validators_add_error_messages.py@@ -0,0 +1,24 @@+from django.contrib.auth import validators+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0006_require_contenttypes_0002"),+ ]++ operations = [+ migrations.AlterField(+ model_name="user",+ name="username",+ field=models.CharField(+ error_messages={"unique": "A user with that username already exists."},+ help_text="Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.", # noqa: E501+ max_length=30,+ unique=True,+ validators=[validators.UnicodeUsernameValidator()],+ verbose_name="username",+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0008_alter_user_username_max_length.py b/saleor/auth/migrations/0008_alter_user_username_max_length.pynew file mode 100644index 0000000000..0347eb50ab--- /dev/null+++ b/saleor/auth/migrations/0008_alter_user_username_max_length.py@@ -0,0 +1,24 @@+from django.contrib.auth import validators+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0007_alter_validators_add_error_messages"),+ ]++ operations = [+ migrations.AlterField(+ model_name="user",+ name="username",+ field=models.CharField(+ error_messages={"unique": "A user with that username already exists."},+ help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.", # noqa: E501+ max_length=150,+ unique=True,+ validators=[validators.UnicodeUsernameValidator()],+ verbose_name="username",+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0009_alter_user_last_name_max_length.py b/saleor/auth/migrations/0009_alter_user_last_name_max_length.pynew file mode 100644index 0000000000..e0665366d0--- /dev/null+++ b/saleor/auth/migrations/0009_alter_user_last_name_max_length.py@@ -0,0 +1,18 @@+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0008_alter_user_username_max_length"),+ ]++ operations = [+ migrations.AlterField(+ model_name="user",+ name="last_name",+ field=models.CharField(+ blank=True, max_length=150, verbose_name="last name"+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0010_alter_group_name_max_length.py b/saleor/auth/migrations/0010_alter_group_name_max_length.pynew file mode 100644index 0000000000..a58e11480f--- /dev/null+++ b/saleor/auth/migrations/0010_alter_group_name_max_length.py@@ -0,0 +1,16 @@+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0009_alter_user_last_name_max_length"),+ ]++ operations = [+ migrations.AlterField(+ model_name="group",+ name="name",+ field=models.CharField(max_length=150, unique=True, verbose_name="name"),+ ),+ ]diff --git a/saleor/auth/migrations/0011_update_proxy_permissions.py b/saleor/auth/migrations/0011_update_proxy_permissions.pynew file mode 100644index 0000000000..17cd5b8b03--- /dev/null+++ b/saleor/auth/migrations/0011_update_proxy_permissions.py@@ -0,0 +1,78 @@+import sys++from django.core.management.color import color_style+from django.db import IntegrityError, migrations, transaction+from django.db.models import Q++WARNING = """+ A problem arose migrating proxy model permissions for {old} to {new}.++ Permission(s) for {new} already existed.+ Codenames Q: {query}++ Ensure to audit ALL permissions for {old} and {new}.+"""+++def update_proxy_model_permissions(+ apps, schema_editor, reverse=False+): # noqa: D205, D212, D400, D415+ """+ Update the content_type of proxy model permissions to use the ContentType+ of the proxy model.+ """+ style = color_style()+ Permission = apps.get_model("auth", "Permission")+ ContentType = apps.get_model("contenttypes", "ContentType")+ alias = schema_editor.connection.alias+ for Model in apps.get_models():+ opts = Model._meta+ if not opts.proxy:+ continue+ proxy_default_permissions_codenames = [+ "%s_%s" % (action, opts.model_name) for action in opts.default_permissions+ ]+ permissions_query = Q(codename__in=proxy_default_permissions_codenames)+ for codename, name in opts.permissions:+ permissions_query = permissions_query | Q(codename=codename, name=name)+ content_type_manager = ContentType.objects.db_manager(alias)+ concrete_content_type = content_type_manager.get_for_model(+ Model, for_concrete_model=True+ )+ proxy_content_type = content_type_manager.get_for_model(+ Model, for_concrete_model=False+ )+ old_content_type = proxy_content_type if reverse else concrete_content_type+ new_content_type = concrete_content_type if reverse else proxy_content_type+ try:+ with transaction.atomic(using=alias):+ Permission.objects.using(alias).filter(+ permissions_query,+ content_type=old_content_type,+ ).update(content_type=new_content_type)+ except IntegrityError:+ old = "{}_{}".format(old_content_type.app_label, old_content_type.model)+ new = "{}_{}".format(new_content_type.app_label, new_content_type.model)+ sys.stdout.write(+ style.WARNING(WARNING.format(old=old, new=new, query=permissions_query))+ )+++def revert_proxy_model_permissions(apps, schema_editor): # noqa: D205, D212, D400, D415+ """+ Update the content_type of proxy model permissions to use the ContentType+ of the concrete model.+ """+ update_proxy_model_permissions(apps, schema_editor, reverse=True)+++class Migration(migrations.Migration):+ dependencies = [+ ("auth", "0010_alter_group_name_max_length"),+ ("contenttypes", "0002_remove_content_type_name"),+ ]+ operations = [+ migrations.RunPython(+ update_proxy_model_permissions, revert_proxy_model_permissions+ ),+ ]diff --git a/saleor/auth/migrations/0012_alter_user_first_name_max_length.py b/saleor/auth/migrations/0012_alter_user_first_name_max_length.pynew file mode 100644index 0000000000..839c950417--- /dev/null+++ b/saleor/auth/migrations/0012_alter_user_first_name_max_length.py@@ -0,0 +1,18 @@+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0011_update_proxy_permissions"),+ ]++ operations = [+ migrations.AlterField(+ model_name="user",+ name="first_name",+ field=models.CharField(+ blank=True, max_length=150, verbose_name="first name"+ ),+ ),+ ]diff --git a/saleor/auth/migrations/0013_auto_20221214_1224.py b/saleor/auth/migrations/0013_auto_20221214_1224.pynew file mode 100644index 0000000000..176889bcdf--- /dev/null+++ b/saleor/auth/migrations/0013_auto_20221214_1224.py@@ -0,0 +1,26 @@+# Generated by Django 3.2.16 on 2022-12-14 12:24++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [+ ("auth", "0012_alter_user_first_name_max_length"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.DeleteModel(+ name="Group",+ ),+ migrations.DeleteModel(+ name="Permission",+ ),+ migrations.DeleteModel(+ name="User",+ ),+ ]+ )+ ]diff --git a/saleor/auth/migrations/__init__.py b/saleor/auth/migrations/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/channel/migrations/0001_initial.py b/saleor/channel/migrations/0001_initial.pyindex 70193693c1..e2e68ddd97 100644--- a/saleor/channel/migrations/0001_initial.py+++ b/saleor/channel/migrations/0001_initial.py@@ -9,8 +9,9 @@ from django.apps import apps as registrydef assing_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Group = apps.get_model("auth", "Group")- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Group = apps.get_model("account", "Group")+ Permission = apps.get_model("permission", "Permission")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(app_label="channel", model="channel")diff --git a/saleor/checkout/migrations/0040_add_handle_checkouts_permission.py b/saleor/checkout/migrations/0040_add_handle_checkouts_permission.pyindex 344d40a370..12cab4cc32 100644--- a/saleor/checkout/migrations/0040_add_handle_checkouts_permission.py+++ b/saleor/checkout/migrations/0040_add_handle_checkouts_permission.py@@ -7,9 +7,10 @@ from django.db.models.signals import post_migratedef assign_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Permission = apps.get_model("permission", "Permission")App = apps.get_model("app", "App")- Group = apps.get_model("auth", "Group")+ Group = apps.get_model("account", "Group")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(diff --git a/saleor/checkout/migrations/0051_auto_20220713_1103.py b/saleor/checkout/migrations/0051_auto_20220713_1103.pyindex 223ae443df..9aa8505a93 100644--- a/saleor/checkout/migrations/0051_auto_20220713_1103.py+++ b/saleor/checkout/migrations/0051_auto_20220713_1103.py@@ -8,9 +8,10 @@ from django.db.models.signals import post_migratedef assign_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Permission = apps.get_model("permission", "Permission")App = apps.get_model("app", "App")- Group = apps.get_model("auth", "Group")+ Group = apps.get_model("account", "Group")handle_taxes = Permission.objects.filter(codename="handle_taxes", content_type__app_label="checkout"diff --git a/saleor/checkout/migrations/0054_alter_checkout_options.py b/saleor/checkout/migrations/0054_alter_checkout_options.pyindex 5235c9fa6d..20b6264120 100644--- a/saleor/checkout/migrations/0054_alter_checkout_options.py+++ b/saleor/checkout/migrations/0054_alter_checkout_options.py@@ -7,9 +7,10 @@ from django.db.models.signals import post_migratedef assign_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Permission = apps.get_model("permission", "Permission")App = apps.get_model("app", "App")- Group = apps.get_model("auth", "Group")+ Group = apps.get_model("account", "Group")manage_taxes = Permission.objects.filter(codename="manage_taxes", content_type__app_label="checkout"diff --git a/saleor/page/migrations/0017_pagetype.py b/saleor/page/migrations/0017_pagetype.pyindex 91ff585e18..f9f56468ba 100644--- a/saleor/page/migrations/0017_pagetype.py+++ b/saleor/page/migrations/0017_pagetype.py@@ -8,8 +8,9 @@ import saleor.core.utils.json_serializerdef update_groups_with_manage_pages_with_new_permission(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Group = apps.get_model("auth", "Group")- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Group = apps.get_model("account", "Group")+ Permission = apps.get_model("permission", "Permission")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(app_label="page", model="pagetype")diff --git a/saleor/payment/migrations/0029_alter_payment_options.py b/saleor/payment/migrations/0029_alter_payment_options.pyindex 3090a90b20..f1850ec1de 100644--- a/saleor/payment/migrations/0029_alter_payment_options.py+++ b/saleor/payment/migrations/0029_alter_payment_options.py@@ -7,8 +7,9 @@ from django.db.models.signals import post_migratedef assing_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Group = apps.get_model("auth", "Group")- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Group = apps.get_model("account", "Group")+ Permission = apps.get_model("permission", "Permission")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(app_label="payment", model="payment")diff --git a/saleor/product/migrations/0129_add_product_types_and_attributes_perm.py b/saleor/product/migrations/0129_add_product_types_and_attributes_perm.pyindex 34e5e29ad2..9e6c01ab62 100644--- a/saleor/product/migrations/0129_add_product_types_and_attributes_perm.py+++ b/saleor/product/migrations/0129_add_product_types_and_attributes_perm.py@@ -7,8 +7,9 @@ from django.apps import apps as registrydef update_groups_with_manage_products_with_new_permission(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Group = apps.get_model("auth", "Group")- Permission = apps.get_model("auth", "Permission")+ apps = kwargs["apps"]+ Group = apps.get_model("account", "Group")+ Permission = apps.get_model("permission", "Permission")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(diff --git a/saleor/settings.py b/saleor/settings.pyindex d778f7d588..6921ae08ec 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -220,11 +220,11 @@ INSTALLED_APPS = ["django.contrib.contenttypes","django.contrib.sites","django.contrib.staticfiles",- "django.contrib.auth","django.contrib.postgres","django_celery_beat",# Local apps"saleor.permission",+ "saleor.auth","saleor.plugins","saleor.account","saleor.discount",diff --git a/saleor/tax/migrations/0003_add_manage_taxes_permission.py b/saleor/tax/migrations/0003_add_manage_taxes_permission.pyindex 9484ec4fe8..a488ad4f37 100644--- a/saleor/tax/migrations/0003_add_manage_taxes_permission.py+++ b/saleor/tax/migrations/0003_add_manage_taxes_permission.py@@ -6,8 +6,9 @@ from django.db.models.signals import post_migratedef assign_permissions(apps, schema_editor):def on_migrations_complete(sender=None, **kwargs):- Permission = apps.get_model("auth", "Permission")- Group = apps.get_model("auth", "Group")+ apps = kwargs["apps"]+ Permission = apps.get_model("permission", "Permission")+ Group = apps.get_model("account", "Group")ContentType = apps.get_model("contenttypes", "ContentType")ct, _ = ContentType.objects.get_or_create(diff --git a/saleor/webhook/migrations/0005_drop_manage_webhooks_permission.py b/saleor/webhook/migrations/0005_drop_manage_webhooks_permission.pyindex bf82f24ec2..cf0741a626 100644--- a/saleor/webhook/migrations/0005_drop_manage_webhooks_permission.py+++ b/saleor/webhook/migrations/0005_drop_manage_webhooks_permission.py@@ -44,6 +44,10 @@ class Migration(migrations.Migration):("account", "0045_auto_20200427_0425"),]+ run_before = [+ ("account", "0071_group"),+ ]+operations = [migrations.RunPython(change_webhook_permission_to_app_permission),migrations.AlterModelOptions(