Compare commits

..

9 Commits

5 changed files with 73 additions and 11 deletions

View File

@@ -163,12 +163,27 @@ class CheckinListViewSet(viewsets.ModelViewSet):
serializer.is_valid(raise_exception=True)
kwargs = {}
if not serializer.validated_data.get('position'):
kwargs['position'] = OrderPosition.all.filter(
secret=serializer.validated_data['raw_barcode']
).first()
clist = self.get_object()
if not serializer.validated_data.get('position'):
# an offline checkin failed, let's see whether a ticket with the given secret actually exists and just
# was not synced in time, so we can enrich the log message
try:
candidate_position = OrderPosition.all.get(
organizer=self.request.organizer,
secret=serializer.validated_data['raw_barcode']
)
except (OrderPosition.DoesNotExist, OrderPosition.MultipleObjectsReturned):
pass
else:
if candidate_position.event.pk != clist.event.pk and 'candidate_checkin_lists' in self.request.data:
try:
clist = candidate_position.event.checkin_lists.get(pk__in=self.request.data['candidate_checkin_lists'])
except CheckinList.DoesNotExist:
pass # ignore if candidate position's event was not active on device, if list was deleted in between
if candidate_position.event.pk == clist.event.pk:
kwargs['position'] = candidate_position
if serializer.validated_data.get('nonce'):
if kwargs.get('position'):
prev = kwargs['position'].all_checkins.filter(nonce=serializer.validated_data['nonce']).first()

View File

@@ -80,7 +80,7 @@ class OrderLogEntryType(EventLogEntryType):
content_type = Order
def object_link_args(self, order):
return {'code': order.code}
return {'event': order.event.slug, 'code': order.code}
def object_link_display_name(self, order):
return order.code

View File

@@ -1308,10 +1308,13 @@ DEFAULTS = {
'serializer_class': serializers.BooleanField,
'form_class': forms.BooleanField,
'form_kwargs': dict(
label=_("Show event times and dates on the ticket shop"),
help_text=_("If disabled, no date or time will be shown on the ticket shop's front page. This settings "
"also affects a few other locations, however it should not be expected that the date of the "
"event is shown nowhere to users."),
label=_("This shop represents an event"),
help_text=_(
"Uncheck this box if you are only selling something that has no specific date, such as gift cards or a "
"ticket that can be used any time. The system will then stop showing the event date in some places like "
"the event start page. Note that pretix still is a system built around events and the date may still "
"show up in other places."
),
)
},
'show_date_to': {

View File

@@ -1,6 +1,6 @@
/*global $,u2f */
$(function () {
$('.sidebar .dropdown, ul.navbar-nav .dropdown, .navbar-events-collapse').on('shown.bs.collapse shown.bs.dropdown', function () {
$('.context-selector.dropdown').on('shown.bs.collapse shown.bs.dropdown', function () {
$(this).parent().find("input").val("").trigger('forceRunQuery').focus();
});
$('.dropdown-menu .form-box input').click(function (e) {

View File

@@ -777,6 +777,50 @@ def test_store_failed(token_client, organizer, clist, event, order):
assert resp.status_code == 400
@pytest.mark.django_db
def test_store_failed_other_event(token_client, organizer, clist, event, clist_event2, event2, order):
with scopes_disabled():
p = order.positions.first()
p.secret = 'xyzabc'
p.save()
resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format(
organizer.slug, event.slug, clist.pk,
), {
'raw_barcode': 'xyzabc',
'error_reason': 'invalid',
'nonce': '111',
}, format='json')
assert resp.status_code == 201
with scopes_disabled():
c = Checkin.all.get(nonce='111')
assert c.position == p
resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format(
organizer.slug, event2.slug, clist_event2.pk,
), {
'raw_barcode': 'xyzabc',
'error_reason': 'invalid',
'nonce': '222',
}, format='json')
assert resp.status_code == 201
with scopes_disabled():
c = Checkin.all.get(nonce='222')
assert c.position is None
resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format(
organizer.slug, event2.slug, clist_event2.pk,
), {
'raw_barcode': 'xyzabc',
'error_reason': 'invalid',
'candidate_checkin_lists': [clist.pk, clist_event2.pk],
'nonce': '333',
}, format='json')
assert resp.status_code == 201
with scopes_disabled():
c = Checkin.all.get(nonce='333')
assert c.position == p
@pytest.mark.django_db
def test_redeem_unknown(token_client, organizer, clist, event, order):
resp = _redeem(token_client, organizer, clist, 'unknown_secret', {'force': True})