Skip to content

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

Rename discount permission (#14856)

Filip Owczarek9e3e0d1c6cc0
diff --git a/saleor/discount/migrations/0070_alter_promotion_options.py b/saleor/discount/migrations/0070_alter_promotion_options.py
new file mode 100644
index 0000000000..3f4d2bd736
--- /dev/null
+++ b/saleor/discount/migrations/0070_alter_promotion_options.py
@@ -0,0 +1,33 @@
+# Generated by Django 3.2.23 on 2023-11-24 12:18
+
+from django.db import migrations
+
+
+def rename_discount_permission(apps, schema_editor):
+ Promotion = apps.get_model("discount", "Promotion")
+ ContentType = apps.get_model("contenttypes", "ContentType")
+ Permission = apps.get_model("permission", "Permission")
+
+ content_type = ContentType.objects.get_for_model(Promotion)
+ Permission.objects.filter(
+ content_type=content_type, codename="manage_discounts"
+ ).update(name="Manage promotions and vouchers.")
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("discount", "0069_merge_20231117_0959"),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name="promotion",
+ options={
+ "ordering": ("name", "pk"),
+ "permissions": (
+ ("manage_discounts", "Manage promotions and vouchers."),
+ ),
+ },
+ ),
+ migrations.RunPython(rename_discount_permission, migrations.RunPython.noop),
+ ]
diff --git a/saleor/discount/models.py b/saleor/discount/models.py
index 7a26c9bb8c..a91e2c8095 100644
--- a/saleor/discount/models.py
+++ b/saleor/discount/models.py
@@ -324,7 +324,7 @@ class Promotion(ModelWithMetadata):
permissions = (
(
DiscountPermissions.MANAGE_DISCOUNTS.codename,
- "Manage sales and vouchers.",
+ "Manage promotions and vouchers.",
),
)