forked from CGM_Public/pretix_original
Add action buttons to "missing quota" warnings (#4533)
* Add action buttons to "missing quota" warnings * Update item.py
This commit is contained in:
@@ -12,10 +12,22 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if object.id and not object.quotas.exists %}
|
{% if object.id and not object.quotas.exists %}
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
{% blocktrans trimmed %}
|
<div class="row">
|
||||||
Please note that your product will <strong>not</strong> be available for sale until you have added your
|
<div class="col-lg-8">
|
||||||
item to an existing or newly created quota.
|
{% blocktrans trimmed %}
|
||||||
{% endblocktrans %}
|
Please note that your product will <strong>not</strong> be available for sale until you have added your
|
||||||
|
item to an existing or newly created quota.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 text-right">
|
||||||
|
<a class="btn btn-default btn-sm" href="{% url "control:event.items.quotas" organizer=request.event.organizer.slug event=request.event.slug %}">
|
||||||
|
<i class="fa fa-wrench"></i> {% trans "Manage quotas" %}
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-default btn-sm" href="{% url "control:event.items.quotas.add" organizer=request.event.organizer.slug event=request.event.slug %}?{% if object.has_variations %}{% for var in object.variations.all %}product={{ object.pk }}-{{ var.pk }}&{% endfor %}{% else %}product={{ object.pk }}{% endif %}">
|
||||||
|
<i class="fa fa-plus"></i> {% trans "Create a new quota" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% elif object.pk and not object.is_available_by_time %}
|
{% elif object.pk and not object.is_available_by_time %}
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
|
|||||||
@@ -67,10 +67,22 @@
|
|||||||
<div class="panel-body form-horizontal">
|
<div class="panel-body form-horizontal">
|
||||||
{% if form.instance.pk and not form.instance.quotas.exists %}
|
{% if form.instance.pk and not form.instance.quotas.exists %}
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
{% blocktrans trimmed %}
|
<div class="row">
|
||||||
Please note that your variation will <strong>not</strong> be available for sale
|
<div class="col-lg-8">
|
||||||
until you have added it to an existing or newly created quota.
|
{% blocktrans trimmed %}
|
||||||
{% endblocktrans %}
|
Please note that your variation will <strong>not</strong> be available for sale
|
||||||
|
until you have added it to an existing or newly created quota.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 text-right">
|
||||||
|
<a class="btn btn-default btn-xs" href="{% url "control:event.items.quotas" organizer=request.event.organizer.slug event=request.event.slug %}">
|
||||||
|
<i class="fa fa-wrench"></i> {% trans "Manage quotas" %}
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-default btn-xs" href="{% url "control:event.items.quotas.add" organizer=request.event.organizer.slug event=request.event.slug %}?product={{ form.instance.item.pk }}-{{ form.instance.pk }}">
|
||||||
|
<i class="fa fa-plus"></i> {% trans "Create a new quota" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% bootstrap_form_errors form %}
|
{% bootstrap_form_errors form %}
|
||||||
|
|||||||
@@ -920,16 +920,19 @@ class QuotaCreate(EventPermissionRequiredMixin, CreateView):
|
|||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
|
|
||||||
|
kwargs.setdefault('initial', {})
|
||||||
if self.copy_from:
|
if self.copy_from:
|
||||||
i = modelcopy(self.copy_from)
|
i = modelcopy(self.copy_from)
|
||||||
i.pk = None
|
i.pk = None
|
||||||
kwargs['instance'] = i
|
kwargs['instance'] = i
|
||||||
kwargs.setdefault('initial', {})
|
|
||||||
kwargs['initial']['itemvars'] = [str(i.pk) for i in self.copy_from.items.all()] + [
|
kwargs['initial']['itemvars'] = [str(i.pk) for i in self.copy_from.items.all()] + [
|
||||||
'{}-{}'.format(v.item_id, v.pk) for v in self.copy_from.variations.all()
|
'{}-{}'.format(v.item_id, v.pk) for v in self.copy_from.variations.all()
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
kwargs['instance'] = Quota(event=self.request.event)
|
kwargs['instance'] = Quota(event=self.request.event)
|
||||||
|
if 'product' in self.request.GET:
|
||||||
|
kwargs['initial']['itemvars'] = self.request.GET.getlist('product')
|
||||||
|
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def form_invalid(self, form):
|
def form_invalid(self, form):
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ $(function () {
|
|||||||
autofill = false;
|
autofill = false;
|
||||||
})
|
})
|
||||||
|
|
||||||
$("input[name=itemvars]").change(function () {
|
function do_autofill() {
|
||||||
if (autofill) {
|
if (autofill) {
|
||||||
var names = [];
|
var names = [];
|
||||||
$("input[name=itemvars]:checked").each(function () {
|
$("input[name=itemvars]:checked").each(function () {
|
||||||
@@ -37,5 +37,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
$("#id_name").val(names.join(', '));
|
$("#id_name").val(names.join(', '));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
$("input[name=itemvars]").change(do_autofill);
|
||||||
|
do_autofill();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user