forked from CGM_Public/pretix_original
Improve check-in deletion (#3688)
* Improve check-in deletion * Add pluralization * Disable buttons if nothing selected
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
{% extends "pretixcontrol/items/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
{% block title %}{% trans "Delete check-ins" %}{% endblock %}
|
||||||
|
{% block inside %}
|
||||||
|
<h1>{% trans "Delete check-ins" %}</h1>
|
||||||
|
<form action="{% url "control:event.orders.checkinlists.bulk_action" event=request.event.slug organizer=request.event.organizer.slug list=checkinlist.pk %}" method="post" class="form-horizontal" data-asynctask>
|
||||||
|
{% csrf_token %}
|
||||||
|
{% for k, l in request.POST.lists %}
|
||||||
|
{% for v in l %}
|
||||||
|
<input type="hidden" name="{{ k }}" value="{{ v }}">
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
<p>
|
||||||
|
{% blocktrans trimmed count count=cnt %}
|
||||||
|
Are you sure you want to permanently delete the check-ins of <strong>one ticket</strong>.
|
||||||
|
{% plural %}
|
||||||
|
Are you sure you want to permanently delete the check-ins of <strong>{{ count }} tickets</strong>?
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
<div class="form-group submit-group">
|
||||||
|
<a href="{% url "control:event.orders.checkinlists" organizer=request.event.organizer.slug event=request.event.slug %}"
|
||||||
|
class="btn btn-default btn-cancel">
|
||||||
|
{% trans "Cancel" %}
|
||||||
|
</a>
|
||||||
|
<button type="submit" class="btn btn-danger btn-save">
|
||||||
|
{% trans "Delete" %}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
@@ -205,22 +205,27 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{% if "can_change_orders" in request.eventpermset or "can_checkin_orders" in request.eventpermset %}
|
<div class="batch-select-actions">
|
||||||
<button type="submit" class="btn btn-primary btn-save">
|
{% if "can_change_orders" in request.eventpermset or "can_checkin_orders" in request.eventpermset %}
|
||||||
<span class="fa fa-sign-in" aria-hidden="true"></span>
|
<button type="submit" class="btn btn-primary btn-save">
|
||||||
{% trans "Check-In selected attendees" %}
|
<span class="fa fa-sign-in" aria-hidden="true"></span>
|
||||||
</button>
|
{% trans "Check-In selected attendees" %}
|
||||||
<button type="submit" class="btn btn-default btn-save" name="checkout" value="true">
|
</button>
|
||||||
<span class="fa fa-sign-out" aria-hidden="true"></span>
|
<button type="submit" class="btn btn-default btn-save" name="checkout" value="true">
|
||||||
{% trans "Check-Out selected attendees" %}
|
<span class="fa fa-sign-out" aria-hidden="true"></span>
|
||||||
</button>
|
{% trans "Check-Out selected attendees" %}
|
||||||
{% endif %}
|
</button>
|
||||||
{% if "can_change_orders" in request.eventpermset %}
|
{% endif %}
|
||||||
<button type="submit" class="btn btn-danger btn-save" name="revert" value="true">
|
{% if "can_change_orders" in request.eventpermset %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
<button type="submit" class="btn btn-danger btn-save" name="revert"
|
||||||
{% trans "Delete all check-ins of selected attendees" %}
|
formaction="{% url "control:event.orders.checkinlists.bulk_revert" event=request.event.slug organizer=request.event.organizer.slug list=checkinlist.pk %}"
|
||||||
</button>
|
data-no-asynctask
|
||||||
{% endif %}
|
value="true">
|
||||||
|
<span class="fa fa-trash" aria-hidden="true"></span>
|
||||||
|
{% trans "Delete all check-ins of selected attendees" %}
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% include "pretixcontrol/pagination.html" %}
|
{% include "pretixcontrol/pagination.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -438,6 +438,7 @@ urlpatterns = [
|
|||||||
re_path(r'^checkinlists/select2$', typeahead.checkinlist_select2, name='event.orders.checkinlists.select2'),
|
re_path(r'^checkinlists/select2$', typeahead.checkinlist_select2, name='event.orders.checkinlists.select2'),
|
||||||
re_path(r'^checkinlists/(?P<list>\d+)/$', checkin.CheckInListShow.as_view(), name='event.orders.checkinlists.show'),
|
re_path(r'^checkinlists/(?P<list>\d+)/$', checkin.CheckInListShow.as_view(), name='event.orders.checkinlists.show'),
|
||||||
re_path(r'^checkinlists/(?P<list>\d+)/simulator$', checkin.CheckInListSimulator.as_view(), name='event.orders.checkinlists.simulator'),
|
re_path(r'^checkinlists/(?P<list>\d+)/simulator$', checkin.CheckInListSimulator.as_view(), name='event.orders.checkinlists.simulator'),
|
||||||
|
re_path(r'^checkinlists/(?P<list>\d+)/bulk_revert$', checkin.CheckInListBulkRevertConfirmView.as_view(), name='event.orders.checkinlists.bulk_revert'),
|
||||||
re_path(r'^checkinlists/(?P<list>\d+)/bulk_action$', checkin.CheckInListBulkActionView.as_view(), name='event.orders.checkinlists.bulk_action'),
|
re_path(r'^checkinlists/(?P<list>\d+)/bulk_action$', checkin.CheckInListBulkActionView.as_view(), name='event.orders.checkinlists.bulk_action'),
|
||||||
re_path(r'^checkinlists/(?P<list>\d+)/change$', checkin.CheckinListUpdate.as_view(),
|
re_path(r'^checkinlists/(?P<list>\d+)/change$', checkin.CheckinListUpdate.as_view(),
|
||||||
name='event.orders.checkinlists.edit'),
|
name='event.orders.checkinlists.edit'),
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ from django.urls import reverse
|
|||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.timezone import is_aware, make_aware, now
|
from django.utils.timezone import is_aware, make_aware, now
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import FormView, ListView
|
from django.views.generic import FormView, ListView, TemplateView
|
||||||
from i18nfield.strings import LazyI18nString
|
from i18nfield.strings import LazyI18nString
|
||||||
|
|
||||||
from pretix.api.views.checkin import _redeem_process
|
from pretix.api.views.checkin import _redeem_process
|
||||||
@@ -191,9 +191,23 @@ class CheckInListShow(EventPermissionRequiredMixin, PaginationMixin, CheckInList
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
|
class CheckInListBulkRevertConfirmView(CheckInListQueryMixin, EventPermissionRequiredMixin, TemplateView):
|
||||||
|
template_name = "pretixcontrol/checkin/bulk_revert_confirm.html"
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
self.list = get_object_or_404(self.request.event.checkin_lists.all(), pk=kwargs.get("list"))
|
||||||
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
return super().get_context_data(
|
||||||
|
**kwargs,
|
||||||
|
cnt=self.get_queryset().count(),
|
||||||
|
checkinlist=self.list,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CheckInListBulkActionView(CheckInListQueryMixin, EventPermissionRequiredMixin, AsyncPostView):
|
class CheckInListBulkActionView(CheckInListQueryMixin, EventPermissionRequiredMixin, AsyncPostView):
|
||||||
permission = ('can_change_orders', 'can_checkin_orders')
|
permission = ('can_change_orders', 'can_checkin_orders')
|
||||||
context_object_name = 'device'
|
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
self.list = get_object_or_404(self.request.event.checkin_lists.all(), pk=kwargs.get("list"))
|
self.list = get_object_or_404(self.request.event.checkin_lists.all(), pk=kwargs.get("list"))
|
||||||
@@ -216,14 +230,15 @@ class CheckInListBulkActionView(CheckInListQueryMixin, EventPermissionRequiredMi
|
|||||||
if op.order.status == Order.STATUS_PAID or (
|
if op.order.status == Order.STATUS_PAID or (
|
||||||
(self.list.include_pending or op.order.valid_if_pending) and op.order.status == Order.STATUS_PENDING
|
(self.list.include_pending or op.order.valid_if_pending) and op.order.status == Order.STATUS_PENDING
|
||||||
):
|
):
|
||||||
Checkin.objects.filter(position=op, list=self.list).delete()
|
_, deleted = Checkin.objects.filter(position=op, list=self.list).delete()
|
||||||
op.order.log_action('pretix.event.checkin.reverted', data={
|
if deleted:
|
||||||
'position': op.id,
|
op.order.log_action('pretix.event.checkin.reverted', data={
|
||||||
'positionid': op.positionid,
|
'position': op.id,
|
||||||
'list': self.list.pk,
|
'positionid': op.positionid,
|
||||||
'web': True
|
'list': self.list.pk,
|
||||||
}, user=request.user)
|
'web': True
|
||||||
op.order.touch()
|
}, user=request.user)
|
||||||
|
op.order.touch()
|
||||||
|
|
||||||
return 'reverted', request.POST.get('returnquery')
|
return 'reverted', request.POST.get('returnquery')
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user