manager: set presence reason on bookings (#63810)

This commit is contained in:
Lauréline Guérin 2022-04-14 16:24:34 +02:00
parent ae28ec5858
commit 30afa66e3f
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
7 changed files with 246 additions and 40 deletions

View File

@ -1982,6 +1982,7 @@ class Booking(models.Model):
self.save()
def mark_user_absence(self, check_type=None):
check_type = check_type or ''
self.user_check_type = check_type
self.user_was_present = False
with transaction.atomic():
@ -1990,11 +1991,12 @@ class Booking(models.Model):
self.save()
self.event.set_is_checked()
def mark_user_presence(self):
self.user_check_type = ''
def mark_user_presence(self, check_type=None):
check_type = check_type or ''
self.user_check_type = check_type
self.user_was_present = True
with transaction.atomic():
self.secondary_booking_set.update(user_check_type='')
self.secondary_booking_set.update(user_check_type=check_type)
self.secondary_booking_set.update(user_was_present=True)
self.save()
self.event.set_is_checked()

View File

@ -442,8 +442,13 @@ class BookingCheckFilterSet(django_filters.FilterSet):
('cancelled', _('Cancelled')),
('not-checked', _('Not checked')),
('presence', _('Presence')),
('absence', _('Absence')),
]
if self.agenda.check_type_group:
status_choices += [
('presence-%s' % r.label, _('Presence (%s)') % r.label)
for r in self.agenda.check_type_group.check_types.presences()
]
status_choices += [('absence', _('Absence'))]
if self.agenda.check_type_group:
status_choices += [
('absence-%s' % r.label, _('Absence (%s)') % r.label)
@ -474,6 +479,8 @@ class BookingCheckFilterSet(django_filters.FilterSet):
return queryset.filter(user_was_present=False)
if value.startswith('absence-'):
return queryset.filter(user_was_present=False, user_check_type=value[8:])
if value.startswith('presence-'):
return queryset.filter(user_was_present=True, user_check_type=value[9:])
return queryset
def do_nothing(self, queryset, name, value):
@ -503,6 +510,18 @@ class BookingCheckAbsenceForm(forms.Form):
]
class BookingCheckPresenceForm(forms.Form):
check_type = forms.ChoiceField(required=False)
def __init__(self, *args, **kwargs):
agenda = kwargs.pop('agenda')
super().__init__(*args, **kwargs)
if agenda.check_type_group:
self.fields['check_type'].choices = [('', '---------')] + [
(r.label, r.label) for r in agenda.check_type_group.check_types.presences()
]
class EventsTimesheetForm(forms.Form):
date_start = forms.DateField(
label=_('Start date'),

View File

@ -42,9 +42,18 @@
<tr class="booking all-bookings">
<td colspan="2"><b>{% trans "Mark all bookings without status:" %}</b></td>
<td class="booking-actions">
<form method="post" action="{% url 'chrono-manager-event-presence' pk=agenda.pk event_pk=object.pk %}">
<form method="post" action="{% url 'chrono-manager-event-presence' pk=agenda.pk event_pk=object.pk %}" id="all-bookings-presence">
{% csrf_token %}
<button class="submit-button">{% trans "Presence" %}</button>
{% if presence_form.check_type.field.choices.1 %}{{ presence_form.check_type }}{% endif %}
<script>
$(function() {
$('#all-bookings-presence select').on('change',
function() {
$('#all-bookings-presence').submit();
});
});
</script>
</form>
<form method="post" action="{% url 'chrono-manager-event-absence' pk=agenda.pk event_pk=object.pk %}" id="all-bookings-absence">
{% csrf_token %}

View File

@ -3,29 +3,38 @@
<td class="booking-username main-list">{{ booking.get_user_block }}{% if booking.places_count > 1 %} ({{ booking.places_count }} {% trans "places" %}){% endif %}</td>
<td class="booking-status {% if booking.user_was_present is None %}without-status{% endif %}">
{{ booking.user_was_present|yesno:_('Present,Absent,-') }}
{% if booking.user_was_present is False and booking.user_check_type %}
{% if booking.user_was_present is not None and booking.user_check_type %}
({{ booking.user_check_type }})
{% endif %}
</td>
{% if not event.checked or not agenda.disable_check_update %}
<td class="booking-actions" data-booking-id="{{ booking.id }}">
<form method="post" action="{% url 'chrono-manager-booking-presence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax">
<form method="post" action="{% url 'chrono-manager-booking-presence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax presence">
{% csrf_token %}
<button class="submit-button"
{% if booking.user_was_present is True %}disabled{% endif %}
>{% trans "Presence" %}</button>
{% if booking.presence_form.check_type.field.choices.1 %}{{ booking.presence_form.check_type }}{% endif %}
<script>
$(function() {
$('td[data-booking-id="{{ booking.id }}"] form.presence select').on('change',
function() {
$(this).parents('form.presence').submit();
});
});
</script>
</form>
<form method="post" action="{% url 'chrono-manager-booking-absence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax">
<form method="post" action="{% url 'chrono-manager-booking-absence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax absence">
{% csrf_token %}
<button class="submit-button"
{% if booking.user_was_present is False %}disabled{% endif %}
>{% trans "Absence" %}</button>
{% if booking.form.check_type.field.choices.1 %}{{ booking.form.check_type }}{% endif %}
{% if booking.absence_form.check_type.field.choices.1 %}{{ booking.absence_form.check_type }}{% endif %}
<script>
$(function() {
$('td[data-booking-id="{{ booking.id }}"] select').on('change',
$('td[data-booking-id="{{ booking.id }}"] form.absence select').on('change',
function() {
$(this).parents('form').submit();
$(this).parents('form.absence').submit();
});
});
</script>

View File

@ -104,6 +104,7 @@ from .forms import (
BookingCancelForm,
BookingCheckAbsenceForm,
BookingCheckFilterSet,
BookingCheckPresenceForm,
CheckTypeForm,
CustomFieldFormSet,
DeskExceptionsImportForm,
@ -745,7 +746,7 @@ check_type_group_export = CheckTypeGroupExport.as_view()
class CheckTypeAddView(CreateView):
template_name = 'chrono/manager_check_type_form.html'
model = CheckType
fields = ['label']
fields = ['kind', 'label']
def dispatch(self, request, *args, **kwargs):
self.group_pk = kwargs.pop('group_pk')
@ -2335,8 +2336,13 @@ class EventCheckView(ViewableAgendaMixin, DetailView):
for booking in booked_filterset.qs:
if booking.cancellation_datetime is None and booking.user_was_present is None:
booked_without_status = True
booking.form = BookingCheckAbsenceForm(
agenda=self.agenda, initial={'check_type': booking.user_check_type}
booking.absence_form = BookingCheckAbsenceForm(
agenda=self.agenda,
initial={'check_type': booking.user_check_type if booking.user_was_present is False else ''},
)
booking.presence_form = BookingCheckPresenceForm(
agenda=self.agenda,
initial={'check_type': booking.user_check_type if booking.user_was_present is True else ''},
)
booking.kind = 'booking'
results.append(booking)
@ -2357,6 +2363,7 @@ class EventCheckView(ViewableAgendaMixin, DetailView):
context['booked_without_status'] = booked_without_status
if context['booked_without_status']:
context['absence_form'] = BookingCheckAbsenceForm(agenda=self.agenda)
context['presence_form'] = BookingCheckPresenceForm(agenda=self.agenda)
context['filterset'] = booked_filterset
context['results'] = results
context['waiting'] = waiting_qs
@ -2402,10 +2409,21 @@ class EventCheckMixin:
)
class EventPresenceView(EventCheckMixin, ViewableAgendaMixin, View):
class EventPresenceView(EventCheckMixin, ViewableAgendaMixin, FormView):
form_class = BookingCheckPresenceForm
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs['agenda'] = self.agenda
return kwargs
def post(self, request, *args, **kwargs):
form = self.get_form()
qs_kwargs = {}
if form.is_valid():
qs_kwargs['user_check_type'] = form.cleaned_data['check_type']
bookings = self.get_bookings()
bookings.update(user_check_type='', user_was_present=True)
bookings.update(user_was_present=True, **qs_kwargs)
self.event.set_is_checked()
return self.response(request)
@ -3121,7 +3139,10 @@ class BookingCheckMixin:
def response(self, request, booking):
if request.is_ajax():
booking.form = BookingCheckAbsenceForm(
booking.absence_form = BookingCheckAbsenceForm(
agenda=self.agenda, initial={'check_type': booking.user_check_type}
)
booking.presence_form = BookingCheckPresenceForm(
agenda=self.agenda, initial={'check_type': booking.user_check_type}
)
return render(
@ -3137,10 +3158,21 @@ class BookingCheckMixin:
)
class BookingPresenceView(ViewableAgendaMixin, BookingCheckMixin, View):
class BookingPresenceView(ViewableAgendaMixin, BookingCheckMixin, FormView):
form_class = BookingCheckPresenceForm
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs['agenda'] = self.agenda
return kwargs
def post(self, request, *args, **kwargs):
booking = self.get_booking(**kwargs)
booking.mark_user_presence()
form = self.get_form()
check_type = None
if form.is_valid():
check_type = form.cleaned_data['check_type']
booking.mark_user_presence(check_type=check_type)
return self.response(request, booking)

View File

@ -103,6 +103,16 @@ def test_add_check_type(app, admin_user):
assert check_type.slug == 'foo-reason'
assert check_type.kind == 'absence'
resp = app.get('/manage/check-type/group/%s/add/' % group.pk)
resp.form['label'] = 'Foo reason'
resp.form['kind'] = 'presence'
resp = resp.form.submit()
assert resp.location.endswith('/manage/check-types/')
check_type = CheckType.objects.latest('pk')
assert check_type.label == 'Foo reason'
assert check_type.slug == 'foo-reason-1'
assert check_type.kind == 'presence'
def test_add_check_type_as_manager(app, manager_user, agenda_with_restrictions):
group = CheckTypeGroup.objects.create(label='Foo bar')
@ -123,6 +133,7 @@ def test_edit_check_type(app, admin_user):
resp = resp.click(href='/manage/check-type/group/%s/%s/edit/' % (group.pk, check_type.pk))
resp.form['label'] = 'Foo bar reason'
resp.form['slug'] = check_type2.slug
assert 'kind' not in resp.context['form'].fields
resp = resp.form.submit()
assert resp.context['form'].errors['slug'] == ['Another check type exists with the same identifier.']

View File

@ -1621,7 +1621,8 @@ def test_event_checked(app, admin_user):
def test_event_check_filters(app, admin_user):
group = CheckTypeGroup.objects.create(label='Foo bar')
check_type = CheckType.objects.create(label='Foo reason', group=group)
check_type_absence = CheckType.objects.create(label='Foo reason', group=group, kind='absence')
check_type_presence = CheckType.objects.create(label='Bar reason', group=group, kind='presence')
agenda = Agenda.objects.create(
label='Events', kind='events', booking_check_filters='foo,bar', check_type_group=group
)
@ -1671,16 +1672,35 @@ def test_event_check_filters(app, admin_user):
user_last_name='foo-none bar-val2 reason-foo',
extra_data={'bar': 'val2'},
user_was_present=False,
user_check_type=check_type.label,
user_check_type=check_type_absence.label,
)
Booking.objects.create(
event=event,
user_external_id='user:5',
user_first_name='User',
user_last_name='foo-none bar-val2 cancelled',
user_last_name='foo-none bar-val2 reason-bar',
extra_data={'bar': 'val2'},
user_was_present=True,
user_check_type=check_type_presence.label,
)
Booking.objects.create(
event=event,
user_external_id='user:6',
user_first_name='User',
user_last_name='foo-none bar-val2 cancelled-absence',
extra_data={'bar': 'val2'},
user_was_present=False,
user_check_type=check_type.label,
user_check_type=check_type_absence.label,
cancellation_datetime=now(),
)
Booking.objects.create(
event=event,
user_external_id='user:7',
user_first_name='User',
user_last_name='foo-none bar-val2 cancelled-presence',
extra_data={'bar': 'val2'},
user_was_present=True,
user_check_type=check_type_presence.label,
cancellation_datetime=now(),
)
@ -1752,7 +1772,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' in resp
assert 'User foo-val1 bar-val2 not-checked' in resp
assert 'User foo-none bar-val2 reason-foo' in resp
assert 'User foo-none bar-val2 cancelled' in resp
assert 'User foo-none bar-val2 reason-bar' in resp
assert 'User foo-none bar-val2 cancelled-absence' in resp
assert 'User foo-none bar-val2 cancelled-presence' in resp
assert 'Subscription none' in resp
assert 'Subscription empty' in resp
assert 'Subscription foo-val1 bar-none' in resp
@ -1769,7 +1791,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' in resp
@ -1787,7 +1811,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1805,7 +1831,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1822,7 +1850,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' in resp
assert 'User foo-val1 bar-val2 not-checked' in resp
assert 'User foo-none bar-val2 reason-foo' in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1839,7 +1869,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' in resp
assert 'Subscription empty' in resp
assert 'Subscription foo-val1 bar-none' in resp
@ -1856,7 +1888,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' in resp
assert 'User foo-none bar-val2 cancelled-presence' in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1873,7 +1907,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1890,7 +1926,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1907,7 +1945,9 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -1925,7 +1965,29 @@ def test_event_check_filters(app, admin_user):
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' in resp
assert 'User foo-none bar-val2 cancelled' not in resp
assert 'User foo-none bar-val2 reason-bar' not in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
assert 'Subscription foo-val2 bar-val1' not in resp
assert 'Subscription foo-val1 bar-val2' not in resp
assert 'Subscription foo-none bar-val2' not in resp
resp = app.get(
'/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk),
params={'booking-status': 'presence-Bar reason'},
)
assert 'User none' not in resp
assert 'User empty' not in resp
assert 'User foo-val1 bar-none presence' not in resp
assert 'User foo-val2 bar-val1 absence' not in resp
assert 'User foo-val1 bar-val2 not-checked' not in resp
assert 'User foo-none bar-val2 reason-foo' not in resp
assert 'User foo-none bar-val2 reason-bar' in resp
assert 'User foo-none bar-val2 cancelled-absence' not in resp
assert 'User foo-none bar-val2 cancelled-presence' not in resp
assert 'Subscription none' not in resp
assert 'Subscription empty' not in resp
assert 'Subscription foo-val1 bar-none' not in resp
@ -2036,11 +2098,13 @@ def test_event_check_booking(app, admin_user):
agenda.check_type_group = group
agenda.save()
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
assert len(resp.pyquery.find('td.booking-actions select')) == 0
assert len(resp.pyquery.find('td.booking-actions form.absence select')) == 0
assert len(resp.pyquery.find('td.booking-actions form.presence select')) == 0
CheckType.objects.create(label='Foo reason', group=group)
CheckType.objects.create(label='Foo reason', group=group, kind='absence')
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
assert len(resp.pyquery.find('td.booking-actions select')) == 1
assert len(resp.pyquery.find('td.booking-actions form.absence select')) == 1
assert len(resp.pyquery.find('td.booking-actions form.presence select')) == 0
# set as absent with check_type
resp = app.post(
@ -2055,17 +2119,46 @@ def test_event_check_booking(app, admin_user):
assert secondary_booking.user_was_present is False
assert secondary_booking.user_check_type == 'Foo reason'
# set as present
app.post(
# set as present without check_type
resp = app.post(
'/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking.pk),
params={'csrfmiddlewaretoken': token},
)
).follow()
assert resp.pyquery.find('td.booking-status')[0].text.strip() == 'Present'
assert len(resp.pyquery.find('td.booking-actions button[disabled]')) == 1
assert resp.pyquery.find('td.booking-actions button[disabled]')[0].text == 'Presence'
booking.refresh_from_db()
assert booking.user_was_present is True
assert booking.user_check_type == ''
secondary_booking.refresh_from_db()
assert secondary_booking.user_was_present is True
assert secondary_booking.user_check_type == ''
event.refresh_from_db()
assert event.checked is True
agenda.check_type_group = group
agenda.save()
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
assert len(resp.pyquery.find('td.booking-actions form.absence select')) == 1
assert len(resp.pyquery.find('td.booking-actions form.presence select')) == 0
CheckType.objects.create(label='Bar reason', group=group, kind='presence')
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
assert len(resp.pyquery.find('td.booking-actions form.absence select')) == 1
assert len(resp.pyquery.find('td.booking-actions form.presence select')) == 1
# set as present with check_type
resp = app.post(
'/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking.pk),
params={'csrfmiddlewaretoken': token, 'check_type': 'Bar reason'},
).follow()
assert 'Bar reason' in resp
booking.refresh_from_db()
assert booking.user_was_present is True
assert booking.user_check_type == 'Bar reason'
secondary_booking.refresh_from_db()
assert secondary_booking.user_was_present is True
assert secondary_booking.user_check_type == 'Bar reason'
# mark the event as checked
event.checked = True
@ -2145,6 +2238,7 @@ def test_event_check_booking_ajax(app, admin_user):
def test_event_check_all_bookings(app, admin_user):
group = CheckTypeGroup.objects.create(label='Foo bar')
CheckType.objects.create(label='Foo reason', group=group)
CheckType.objects.create(label='Bar reason', group=group, kind='presence')
agenda = Agenda.objects.create(label='Events', kind='events', check_type_group=group)
event = Event.objects.create(
label='xyz',
@ -2222,6 +2316,26 @@ def test_event_check_all_bookings(app, admin_user):
assert booking3.user_was_present is False
assert booking3.user_check_type == 'Foo reason'
booking4 = Booking.objects.create(event=event, user_first_name='User', user_last_name='52')
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
assert 'Mark all bookings without status' in resp
app.post(
'/manage/agendas/%s/events/%s/presence' % (agenda.pk, event.pk),
params={'csrfmiddlewaretoken': token, 'check_type': 'Bar reason'},
)
booking1.refresh_from_db()
assert booking1.user_was_present is False
assert booking1.user_check_type == ''
booking2.refresh_from_db()
assert booking2.user_was_present is True
assert booking2.user_check_type == ''
booking3.refresh_from_db()
assert booking3.user_was_present is False
assert booking3.user_check_type == 'Foo reason'
booking4.refresh_from_db()
assert booking4.user_was_present is True
assert booking4.user_check_type == 'Bar reason'
# now disable check update
agenda.disable_check_update = True
agenda.save()
@ -2238,6 +2352,16 @@ def test_event_check_all_bookings(app, admin_user):
params={'csrfmiddlewaretoken': token},
status=404,
)
app.post(
'/manage/agendas/%s/events/%s/presence' % (agenda.pk, event.pk),
params={'csrfmiddlewaretoken': token, 'check_type': 'Bar reason'},
status=404,
)
resp = app.post(
'/manage/agendas/%s/events/%s/presence' % (agenda.pk, event.pk),
params={'csrfmiddlewaretoken': token},
status=404,
)
def test_event_check_primary_booking(app, admin_user):