forked from CGM_Public/pretix_original
Allow to manually revert check-ins on a check-in list
This commit is contained in:
@@ -334,6 +334,20 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs):
|
|||||||
list=checkin_list
|
list=checkin_list
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if logentry.action_type == 'pretix.control.views.checkin.reverted':
|
||||||
|
if 'list' in data:
|
||||||
|
try:
|
||||||
|
checkin_list = sender.checkin_lists.get(pk=data.get('list')).name
|
||||||
|
except CheckinList.DoesNotExist:
|
||||||
|
checkin_list = _("(unknown)")
|
||||||
|
else:
|
||||||
|
checkin_list = _("(unknown)")
|
||||||
|
|
||||||
|
return _('The check-in of position #{posid} on list "{list}" has been reverted.').format(
|
||||||
|
posid=data.get('positionid'),
|
||||||
|
list=checkin_list,
|
||||||
|
)
|
||||||
|
|
||||||
if logentry.action_type == 'pretix.team.member.added':
|
if logentry.action_type == 'pretix.team.member.added':
|
||||||
return _('{user} has been added to the team.').format(user=data.get('email'))
|
return _('{user} has been added to the team.').format(user=data.get('email'))
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,9 @@
|
|||||||
<button type="submit" class="btn btn-primary btn-save">
|
<button type="submit" class="btn btn-primary btn-save">
|
||||||
{% trans "Check-In selected attendees" %}
|
{% trans "Check-In selected attendees" %}
|
||||||
</button>
|
</button>
|
||||||
|
<button type="submit" class="btn btn-default btn-save" name="revert" value="true">
|
||||||
|
{% trans "Revert selected check-ins" %}
|
||||||
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
{% include "pretixcontrol/pagination.html" %}
|
{% include "pretixcontrol/pagination.html" %}
|
||||||
|
|||||||
@@ -90,21 +90,34 @@ class CheckInListShow(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
|||||||
pk__in=request.POST.getlist('checkin')
|
pk__in=request.POST.getlist('checkin')
|
||||||
)
|
)
|
||||||
|
|
||||||
for op in positions:
|
if request.POST.get('revert') == 'true':
|
||||||
created = False
|
for op in positions:
|
||||||
if op.order.status == Order.STATUS_PAID or (self.list.include_pending and op.order.status == Order.STATUS_PENDING):
|
if op.order.status == Order.STATUS_PAID or (self.list.include_pending and op.order.status == Order.STATUS_PENDING):
|
||||||
ci, created = Checkin.objects.get_or_create(position=op, list=self.list, defaults={
|
Checkin.objects.filter(position=op, list=self.list).delete()
|
||||||
'datetime': now(),
|
op.order.log_action('pretix.control.views.checkin.reverted', data={
|
||||||
})
|
'position': op.id,
|
||||||
op.order.log_action('pretix.control.views.checkin', data={
|
'positionid': op.positionid,
|
||||||
'position': op.id,
|
'list': self.list.pk
|
||||||
'positionid': op.positionid,
|
}, user=request.user)
|
||||||
'first': created,
|
|
||||||
'datetime': now(),
|
messages.success(request, _('The selected check-ins have been reverted.'))
|
||||||
'list': self.list.pk
|
else:
|
||||||
}, user=request.user)
|
for op in positions:
|
||||||
|
created = False
|
||||||
|
if op.order.status == Order.STATUS_PAID or (self.list.include_pending and op.order.status == Order.STATUS_PENDING):
|
||||||
|
ci, created = Checkin.objects.get_or_create(position=op, list=self.list, defaults={
|
||||||
|
'datetime': now(),
|
||||||
|
})
|
||||||
|
op.order.log_action('pretix.control.views.checkin', data={
|
||||||
|
'position': op.id,
|
||||||
|
'positionid': op.positionid,
|
||||||
|
'first': created,
|
||||||
|
'datetime': now(),
|
||||||
|
'list': self.list.pk
|
||||||
|
}, user=request.user)
|
||||||
|
|
||||||
|
messages.success(request, _('The selected tickets have been marked as checked in.'))
|
||||||
|
|
||||||
messages.success(request, _('The selected tickets have been marked as checked in.'))
|
|
||||||
return redirect(reverse('control:event.orders.checkinlists.show', kwargs={
|
return redirect(reverse('control:event.orders.checkinlists.show', kwargs={
|
||||||
'event': self.request.event.slug,
|
'event': self.request.event.slug,
|
||||||
'organizer': self.request.event.organizer.slug,
|
'organizer': self.request.event.organizer.slug,
|
||||||
|
|||||||
@@ -266,6 +266,26 @@ def test_manual_checkins(client, checkin_list_env):
|
|||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_manual_checkins_revert(client, checkin_list_env):
|
||||||
|
client.login(email='dummy@dummy.dummy', password='dummy')
|
||||||
|
assert not checkin_list_env[5][3].checkins.exists()
|
||||||
|
client.post('/control/event/dummy/dummy/checkinlists/{}/'.format(checkin_list_env[6].pk), {
|
||||||
|
'checkin': [checkin_list_env[5][3].pk]
|
||||||
|
})
|
||||||
|
client.post('/control/event/dummy/dummy/checkinlists/{}/'.format(checkin_list_env[6].pk), {
|
||||||
|
'checkin': [checkin_list_env[5][3].pk],
|
||||||
|
'revert': 'true'
|
||||||
|
})
|
||||||
|
assert not checkin_list_env[5][3].checkins.exists()
|
||||||
|
assert LogEntry.objects.filter(
|
||||||
|
action_type='pretix.control.views.checkin', object_id=checkin_list_env[5][3].order.pk
|
||||||
|
).exists()
|
||||||
|
assert LogEntry.objects.filter(
|
||||||
|
action_type='pretix.control.views.checkin.reverted', object_id=checkin_list_env[5][3].order.pk
|
||||||
|
).exists()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def checkin_list_with_addon_env():
|
def checkin_list_with_addon_env():
|
||||||
# permission
|
# permission
|
||||||
|
|||||||
Reference in New Issue
Block a user