manager: only display events as full when main list is full (#44657)

This commit is contained in:
Frédéric Péters 2020-07-01 20:48:23 +02:00 committed by Thomas NOËL
parent 4dc5481456
commit 7e07387301
3 changed files with 8 additions and 3 deletions

View File

@ -35,6 +35,7 @@ from django.core.validators import MaxValueValidator
from django.db import models, transaction
from django.db.models import Count, Q, Case, When
from django.urls import reverse
from django.utils import functional
from django.utils.dates import WEEKDAYS
from django.utils.encoding import force_text
from django.utils.formats import date_format
@ -776,6 +777,10 @@ class Event(models.Model):
# label can be empty
return slugify(self.label or ('%s-event' % self.agenda.label))
@functional.cached_property
def main_list_full(self):
return bool(self.booked_places >= self.places)
def check_full(self):
self.full = bool(
(self.booked_places >= self.places and self.waiting_list_places == 0)

View File

@ -9,7 +9,7 @@
<ul class="objects-list single-links">
{% for event in object_list %}
<li class="{% if event.booked_places_count > event.places %}overbooking{% endif %}
{% if event.full %}full{% endif %}
{% if event.main_list_full %}full{% endif %}
{% if not event.in_bookable_period %}not-{% endif %}bookable"
{% if event.places %}
data-total="{{event.places}}" data-booked="{{event.booked_places_count}}"
@ -17,7 +17,7 @@
data-total="{{event.waiting_list_places}}" data-booked="{{event.waiting_list_count}}"
{% endif %}
><a href="{% url 'chrono-manager-event-view' pk=agenda.id event_pk=event.id %}">
{% if event.full %}<span class="full tag">{% trans "Full" %}</span>{% endif %}
{% if event.main_list_full %}<span class="full tag">{% trans "Full" %}</span>{% endif %}
{% if event.label %}{{event.label}} / {% endif %}
{{ event.start_datetime }}
(

View File

@ -2449,7 +2449,7 @@ def test_agenda_events_month_view(app, admin_user, manager_user, api_user):
app.get(
'/manage/agendas/%s/%s/%s/' % (agenda.id, event.start_datetime.year, event.start_datetime.month)
)
assert len(ctx.captured_queries) == 5
assert len(ctx.captured_queries) == 6
# current month still doesn't have events
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, today.year, today.month))