manager: enable check of future event (#75277)
gitea/chrono/pipeline/head There was a failure building this commit
Details
gitea/chrono/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
0a9e36883c
commit
2b9b2f2607
|
@ -56,8 +56,10 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if event.is_day_past and not event.cancelled %}
|
||||
<a href="{% url 'chrono-manager-event-check' pk=agenda.pk event_pk=event.pk %}">{% trans "Check" %}</a>
|
||||
{% if not event.cancelled %}
|
||||
{% if event.is_day_past or agenda.enable_check_for_future_events %}
|
||||
<a href="{% url 'chrono-manager-event-check' pk=agenda.pk event_pk=event.pk %}">{% trans "Check" %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2541,7 +2541,11 @@ class EventCheckView(ViewableAgendaMixin, DetailView):
|
|||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = Event.annotate_booking_checks(queryset)
|
||||
return queryset.filter(agenda=self.agenda, start_datetime__date__lte=now().date(), cancelled=False)
|
||||
return queryset.filter(
|
||||
Q(start_datetime__date__lte=now().date()) | Q(agenda__enable_check_for_future_events=True),
|
||||
agenda=self.agenda,
|
||||
cancelled=False,
|
||||
)
|
||||
|
||||
def get_filters(self, booked_queryset, subscription_queryset):
|
||||
agenda_filters = self.agenda.get_booking_check_filters()
|
||||
|
@ -2666,16 +2670,15 @@ class EventCheckMixin:
|
|||
self.event = get_object_or_404(
|
||||
Event,
|
||||
Q(checked=False) | Q(agenda__disable_check_update=False),
|
||||
Q(start_datetime__date__lte=now().date()) | Q(agenda__enable_check_for_future_events=True),
|
||||
pk=kwargs.get('event_pk'),
|
||||
agenda=self.agenda,
|
||||
start_datetime__date__lte=now().date(),
|
||||
cancelled=False,
|
||||
)
|
||||
|
||||
def get_bookings(self):
|
||||
return self.event.booking_set.filter(
|
||||
event__agenda=self.agenda,
|
||||
event__start_datetime__date__lte=now().date(),
|
||||
event__cancelled=False,
|
||||
cancellation_datetime__isnull=True,
|
||||
in_waiting_list=False,
|
||||
|
@ -3490,9 +3493,10 @@ class BookingCheckMixin:
|
|||
booking = get_object_or_404(
|
||||
Booking,
|
||||
Q(event__checked=False) | Q(event__agenda__disable_check_update=False),
|
||||
Q(event__start_datetime__date__lte=now().date())
|
||||
| Q(event__agenda__enable_check_for_future_events=True),
|
||||
pk=kwargs['booking_pk'],
|
||||
event__agenda=self.agenda,
|
||||
event__start_datetime__date__lte=now().date(),
|
||||
event__cancelled=False,
|
||||
in_waiting_list=False,
|
||||
primary_booking__isnull=True,
|
||||
|
@ -3592,8 +3596,8 @@ class SubscriptionCheckMixin(BookingCheckMixin):
|
|||
event = get_object_or_404(
|
||||
Event,
|
||||
Q(checked=False) | Q(agenda__disable_check_update=False),
|
||||
Q(start_datetime__date__lte=now().date()) | Q(agenda__enable_check_for_future_events=True),
|
||||
agenda=self.agenda,
|
||||
start_datetime__date__lte=now().date(),
|
||||
cancelled=False,
|
||||
pk=kwargs['event_pk'],
|
||||
)
|
||||
|
|
|
@ -1504,14 +1504,26 @@ def test_event_check(app, admin_user, get_proper_html_str):
|
|||
login(app)
|
||||
|
||||
# event not in past
|
||||
assert agenda.enable_check_for_future_events is False
|
||||
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.pk, event.pk))
|
||||
assert '/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk) not in resp
|
||||
app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk), status=404)
|
||||
|
||||
# not in past, but check for future events is enabled
|
||||
agenda.enable_check_for_future_events = True
|
||||
agenda.save()
|
||||
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.pk, event.pk))
|
||||
assert '/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk) in resp
|
||||
app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk), status=200)
|
||||
|
||||
# event is today
|
||||
agenda.enable_check_for_future_events = False
|
||||
agenda.save()
|
||||
event.start_datetime = localtime(now()).replace(hour=22, minute=0) # it's ok all the day
|
||||
event.save()
|
||||
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.pk, event.pk))
|
||||
assert '/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk) in resp
|
||||
app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk), status=200)
|
||||
|
||||
# unknown agenda
|
||||
app.get('/manage/agendas/%s/events/%s/check' % (0, event.pk), status=404)
|
||||
|
@ -1728,6 +1740,27 @@ def test_event_checked(app, admin_user):
|
|||
assert '<span class="meta meta-error">Absents 4</span>' in resp
|
||||
assert 'meta meta-disabled' not in resp
|
||||
|
||||
# event not in past
|
||||
agenda.disable_check_update = False
|
||||
agenda.save()
|
||||
assert agenda.enable_check_for_future_events is False
|
||||
event.start_datetime = now() + datetime.timedelta(days=1)
|
||||
event.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/events/%s/checked' % (agenda.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=404,
|
||||
)
|
||||
|
||||
# not in past, but check for future events is enabled
|
||||
agenda.enable_check_for_future_events = True
|
||||
agenda.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/events/%s/checked' % (agenda.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
|
||||
|
||||
@mock.patch('chrono.manager.forms.get_agenda_check_types')
|
||||
def test_event_check_filters(check_types, app, admin_user):
|
||||
|
@ -2344,6 +2377,45 @@ def test_event_check_booking(check_types, app, admin_user):
|
|||
status=302,
|
||||
)
|
||||
|
||||
# event not in past
|
||||
assert agenda.enable_check_for_future_events is False
|
||||
event.start_datetime = now() + datetime.timedelta(days=1)
|
||||
event.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/bookings/%s/reset' % (agenda.pk, booking.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=404,
|
||||
)
|
||||
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,
|
||||
)
|
||||
|
||||
# not in past, but check for future events is enabled
|
||||
agenda.enable_check_for_future_events = True
|
||||
agenda.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/bookings/%s/reset' % (agenda.pk, booking.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
app.post(
|
||||
'/manage/agendas/%s/bookings/%s/absence' % (agenda.pk, booking.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
app.post(
|
||||
'/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
|
||||
# now disable check update
|
||||
agenda.disable_check_update = True
|
||||
agenda.save()
|
||||
|
@ -2687,6 +2759,38 @@ def test_event_check_subscription(check_types, app, admin_user):
|
|||
status=404,
|
||||
)
|
||||
|
||||
# event not in past
|
||||
subscription.date_end = now() + datetime.timedelta(days=2)
|
||||
subscription.save()
|
||||
assert agenda.enable_check_for_future_events is False
|
||||
event.start_datetime = now() + datetime.timedelta(days=1)
|
||||
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,
|
||||
)
|
||||
|
||||
# not in past, but check for future events is enabled
|
||||
agenda.enable_check_for_future_events = True
|
||||
agenda.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/subscriptions/%s/absence/%s' % (agenda.pk, subscription.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
Booking.objects.all().delete()
|
||||
app.post(
|
||||
'/manage/agendas/%s/subscriptions/%s/presence/%s' % (agenda.pk, subscription.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
|
||||
|
||||
@mock.patch('chrono.manager.forms.get_agenda_check_types')
|
||||
def test_event_check_subscription_ajax(check_types, app, admin_user):
|
||||
|
@ -2883,6 +2987,37 @@ def test_event_check_all_bookings(check_types, app, admin_user):
|
|||
status=404,
|
||||
)
|
||||
|
||||
# event not in past
|
||||
agenda.disable_check_update = False
|
||||
agenda.save()
|
||||
assert agenda.enable_check_for_future_events is False
|
||||
event.start_datetime = now() + datetime.timedelta(days=1)
|
||||
event.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/events/%s/absence' % (agenda.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=404,
|
||||
)
|
||||
app.post(
|
||||
'/manage/agendas/%s/events/%s/presence' % (agenda.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=404,
|
||||
)
|
||||
|
||||
# not in past, but check for future events is enabled
|
||||
agenda.enable_check_for_future_events = True
|
||||
agenda.save()
|
||||
app.post(
|
||||
'/manage/agendas/%s/events/%s/absence' % (agenda.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
app.post(
|
||||
'/manage/agendas/%s/events/%s/presence' % (agenda.pk, event.pk),
|
||||
params={'csrfmiddlewaretoken': token},
|
||||
status=302,
|
||||
)
|
||||
|
||||
|
||||
def test_event_check_primary_booking(app, admin_user):
|
||||
agenda = Agenda.objects.create(label='Events', kind='events')
|
||||
|
|
Loading…
Reference in New Issue