manager: lock check if flag check_locked is enabled (#75416)
gitea/chrono/pipeline/head This commit looks good
Details
gitea/chrono/pipeline/head This commit looks good
Details
This commit is contained in:
parent
a1302e3389
commit
8892bd7bcb
|
@ -49,6 +49,9 @@
|
||||||
{% if event.main_list_full %}
|
{% if event.main_list_full %}
|
||||||
<span class="full tag">{% trans "Full" %}</span>
|
<span class="full tag">{% trans "Full" %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if event.check_locked %}
|
||||||
|
<span class="check-locked tag">{% trans "Check locked" %}</span>
|
||||||
|
{% endif %}
|
||||||
{% if event.checked %}
|
{% if event.checked %}
|
||||||
<span class="checked tag">{% trans "Checked" %}</span>
|
<span class="checked tag">{% trans "Checked" %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
({% trans "Cancelled" %})
|
({% trans "Cancelled" %})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not event.checked or not agenda.disable_check_update %}
|
{% if not event.checked or not agenda.disable_check_update %}
|
||||||
{% if booking.user_was_present is not None %}
|
{% if booking.user_was_present is not None and not event.check_locked %}
|
||||||
<form method="post" action="{% url 'chrono-manager-booking-reset' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax reset">
|
<form method="post" action="{% url 'chrono-manager-booking-reset' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax reset">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<a href="#">{% trans "Reset" context "check" %}</a>
|
<a href="#">{% trans "Reset" context "check" %}</a>
|
||||||
|
@ -33,45 +33,47 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if not event.checked or not agenda.disable_check_update %}
|
{% if not event.check_locked %}
|
||||||
<td class="booking-actions" data-{{ booking.kind }}-id="{{ booking.id }}">
|
{% if not event.checked or not agenda.disable_check_update %}
|
||||||
|
<td class="booking-actions" data-{{ booking.kind }}-id="{{ booking.id }}">
|
||||||
|
{% if booking.kind == "subscription" %}
|
||||||
|
<form method="post" action="{% url 'chrono-manager-subscription-presence' pk=agenda.pk subscription_pk=booking.pk event_pk=event.pk %}" class="with-ajax presence">
|
||||||
|
{% else %}
|
||||||
|
<form method="post" action="{% url 'chrono-manager-booking-presence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax presence">
|
||||||
|
{% endif %}
|
||||||
|
{% 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.booking-actions[data-{{ booking.kind }}-id="{{ booking.id }}"] form.presence select').on('change',
|
||||||
|
function() {
|
||||||
|
$(this).parents('form.presence').submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</form>
|
||||||
{% if booking.kind == "subscription" %}
|
{% if booking.kind == "subscription" %}
|
||||||
<form method="post" action="{% url 'chrono-manager-subscription-presence' pk=agenda.pk subscription_pk=booking.pk event_pk=event.pk %}" class="with-ajax presence">
|
<form method="post" action="{% url 'chrono-manager-subscription-absence' pk=agenda.pk subscription_pk=booking.pk event_pk=event.pk %}" class="with-ajax absence">
|
||||||
{% else %}
|
{% else %}
|
||||||
<form method="post" action="{% url 'chrono-manager-booking-presence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax presence">
|
<form method="post" action="{% url 'chrono-manager-booking-absence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax absence">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="submit-button"
|
<button class="submit-button"
|
||||||
{% if booking.user_was_present is True %}disabled{% endif %}
|
{% if booking.user_was_present is False %}disabled{% endif %}
|
||||||
>{% trans "Presence" %}</button>
|
>{% trans "Absence" %}</button>
|
||||||
{% if booking.presence_form.check_type.field.choices.1 %}{{ booking.presence_form.check_type }}{% endif %}
|
{% if booking.absence_form.check_type.field.choices.1 %}{{ booking.absence_form.check_type }}{% endif %}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$('td.booking-actions[data-{{ booking.kind }}-id="{{ booking.id }}"] form.presence select').on('change',
|
$('td.booking-actions[data-{{ booking.kind }}-id="{{ booking.id }}"] form.absence select').on('change',
|
||||||
function() {
|
function() {
|
||||||
$(this).parents('form.presence').submit();
|
$(this).parents('form.absence').submit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</form>
|
</form>
|
||||||
{% if booking.kind == "subscription" %}
|
</td>
|
||||||
<form method="post" action="{% url 'chrono-manager-subscription-absence' pk=agenda.pk subscription_pk=booking.pk event_pk=event.pk %}" class="with-ajax absence">
|
|
||||||
{% else %}
|
|
||||||
<form method="post" action="{% url 'chrono-manager-booking-absence' pk=agenda.pk booking_pk=booking.pk %}" class="with-ajax absence">
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% csrf_token %}
|
|
||||||
<button class="submit-button"
|
|
||||||
{% if booking.user_was_present is False %}disabled{% endif %}
|
|
||||||
>{% trans "Absence" %}</button>
|
|
||||||
{% if booking.absence_form.check_type.field.choices.1 %}{{ booking.absence_form.check_type }}{% endif %}
|
|
||||||
<script>
|
|
||||||
$(function() {
|
|
||||||
$('td.booking-actions[data-{{ booking.kind }}-id="{{ booking.id }}"] form.absence select').on('change',
|
|
||||||
function() {
|
|
||||||
$(this).parents('form.absence').submit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<div class="event-title-meta">
|
<div class="event-title-meta">
|
||||||
{% if event.cancellation_status %}<span class="tag">{{ event.cancellation_status }}</span>{% endif %}
|
{% if event.cancellation_status %}<span class="tag">{{ event.cancellation_status }}</span>{% endif %}
|
||||||
{% if event.main_list_full %}<span class="tag">{% trans "Full" %}</span>{% endif %}
|
{% if event.main_list_full %}<span class="tag">{% trans "Full" %}</span>{% endif %}
|
||||||
|
{% if event.check_locked %}<span class="check-locked tag">{% trans "Check locked" %}</span>{% endif %}
|
||||||
{% if event.checked %}<span class="checked tag">{% trans "Checked" %}</span>{% endif %}
|
{% if event.checked %}<span class="checked tag">{% trans "Checked" %}</span>{% endif %}
|
||||||
{% if event.is_day_past and not event.cancelled %}
|
{% if event.is_day_past and not event.cancelled %}
|
||||||
{% if event.present_count %}<span class="meta meta-success">{% blocktrans with count=event.present_count %}Presents {{ count }}{% endblocktrans %}</span>{% endif %}
|
{% if event.present_count %}<span class="meta meta-success">{% blocktrans with count=event.present_count %}Presents {{ count }}{% endblocktrans %}</span>{% endif %}
|
||||||
|
|
|
@ -2671,6 +2671,7 @@ class EventCheckMixin:
|
||||||
pk=kwargs.get('event_pk'),
|
pk=kwargs.get('event_pk'),
|
||||||
agenda=self.agenda,
|
agenda=self.agenda,
|
||||||
cancelled=False,
|
cancelled=False,
|
||||||
|
check_locked=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_bookings(self):
|
def get_bookings(self):
|
||||||
|
@ -3495,6 +3496,7 @@ class BookingCheckMixin:
|
||||||
pk=kwargs['booking_pk'],
|
pk=kwargs['booking_pk'],
|
||||||
event__agenda=self.agenda,
|
event__agenda=self.agenda,
|
||||||
event__cancelled=False,
|
event__cancelled=False,
|
||||||
|
event__check_locked=False,
|
||||||
in_waiting_list=False,
|
in_waiting_list=False,
|
||||||
primary_booking__isnull=True,
|
primary_booking__isnull=True,
|
||||||
)
|
)
|
||||||
|
@ -3596,6 +3598,7 @@ class SubscriptionCheckMixin(BookingCheckMixin):
|
||||||
Q(start_datetime__date__lte=now().date()) | Q(agenda__enable_check_for_future_events=True),
|
Q(start_datetime__date__lte=now().date()) | Q(agenda__enable_check_for_future_events=True),
|
||||||
agenda=self.agenda,
|
agenda=self.agenda,
|
||||||
cancelled=False,
|
cancelled=False,
|
||||||
|
check_locked=False,
|
||||||
pk=kwargs['event_pk'],
|
pk=kwargs['event_pk'],
|
||||||
)
|
)
|
||||||
subscription = get_object_or_404(
|
subscription = get_object_or_404(
|
||||||
|
|
|
@ -1716,6 +1716,7 @@ def test_event_checked(app, admin_user):
|
||||||
for url in urls:
|
for url in urls:
|
||||||
resp = app.get(url)
|
resp = app.get(url)
|
||||||
assert '<span class="checked tag">Checked</span>' not in resp
|
assert '<span class="checked tag">Checked</span>' not in resp
|
||||||
|
assert 'check-locked' not in resp
|
||||||
assert '<span class="meta meta-success">Presents 3</span>' in resp
|
assert '<span class="meta meta-success">Presents 3</span>' in resp
|
||||||
assert '<span class="meta meta-error">Absents 4</span>' in resp
|
assert '<span class="meta meta-error">Absents 4</span>' in resp
|
||||||
assert '<span class="meta meta-disabled">Not checked 1</span>' in resp
|
assert '<span class="meta meta-disabled">Not checked 1</span>' in resp
|
||||||
|
@ -1736,6 +1737,7 @@ def test_event_checked(app, admin_user):
|
||||||
for url in urls:
|
for url in urls:
|
||||||
resp = app.get(url)
|
resp = app.get(url)
|
||||||
assert '<span class="checked tag">Checked</span>' in resp
|
assert '<span class="checked tag">Checked</span>' in resp
|
||||||
|
assert 'check-locked' not in resp
|
||||||
assert '<span class="meta meta-success">Presents 4</span>' in resp
|
assert '<span class="meta meta-success">Presents 4</span>' in resp
|
||||||
assert '<span class="meta meta-error">Absents 4</span>' in resp
|
assert '<span class="meta meta-error">Absents 4</span>' in resp
|
||||||
assert 'meta meta-disabled' not in resp
|
assert 'meta meta-disabled' not in resp
|
||||||
|
@ -1761,6 +1763,29 @@ def test_event_checked(app, admin_user):
|
||||||
status=302,
|
status=302,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# event check is locked
|
||||||
|
event.checked = False
|
||||||
|
event.check_locked = True
|
||||||
|
event.save()
|
||||||
|
urls = [
|
||||||
|
'/manage/agendas/%s/events/%s/' % (agenda.pk, event.pk),
|
||||||
|
'/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk),
|
||||||
|
'/manage/agendas/%s/month/%d/%d/%d/'
|
||||||
|
% (agenda.pk, event.start_datetime.year, event.start_datetime.month, event.start_datetime.day),
|
||||||
|
'/manage/agendas/%s/week/%d/%d/%d/'
|
||||||
|
% (agenda.pk, event.start_datetime.year, event.start_datetime.month, event.start_datetime.day),
|
||||||
|
'/manage/agendas/%s/day/%d/%d/%d/'
|
||||||
|
% (agenda.pk, event.start_datetime.year, event.start_datetime.month, event.start_datetime.day),
|
||||||
|
]
|
||||||
|
for url in urls:
|
||||||
|
resp = app.get(url)
|
||||||
|
assert '<span class="check-locked tag">Check locked</span>' in resp
|
||||||
|
app.post(
|
||||||
|
'/manage/agendas/%s/events/%s/checked' % (agenda.pk, event.pk),
|
||||||
|
params={'csrfmiddlewaretoken': token},
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('chrono.manager.forms.get_agenda_check_types')
|
@mock.patch('chrono.manager.forms.get_agenda_check_types')
|
||||||
def test_event_check_filters(check_types, app, admin_user):
|
def test_event_check_filters(check_types, app, admin_user):
|
||||||
|
@ -2416,7 +2441,32 @@ def test_event_check_booking(check_types, app, admin_user):
|
||||||
status=302,
|
status=302,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# event check is locked
|
||||||
|
event.check_locked = True
|
||||||
|
event.save()
|
||||||
|
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
|
||||||
|
assert '/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking.pk) not in resp
|
||||||
|
assert '/manage/agendas/%s/bookings/%s/absence' % (agenda.pk, booking.pk) not in resp
|
||||||
|
assert '/manage/agendas/%s/bookings/%s/reset' % (agenda.pk, booking.pk) not in resp
|
||||||
|
app.post(
|
||||||
|
'/manage/agendas/%s/bookings/%s/absence' % (agenda.pk, booking.pk),
|
||||||
|
params={'csrfmiddlewaretoken': token},
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
app.post(
|
||||||
|
'/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking.pk),
|
||||||
|
params={'csrfmiddlewaretoken': token},
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
app.post(
|
||||||
|
'/manage/agendas/%s/bookings/%s/reset' % (agenda.pk, booking.pk),
|
||||||
|
params={'csrfmiddlewaretoken': token},
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
|
||||||
# now disable check update
|
# now disable check update
|
||||||
|
event.check_locked = False
|
||||||
|
event.save()
|
||||||
agenda.disable_check_update = True
|
agenda.disable_check_update = True
|
||||||
agenda.save()
|
agenda.save()
|
||||||
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
|
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
|
||||||
|
@ -2790,6 +2840,21 @@ def test_event_check_subscription(check_types, app, admin_user):
|
||||||
params={'csrfmiddlewaretoken': token},
|
params={'csrfmiddlewaretoken': token},
|
||||||
status=302,
|
status=302,
|
||||||
)
|
)
|
||||||
|
Booking.objects.all().delete()
|
||||||
|
|
||||||
|
# event check is locked
|
||||||
|
event.check_locked = True
|
||||||
|
event.save()
|
||||||
|
app.post(
|
||||||
|
'/manage/agendas/%s/subscriptions/%s/absence/%s' % (agenda.pk, subscription.pk, event.pk),
|
||||||
|
params={'csrfmiddlewaretoken': token},
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
app.post(
|
||||||
|
'/manage/agendas/%s/subscriptions/%s/presence/%s' % (agenda.pk, subscription.pk, event.pk),
|
||||||
|
params={'csrfmiddlewaretoken': token},
|
||||||
|
status=404,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('chrono.manager.forms.get_agenda_check_types')
|
@mock.patch('chrono.manager.forms.get_agenda_check_types')
|
||||||
|
|
Loading…
Reference in New Issue