Skip to content

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

Add "manage_checkouts" permission to Checkout model

Mateusz Dereniowski2bcca329ae84
diff --git a/saleor/checkout/migrations/0022_auto_20191219_1137.py b/saleor/checkout/migrations/0022_auto_20191219_1137.py
new file mode 100644
index 0000000000..073b79ce74
--- /dev/null
+++ b/saleor/checkout/migrations/0022_auto_20191219_1137.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.7 on 2019-12-19 17:37
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("checkout", "0021_django_price_2")]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name="checkout",
+ options={
+ "ordering": ("-last_change",),
+ "permissions": (("manage_checkouts", "Manage checkouts"),),
+ },
+ )
+ ]
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index 4711dad131..449b2be96d 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -8,11 +8,13 @@ from django.contrib.postgres.fields import JSONField
from django.core.validators import MinValueValidator
from django.db import models
from django.utils.encoding import smart_str
+from django.utils.translation import pgettext_lazy
from django_prices.models import MoneyField
from prices import Money
from ..account.models import Address
from ..core.models import ModelWithMetadata
+from ..core.permissions import CheckoutPermissions
from ..core.taxes import zero_money
from ..core.weight import zero_weight
from ..giftcard.models import GiftCard
@@ -93,6 +95,12 @@ class Checkout(ModelWithMetadata):
class Meta:
ordering = ("-last_change",)
+ permissions = (
+ (
+ CheckoutPermissions.MANAGE_CHECKOUTS.codename,
+ pgettext_lazy("Permission description", "Manage checkouts"),
+ ),
+ )
def __repr__(self):
return "Checkout(quantity=%s)" % (self.quantity,)