Absent/Checked Out persons in Checkin lists (#1721)

This commit is contained in:
Martin Gross
2020-07-20 10:41:39 +02:00
committed by GitHub
parent 3c5948d2e0
commit 6842127802
2 changed files with 26 additions and 2 deletions

View File

@@ -837,6 +837,7 @@ class CheckInFilterForm(FilterForm):
label=_('Check-in status'),
choices=(
('', _('All attendees')),
('3', pgettext_lazy('checkin state', 'Checked in but left')),
('2', pgettext_lazy('checkin state', 'Present')),
('1', _('Checked in')),
('0', _('Not checked in')),
@@ -883,6 +884,10 @@ class CheckInFilterForm(FilterForm):
qs = qs.filter(last_entry__isnull=False).filter(
Q(last_exit__isnull=True) | Q(last_exit__lt=F('last_entry'))
)
elif s == '3':
qs = qs.filter(last_entry__isnull=False).filter(
Q(last_exit__isnull=False) & Q(last_exit__gte=F('last_entry'))
)
elif s == '0':
qs = qs.filter(last_entry__isnull=True)

View File

@@ -120,10 +120,18 @@ class CheckInListMixin(BaseExporter):
m=Max('datetime')
).values('m')
cqsin = cqs.filter(
type=Checkin.TYPE_ENTRY
)
cqsout = cqs.filter(
type=Checkin.TYPE_EXIT
)
qs = OrderPosition.objects.filter(
order__event=self.event,
).annotate(
last_checked_in=Subquery(cqs),
last_checked_in=Subquery(cqsin),
last_checked_out=Subquery(cqsout),
auto_checked_in=Exists(
Checkin.objects.filter(position_id=OuterRef('pk'), list_id=cl.pk, auto_checked_in=True)
)
@@ -393,7 +401,7 @@ class CSVCheckinList(CheckInListMixin, ListExporter):
for k, label, w in name_scheme['fields']:
headers.append(_('Attendee name: {part}').format(part=label))
headers += [
_('Product'), _('Price'), _('Checked in'), _('Automatically checked in')
_('Product'), _('Price'), _('Checked in'), _('Checked out'), _('Automatically checked in')
]
if not cl.include_pending:
qs = qs.filter(order__status=Order.STATUS_PAID)
@@ -434,6 +442,15 @@ class CSVCheckinList(CheckInListMixin, ListExporter):
last_checked_in = op.last_checked_in
if last_checked_in and not is_aware(last_checked_in):
last_checked_in = make_aware(last_checked_in, UTC)
last_checked_out = None
if isinstance(op.last_checked_out, str): # SQLite
last_checked_out = dateutil.parser.parse(op.last_checked_out)
elif op.last_checked_out:
last_checked_out = op.last_checked_out
if last_checked_out and not is_aware(last_checked_out):
last_checked_out = make_aware(last_checked_out, UTC)
row = [
op.order.code,
op.attendee_name or (op.addon_to.attendee_name if op.addon_to else '') or ia.name,
@@ -452,6 +469,8 @@ class CSVCheckinList(CheckInListMixin, ListExporter):
op.price,
date_format(last_checked_in.astimezone(self.event.timezone), 'SHORT_DATETIME_FORMAT')
if last_checked_in else '',
date_format(last_checked_out.astimezone(self.event.timezone), 'SHORT_DATETIME_FORMAT')
if last_checked_out else '',
_('Yes') if op.auto_checked_in else _('No'),
]
if cl.include_pending: