From 4bc4d266c21e86b81469e42c6704b07d3bbe8e77 Mon Sep 17 00:00:00 2001 From: imperosol Date: Wed, 9 Oct 2024 23:30:59 +0200 Subject: [PATCH] Remove the question mark from the counter state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En raison de la manière dont le timeout marche et de l'activité des comptoirs, la notion de "comptoir inactif" n'est pas intuitive. Un comptoir est ouvert ou fermé. Point. --- core/templates/core/base.jinja | 8 +++----- counter/models.py | 15 --------------- counter/templates/counter/activity.jinja | 4 ---- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 7492276b..44a8d7c1 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -70,16 +70,14 @@ {% cache 100 "counters_activity" %} {% for bar in Counter.objects.annotate_has_barman(user).filter(type="BAR") %}
  • - {# If the user is a barman, we redirect him directly to the barman page - else we redirect him to the activity page #} + {# If the user is a barman, we redirect him directly to the barman page + else we redirect him to the activity page #} {% if bar.has_annotated_barman %} {% else %} {% endif %} - {% if bar.is_inactive() %} - - {% elif bar.is_open %} + {% if bar.is_open %} {% else %} diff --git a/counter/models.py b/counter/models.py index f41f6c8c..535e4ed2 100644 --- a/counter/models.py +++ b/counter/models.py @@ -473,21 +473,6 @@ class Counter(models.Model): """Update the barman activity to prevent timeout.""" self.permanencies.filter(end=None).update(activity=timezone.now()) - @property - def is_open(self) -> bool: - return len(self.barmen_list) > 0 - - def is_inactive(self) -> bool: - """Returns True if the counter self is inactive from SITH_COUNTER_MINUTE_INACTIVE's value minutes, else False.""" - return self.is_open and ( - (timezone.now() - self.permanencies.order_by("-activity").first().activity) - > timedelta(minutes=settings.SITH_COUNTER_MINUTE_INACTIVE) - ) - - def barman_list(self) -> list[int]: - """Returns the barman id list.""" - return [b.id for b in self.barmen_list] - def can_refill(self) -> bool: """Show if the counter authorize the refilling with physic money.""" if self.type != "BAR": diff --git a/counter/templates/counter/activity.jinja b/counter/templates/counter/activity.jinja index 3fe1f2e2..29504797 100644 --- a/counter/templates/counter/activity.jinja +++ b/counter/templates/counter/activity.jinja @@ -30,10 +30,6 @@ {% trans %}counter is open, there's at least one barman connected{% endtrans %} -
    - - {% trans minutes=settings.SITH_COUNTER_MINUTE_INACTIVE %}counter is open but not active, the last sale was done at least {{ minutes }} minutes ago {% endtrans %} -
    {% trans %}counter is not open : no one is connected{% endtrans %}