Skip to content

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

* Remove verbose names from Voucher and Sale models

akjanike86c246b7aed
diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.py
index 47c8ac54b3..096146d0ce 100644
--- a/saleor/dashboard/discount/forms.py
+++ b/saleor/dashboard/discount/forms.py
@@ -21,6 +21,23 @@ class SaleForm(forms.ModelForm):
class Meta:
model = Sale
exclude = []
+ labels = {
+ 'name': pgettext_lazy(
+ 'Sale (discount) field',
+ 'sale\'s name'),
+ 'type': pgettext_lazy(
+ 'Sale (discount) field',
+ 'discount for'),
+ 'value': pgettext_lazy(
+ 'Sale (discount) field',
+ 'value'),
+ 'products': pgettext_lazy(
+ 'Sale (discount) field',
+ 'products in sale'),
+ 'categories': pgettext_lazy(
+ 'Sale (discount) field',
+ 'sale\'s categories'),
+ }
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -43,6 +60,29 @@ class VoucherForm(forms.ModelForm):
class Meta:
model = Voucher
exclude = ['limit', 'apply_to', 'product', 'category']
+ labels = {
+ 'type': pgettext_lazy(
+ 'Voucher field',
+ 'discount for'),
+ 'name': pgettext_lazy(
+ 'Voucher field',
+ 'voucher\'s name'),
+ 'code': pgettext_lazy(
+ 'Voucher field',
+ 'voucher\'s code'),
+ 'usage_limit': pgettext_lazy(
+ 'Voucher field',
+ 'usage limit'),
+ 'used': pgettext_lazy(
+ 'Voucher field',
+ 'number of voucher usages'),
+ 'start_date': pgettext_lazy(
+ 'Voucher field',
+ 'start date'),
+ 'end_date': pgettext_lazy(
+ 'Voucher field',
+ 'end date'),
+ }
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial', {})
@@ -86,6 +126,14 @@ class ShippingVoucherForm(forms.ModelForm):
class Meta:
model = Voucher
fields = ['apply_to', 'limit']
+ labels = {
+ 'apply_to': pgettext_lazy(
+ 'Voucher field',
+ 'apply to'),
+ 'limit': pgettext_lazy(
+ 'Voucher field',
+ 'voucher limit'),
+ }
def save(self, commit=True):
self.instance.category = None
@@ -104,6 +152,11 @@ class ValueVoucherForm(forms.ModelForm):
class Meta:
model = Voucher
fields = ['limit']
+ labels = {
+ 'limit': pgettext_lazy(
+ 'Voucher field',
+ 'voucher limit'),
+ }
def save(self, commit=True):
self.instance.category = None
@@ -143,6 +196,14 @@ class ProductVoucherForm(CommonVoucherForm):
class Meta:
model = Voucher
fields = ['product', 'apply_to']
+ labels = {
+ 'apply_to': pgettext_lazy(
+ 'Voucher field',
+ 'apply to'),
+ 'product': pgettext_lazy(
+ 'Voucher field',
+ 'product'),
+ }
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -155,6 +216,14 @@ class CategoryVoucherForm(CommonVoucherForm):
class Meta:
model = Voucher
fields = ['category', 'apply_to']
+ labels = {
+ 'apply_to': pgettext_lazy(
+ 'Voucher field',
+ 'apply to'),
+ 'category': pgettext_lazy(
+ 'Voucher field',
+ 'category'),
+ }
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
diff --git a/saleor/discount/models.py b/saleor/discount/models.py
index 03308e9bfe..82db35dc38 100644
--- a/saleor/discount/models.py
+++ b/saleor/discount/models.py
@@ -86,41 +86,34 @@ class Voucher(models.Model):
(SHIPPING_TYPE, pgettext_lazy('Voucher: discount for', 'Shipping'))]
type = models.CharField(
- pgettext_lazy('Voucher field', 'discount for'), max_length=20,
- choices=TYPE_CHOICES, default=VALUE_TYPE)
+ max_length=20, choices=TYPE_CHOICES, default=VALUE_TYPE)
name = models.CharField(
- pgettext_lazy('Voucher field', 'name'), max_length=255, null=True,
- blank=True)
+ max_length=255, null=True, blank=True)
code = models.CharField(
- pgettext_lazy('Voucher field', 'code'), max_length=12, unique=True,
- db_index=True)
+ max_length=12, unique=True, db_index=True)
usage_limit = models.PositiveIntegerField(
- pgettext_lazy('Voucher field', 'usage limit'), null=True, blank=True)
- used = models.PositiveIntegerField(default=0, editable=False)
+ null=True, blank=True)
+ used = models.PositiveIntegerField(
+ default=0, editable=False)
start_date = models.DateField(
- pgettext_lazy('Voucher field', 'start date'), default=date.today)
+ default=date.today)
end_date = models.DateField(
- pgettext_lazy('Voucher field', 'end date'), null=True, blank=True)
+ null=True, blank=True)
discount_value_type = models.CharField(
- pgettext_lazy('Voucher field', 'discount type'), max_length=10,
- choices=DISCOUNT_VALUE_TYPE_CHOICES, default=DISCOUNT_VALUE_FIXED)
+ max_length=10, choices=DISCOUNT_VALUE_TYPE_CHOICES,
+ default=DISCOUNT_VALUE_FIXED)
discount_value = models.DecimalField(
- pgettext_lazy('Voucher field', 'discount value'), max_digits=12,
- decimal_places=2)
+ max_digits=12, decimal_places=2)
# not mandatory fields, usage depends on type
product = models.ForeignKey(
- 'product.Product', blank=True, null=True,
- on_delete=models.CASCADE)
+ 'product.Product', blank=True, null=True, on_delete=models.CASCADE)
category = models.ForeignKey(
- 'product.Category', blank=True, null=True,
- on_delete=models.CASCADE)
+ 'product.Category', blank=True, null=True, on_delete=models.CASCADE)
apply_to = models.CharField(
- pgettext_lazy('Voucher field', 'apply to'),
max_length=20, blank=True, null=True)
limit = PriceField(
- pgettext_lazy('Voucher field', 'limit'),
max_digits=12, decimal_places=2, null=True,
blank=True, currency=settings.DEFAULT_CURRENCY)
@@ -267,13 +260,10 @@ class Sale(models.Model):
(FIXED, pgettext_lazy('Discount type', settings.DEFAULT_CURRENCY)),
(PERCENTAGE, pgettext_lazy('Discount type', '%')))
- name = models.CharField(
- pgettext_lazy('Sale (discount) field', 'name'), max_length=255)
+ name = models.CharField(max_length=255)
type = models.CharField(
- pgettext_lazy('Sale (discount) field', 'type'),
max_length=10, choices=DISCOUNT_TYPE_CHOICES, default=FIXED)
value = models.DecimalField(
- pgettext_lazy('Sale (discount) field', 'value'),
max_digits=12, decimal_places=2, default=0)
products = models.ManyToManyField(
'product.Product', blank=True)