mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Vouchers: Don't allow to generate more than 100k random codes at once
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
placeholder="{% trans "Prefix (optional)" %}">
|
placeholder="{% trans "Prefix (optional)" %}">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" class="form-control input-xs"
|
<input type="number" class="form-control input-xs"
|
||||||
id="voucher-bulk-codes-num"
|
id="voucher-bulk-codes-num" max="100000"
|
||||||
placeholder="{% trans "Number" context "number_of_things" %}">
|
placeholder="{% trans "Number" context "number_of_things" %}">
|
||||||
<div class="input-group-btn">
|
<div class="input-group-btn">
|
||||||
<button class="btn btn-default" type="button" id="voucher-bulk-codes-generate"
|
<button class="btn btn-default" type="button" id="voucher-bulk-codes-generate"
|
||||||
|
|||||||
@@ -569,6 +569,8 @@ class VoucherRNG(EventPermissionRequiredMixin, View):
|
|||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
num = int(request.GET.get('num', '5'))
|
num = int(request.GET.get('num', '5'))
|
||||||
|
if num > 100_000:
|
||||||
|
return HttpResponseBadRequest()
|
||||||
except ValueError: # NOQA
|
except ValueError: # NOQA
|
||||||
return HttpResponseBadRequest()
|
return HttpResponseBadRequest()
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ var form_handlers = function (el) {
|
|||||||
|
|
||||||
// Vouchers
|
// Vouchers
|
||||||
el.find("#voucher-bulk-codes-generate").click(function () {
|
el.find("#voucher-bulk-codes-generate").click(function () {
|
||||||
|
if (!$("#voucher-bulk-codes-num").get(0).reportValidity())
|
||||||
|
return;
|
||||||
var num = $("#voucher-bulk-codes-num").val();
|
var num = $("#voucher-bulk-codes-num").val();
|
||||||
var prefix = $('#voucher-bulk-codes-prefix').val();
|
var prefix = $('#voucher-bulk-codes-prefix').val();
|
||||||
if (num != "") {
|
if (num != "") {
|
||||||
|
|||||||
Reference in New Issue
Block a user