mirror of
https://github.com/pretix/pretix.git
synced 2026-09-12 16:04:42 +00:00
[wip] Validate price suggestions against default price
This commit is contained in:
@@ -363,6 +363,11 @@ class ItemSerializer(SalesChannelMigrationMixin, I18nAwareModelSerializer):
|
||||
"Gift card products should not be admission products at the same time."
|
||||
))
|
||||
|
||||
if data.get('free_price_suggestion') and data.get('free_price_suggestion') < data.get('default_price'):
|
||||
raise ValidationError(_(
|
||||
"Your price suggestion cannot be less than the default price. "
|
||||
))
|
||||
|
||||
return data
|
||||
|
||||
def validate_category(self, value):
|
||||
|
||||
@@ -889,6 +889,9 @@ class ItemUpdateForm(I18nModelForm):
|
||||
|
||||
Item.clean_media_settings(self.event, d.get('media_policy'), d.get('media_type'), d.get('issue_giftcard'))
|
||||
|
||||
if d.get('free_price_suggestion') and d.get('free_price_suggestion') < d.get('default_price'):
|
||||
self.add_error('free_price_suggestion', _("Your price suggestion cannot be less than the default price. "))
|
||||
|
||||
return d
|
||||
|
||||
class Meta:
|
||||
@@ -1126,6 +1129,14 @@ class ItemVariationForm(I18nModelForm):
|
||||
"If a valid membership is required, at least one valid membership type needs to be selected."
|
||||
)
|
||||
)
|
||||
|
||||
if (
|
||||
d.get('free_price_suggestion')
|
||||
and d.get('default_price')
|
||||
and d.get('free_price_suggestion') < d.get('default_price')
|
||||
):
|
||||
self.add_error('free_price_suggestion', _("Your price suggestion cannot be less than the default price. "))
|
||||
|
||||
return d
|
||||
|
||||
def save(self, commit=True):
|
||||
|
||||
Reference in New Issue
Block a user