mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
API: Write methods for quotas (#657)
* MKBDIGI-183: Added quotas API write methods * MKBDIGI-183: Fixed code formatting * MKBDIGI-183: Added test for permission requirements * MKBDIGI-183: Documentation corrections * MKBDIGI-183: Removed redundant create/update locks * MKBDIGI-183: Added quota validation to check that items and variations corresponds to each other * MKBDIGI-183: Added quota validation to check that item belong to the same event as the endpoint * MKBDIGI-183: Added subevent validation to check that subevent belong to the same event as the endpoint * MKBDIGI-183: Added subevent validation to check that subevent is null for non-series events * MKBDIGI-183: Changed validation error text * MKBDIGI-183: Added logging for subevents * MKBDIGI-183: Fixed code formatting * MKBDIGI-183: Fixed validation error in API test * MKBDIGI-183: Fixed documentation errors * MKBDIGI-183: Fixed typos in validation messages * MKBDIGI-183: Refactored validation loop vars check * MKBDIGI-183: Updated error strings in test assersions * MKBDIGI-183: Fixed logging for API quota update to account changing subevents
This commit is contained in:
committed by
Raphael Michel
parent
445afcc50c
commit
e4167380b9
@@ -897,3 +897,30 @@ class Quota(LoggedModel):
|
||||
|
||||
class QuotaExceededException(Exception):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def clean_variations(items, variations):
|
||||
for variation in variations:
|
||||
if variation.item not in items:
|
||||
raise ValidationError(_('All variations must belong to an item contained in the items list.'))
|
||||
break
|
||||
|
||||
@staticmethod
|
||||
def clean_items(event, items, variations):
|
||||
for item in items:
|
||||
if event != item.event:
|
||||
raise ValidationError(_('One or more items do not belong to this event.'))
|
||||
if item.has_variations:
|
||||
if not any(var.item == item for var in variations):
|
||||
raise ValidationError(_('One or more items has variations but none of these are in the variations list.'))
|
||||
|
||||
@staticmethod
|
||||
def clean_subevent(event, subevent):
|
||||
if event.has_subevents:
|
||||
if not subevent:
|
||||
raise ValidationError(_('Subevent cannot be null for event series.'))
|
||||
if event != subevent.event:
|
||||
raise ValidationError(_('The subevent does not belong to this event.'))
|
||||
else:
|
||||
if subevent:
|
||||
raise ValidationError(_('The subevent does not belong to this event.'))
|
||||
|
||||
Reference in New Issue
Block a user