manager: add separate view to update booking check (#80371)
This commit is contained in:
parent
81e93dd4c5
commit
2e22706c08
|
@ -68,7 +68,7 @@
|
|||
class="registrant--bar clearfix booking"
|
||||
title="{% trans "Booked period" %}"
|
||||
style="left: {{ booking.css_left }}%; width: {{ booking.css_width }}%;"
|
||||
{% if allow_check %}
|
||||
{% if allow_check and not booking.user_check %}
|
||||
rel="popup"
|
||||
href="{% url 'chrono-manager-partial-booking-check' pk=agenda.pk booking_pk=booking.pk %}"
|
||||
{% endif %}
|
||||
|
@ -90,7 +90,7 @@
|
|||
style="left: {{ booking.check_css_left }}%; width: {{ booking.check_css_width }}%;"
|
||||
{% if allow_check %}
|
||||
rel="popup"
|
||||
href="{% url 'chrono-manager-partial-booking-check' pk=agenda.pk booking_pk=booking.pk %}"
|
||||
href="{% url 'chrono-manager-partial-booking-update-check' pk=agenda.pk check_pk=booking.user_check.pk %}"
|
||||
{% endif %}
|
||||
>
|
||||
<strong class="sr-only">{% trans "Checked period:" %}</strong>
|
||||
|
|
|
@ -439,6 +439,11 @@ urlpatterns = [
|
|||
views.partial_booking_check_view,
|
||||
name='chrono-manager-partial-booking-check',
|
||||
),
|
||||
path(
|
||||
'agendas/<int:pk>/booking-checks/<int:check_pk>',
|
||||
views.partial_booking_update_check_view,
|
||||
name='chrono-manager-partial-booking-update-check',
|
||||
),
|
||||
path(
|
||||
'agendas/<int:pk>/subscriptions/<int:subscription_pk>/check/<int:event_pk>',
|
||||
views.partial_booking_subscription_check_view,
|
||||
|
|
|
@ -4519,7 +4519,7 @@ class PartialBookingCheckMixin(ViewableAgendaMixin):
|
|||
|
||||
def get_object(self):
|
||||
booking = self.get_booking(**self.kwargs)
|
||||
return booking.user_check or BookingCheck(booking=booking)
|
||||
return BookingCheck(booking=booking)
|
||||
|
||||
def get_success_url(self):
|
||||
date = self.object.booking.event.start_datetime
|
||||
|
@ -4552,6 +4552,17 @@ class PartialBookingSubscriptionCheckView(PartialBookingCheckMixin, Subscription
|
|||
partial_booking_subscription_check_view = PartialBookingSubscriptionCheckView.as_view()
|
||||
|
||||
|
||||
class PartialBookingUpdateCheckView(PartialBookingCheckMixin, UpdateView):
|
||||
model = BookingCheck
|
||||
pk_url_kwarg = 'check_pk'
|
||||
|
||||
def get_object(self):
|
||||
return super(PartialBookingCheckMixin, self).get_object()
|
||||
|
||||
|
||||
partial_booking_update_check_view = PartialBookingUpdateCheckView.as_view()
|
||||
|
||||
|
||||
def menu_json(request):
|
||||
if not request.user.is_staff:
|
||||
homepage_view = HomepageView(request=request)
|
||||
|
|
|
@ -292,7 +292,7 @@ def test_manager_partial_bookings_day_view_multiple_bookings(app, admin_user, fr
|
|||
assert resp.pyquery('.registrant--bar.check')[0].findall('time')[1].text == '12:00'
|
||||
|
||||
# check second booking
|
||||
resp = resp.click('Booked period', index=1)
|
||||
resp = resp.click('Booked period')
|
||||
resp.form['start_time'] = '15:00'
|
||||
resp.form['end_time'] = '17:00'
|
||||
resp.form['presence'] = 'True'
|
||||
|
@ -387,7 +387,7 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
CheckType(slug='bar-reason', label='Bar reason', kind='presence'),
|
||||
CheckType(slug='baz-reason', label='Baz reason', kind='presence'),
|
||||
]
|
||||
resp = resp.click('Booked period')
|
||||
resp = resp.click('Checked period')
|
||||
assert resp.form['presence_check_type'].options == [
|
||||
('', True, '---------'),
|
||||
('bar-reason', False, 'Bar reason'),
|
||||
|
@ -412,7 +412,7 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
assert resp.pyquery('.registrant--bar.computed time')[1].text == '13:30'
|
||||
assert resp.pyquery('.registrant--bar.computed')[0].attrib['style'] == 'left: 30.77%; width: 19.23%;'
|
||||
|
||||
resp = resp.click('Booked period')
|
||||
resp = resp.click('Checked period')
|
||||
assert resp.form['presence_check_type'].value == 'bar-reason'
|
||||
|
||||
resp.form['presence'] = 'False'
|
||||
|
@ -424,7 +424,7 @@ def test_manager_partial_bookings_check(check_types, app, admin_user):
|
|||
assert len(resp.pyquery('.registrant--bar.computed.absent')) == 1
|
||||
assert resp.pyquery('.registrant--bar span').text() == ''
|
||||
|
||||
resp = resp.click('Booked period')
|
||||
resp = resp.click('Checked period')
|
||||
resp.form['presence'] = ''
|
||||
resp = resp.form.submit().follow()
|
||||
assert len(resp.pyquery('.registrant--bar')) == 1
|
||||
|
|
Loading…
Reference in New Issue