diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..4a4c2047 --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +# TODO + +## Easter eggs + + * 'A' 'L' 'L' 'O': Entendre le Allooo de Madame Coucoune + * idem avec cacafe + * Un meat spin quelque part + * Konami code + diff --git a/counter/models.py b/counter/models.py index 2417db5f..ce65f018 100644 --- a/counter/models.py +++ b/counter/models.py @@ -127,16 +127,16 @@ class Refilling(models.Model): # TODO: add the bank if the payment is made by cheque def __str__(self): - return "Refilling: %f for %s" % (self.amount, self.customer.user.get_display_name()) + return "Refilling: %.2f for %s" % (self.amount, self.customer.user.get_display_name()) # def get_absolute_url(self): # return reverse('counter:details', kwargs={'counter_id': self.id}) def save(self, *args, **kwargs): self.full_clean() - self.customer.amount += self.quantity * self.unit_price + self.customer.amount += self.amount self.customer.save() - super(Selling, self).save(*args, **kwargs) + super(Refilling, self).save(*args, **kwargs) class Selling(models.Model): """ diff --git a/counter/templates/counter/counter_click.jinja b/counter/templates/counter/counter_click.jinja index 4d412294..8fdb0b47 100644 --- a/counter/templates/counter/counter_click.jinja +++ b/counter/templates/counter/counter_click.jinja @@ -22,7 +22,20 @@
Club: {{ counter.club }}
Customer: {{ customer.user.get_display_name() }}, {{ customer.amount }} €
+{{ customer.user.get_display_name() }}, {{ customer.amount }} €
+Not enough money
{% endif %} diff --git a/counter/views.py b/counter/views.py index 6e4d0c73..e3b28c2b 100644 --- a/counter/views.py +++ b/counter/views.py @@ -64,6 +64,7 @@ class CounterMain(DetailView, ProcessFormView, FormMixin): kwargs = super(CounterMain, self).get_context_data(**kwargs) # TODO: make some checks on the counter type, in order not to make the AuthenticationForm if there is no need to kwargs['login_form'] = AuthenticationForm() + kwargs['login_form'].fields['username'].widget.attrs['autofocus'] = True kwargs['form'] = self.get_form() kwargs['barmen'] = Counter.get_barmen_list(self.object.id) if 'last_basket' in self.request.session.keys(): @@ -120,6 +121,8 @@ class CounterClick(DetailView): self.add_product(request) elif 'del_product' in request.POST['action']: self.del_product(request) + elif 'refill' in request.POST['action']: + self.refill(request) elif 'code' in request.POST['action']: return self.parse_code(request) elif 'cancel' in request.POST['action']: @@ -233,6 +236,17 @@ class CounterClick(DetailView): request.session.pop('basket', None) return HttpResponseRedirect(reverse_lazy('counter:details', args=self.args, kwargs=kwargs)) + def refill(self, request): + """Refill the customer's account""" + if self.is_barman_price(): + operator = self.customer.user + else: + operator = Counter.get_random_barman(self.object.id) + amount = float(request.POST['amount']) + s = Refilling(counter=self.object, operator=operator, customer=self.customer, + amount=amount, payment_method="cash") + s.save() + def get_context_data(self, **kwargs): """ Add customer to the context """ kwargs = super(CounterClick, self).get_context_data(**kwargs)