Skip to content

Commit

Permalink
Fix receipt box item removal form validation
Browse files Browse the repository at this point in the history
Fixes commit 2524a1a
  • Loading branch information
jlaunonen committed Jul 21, 2024
1 parent a1116a8 commit edf27c9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kirppu/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def clean_receipt(self):
def clean_code(self):
data = self.cleaned_data["code"]
if box_match := re.match(r"box[_ -]?(\d+)$", data):
if not Box.objects.filter(pk=int(box_match[1])).exists():
# Indefinite check: there may be multiple Box objects with same box_number, across different Events.
if not Box.objects.filter(box_number=int(box_match[1])).exists():
raise forms.ValidationError("Box {} not found".format(box_match[1]))
return data
if not Item.is_item_barcode(data):
Expand Down

0 comments on commit edf27c9

Please sign in to comment.