diff --git a/counter/models.py b/counter/models.py index 564d6a3b..af83d492 100644 --- a/counter/models.py +++ b/counter/models.py @@ -451,11 +451,11 @@ class Counter(models.Model): Show if the counter authorize the refilling with physic money """ - if ( - self.id in SITH_COUNTER_OFFICES - ): # If the counter is the counters 'AE' or 'BdF', the refiling are authorized + if self.type != "BAR": + return False + if self.id in SITH_COUNTER_OFFICES: + # If the counter is either 'AE' or 'BdF', refills are authorized return True - is_ae_member = False ae = Club.objects.get(unix_name=SITH_MAIN_CLUB["unix_name"]) for barman in self.get_barmen_list(): diff --git a/counter/static/counter/js/counter_click.js b/counter/static/counter/js/counter_click.js index e7e05a83..46f22e93 100644 --- a/counter/static/counter/js/counter_click.js +++ b/counter/static/counter/js/counter_click.js @@ -12,6 +12,15 @@ document.addEventListener('alpine:init', () => { return total / 100; }, + async handle_code(event) { + const code = $(event.target).find("#code_field").val().toUpperCase(); + if(["FIN", "ANN"].includes(code)) { + $(event.target).submit(); + } else { + await this.handle_action(event); + } + }, + async handle_action(event) { const payload = $(event.target).serialize(); let request = new Request(click_api_url, { diff --git a/counter/templates/counter/counter_click.jinja b/counter/templates/counter/counter_click.jinja index 8abe2b10..1a44c7f3 100644 --- a/counter/templates/counter/counter_click.jinja +++ b/counter/templates/counter/counter_click.jinja @@ -56,14 +56,17 @@
{% trans %}Selling{% endtrans %}
{% set counter_click_url = url('counter:click', counter_id=counter.id, user_id=customer.user.id) %} + + {# Formulaire pour rechercher un produit en tapant son code dans une barre de recherche #}
+ class="code_form" @submit.prevent="handle_code"> {% csrf_token %}
+