Projet

Général

Profil

0001-manager-only-display-events-as-full-when-main-list-i.patch

Frédéric Péters, 01 juillet 2020 22:01

Télécharger (3,36 ko)

Voir les différences:

Subject: [PATCH] manager: only display events as full when main list is full
 (#44657)

 chrono/agendas/models.py                                     | 5 +++++
 .../templates/chrono/manager_events_agenda_month_view.html   | 4 ++--
 tests/test_manager.py                                        | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)
chrono/agendas/models.py
35 35
from django.db import models, transaction
36 36
from django.db.models import Count, Q, Case, When
37 37
from django.urls import reverse
38
from django.utils import functional
38 39
from django.utils.dates import WEEKDAYS
39 40
from django.utils.encoding import force_text
40 41
from django.utils.formats import date_format
......
776 777
        # label can be empty
777 778
        return slugify(self.label or ('%s-event' % self.agenda.label))
778 779

  
780
    @functional.cached_property
781
    def main_list_full(self):
782
        return bool(self.booked_places >= self.places)
783

  
779 784
    def check_full(self):
780 785
        self.full = bool(
781 786
            (self.booked_places >= self.places and self.waiting_list_places == 0)
chrono/manager/templates/chrono/manager_events_agenda_month_view.html
9 9
  <ul class="objects-list single-links">
10 10
  {% for event in object_list %}
11 11
    <li class="{% if event.booked_places_count > event.places %}overbooking{% endif %}
12
               {% if event.full %}full{% endif %}
12
               {% if event.main_list_full %}full{% endif %}
13 13
               {% if not event.in_bookable_period %}not-{% endif %}bookable"
14 14
        {% if event.places %}
15 15
          data-total="{{event.places}}" data-booked="{{event.booked_places_count}}"
......
17 17
          data-total="{{event.waiting_list_places}}" data-booked="{{event.waiting_list_count}}"
18 18
        {% endif %}
19 19
        ><a href="{% url 'chrono-manager-event-view' pk=agenda.id event_pk=event.id %}">
20
        {% if event.full %}<span class="full tag">{% trans "Full" %}</span>{% endif %}
20
        {% if event.main_list_full %}<span class="full tag">{% trans "Full" %}</span>{% endif %}
21 21
        {% if event.label %}{{event.label}} / {% endif %}
22 22
        {{ event.start_datetime }}
23 23
        (
tests/test_manager.py
2449 2449
        app.get(
2450 2450
            '/manage/agendas/%s/%s/%s/' % (agenda.id, event.start_datetime.year, event.start_datetime.month)
2451 2451
        )
2452
        assert len(ctx.captured_queries) == 5
2452
        assert len(ctx.captured_queries) == 6
2453 2453

  
2454 2454
    # current month still doesn't have events
2455 2455
    resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, today.year, today.month))
2456
-