Commit 0ecb78a1 authored by Skia's avatar Skia

Fix some counter stuff

parent 256651f5
Pipeline #66 failed with stage
in 1 minute and 12 seconds
......@@ -95,6 +95,8 @@ class Counter(models.Model):
return self.name
def get_absolute_url(self):
if self.type == "EBOUTIC":
return reverse('eboutic:main')
return reverse('counter:details', kwargs={'counter_id': self.id})
def can_be_edited_by(self, user):
......
......@@ -10,8 +10,13 @@
<h3>{% trans %}Counter admin list{% endtrans %}</h3>
<ul>
{% for c in counter_list %}
{% if c.type == "EBOUTIC" %}
<li><a href="{{ url('eboutic:main') }}">{{ c }}</a> -
<a href="{{ url('counter:admin', counter_id=c.id) }}">{% trans %}Edit{% endtrans %}</a></li>
{% else %}
<li><a href="{{ url('counter:details', counter_id=c.id) }}">{{ c }}</a> -
<a href="{{ url('counter:admin', counter_id=c.id) }}">{% trans %}Edit{% endtrans %}</a></li>
{% endif %}
{% endfor %}
</ul>
{% else %}
......
......@@ -9,11 +9,7 @@
{% endmacro %}
{% block content %}
<h3>{% trans %}Counter{% endtrans %}</h3>
<h4>{{ counter }}</h4>
<p><strong>{% trans %}Club: {% endtrans %}</strong> {{ counter.club }}</p>
<p><strong>{% trans %}Products: {% endtrans %}</strong> {{ counter.products.all() }}</p>
<h3>{% trans counter_name=counter %}{{ counter_name }} counter{% endtrans %}</h3>
<div>
<h3>{% trans %}Sellings{% endtrans %}</h3>
......
......@@ -124,12 +124,20 @@ class CounterClick(DetailView):
self.object = self.get_object()
self.customer = Customer.objects.filter(user__id=self.kwargs['user_id']).first()
self.refill_form = None
if len(Counter.get_barmen_list(self.object.id)) < 1: # Check that at least one barman is logged in
if ((self.object.type != "BAR" and not request.user.is_authenticated()) or
(self.object.type == "BAR" and
len(Counter.get_barmen_list(self.object.id)) < 1)): # Check that at least one barman is logged in
return self.cancel(request)
if 'basket' not in request.session.keys():
request.session['basket'] = {}
request.session['basket_total'] = 0
request.session['not_enough'] = False
if self.object.type != "BAR":
self.operator = request.user
elif self.is_barman_price():
self.operator = self.customer.user
else:
self.operator = Counter.get_random_barman(self.object.id)
if 'add_product' in request.POST['action']:
self.add_product(request)
......@@ -147,7 +155,7 @@ class CounterClick(DetailView):
return self.render_to_response(context)
def is_barman_price(self):
if self.customer.user.id in [s.id for s in Counter.get_barmen_list(self.object.id)]:
if self.object.type == "BAR" and self.customer.user.id in [s.id for s in Counter.get_barmen_list(self.object.id)]:
return True
else:
return False
......@@ -210,7 +218,7 @@ class CounterClick(DetailView):
nb = 1
else:
nb = int(nb)
p = Product.objects.filter(code=code).first()
p = self.object.products.filter(code=code).first()
if p is not None:
while nb > 0 and not self.add_product(request, nb, p.id):
nb -= 1
......@@ -220,10 +228,6 @@ class CounterClick(DetailView):
def finish(self, request):
""" Finish the click session, and validate the basket """
with transaction.atomic():
if self.is_barman_price():
seller = self.customer.user
else:
seller = Counter.get_random_barman(self.object.id)
request.session['last_basket'] = []
for pid,infos in request.session['basket'].items():
# This duplicates code for DB optimization (prevent to load many times the same object)
......@@ -236,7 +240,7 @@ class CounterClick(DetailView):
raise DataError(_("You have not enough money to buy all the basket"))
request.session['last_basket'].append("%d x %s" % (infos['qty'], p.name))
s = Selling(product=p, counter=self.object, unit_price=uprice,
quantity=infos['qty'], seller=seller, customer=self.customer)
quantity=infos['qty'], seller=self.operator, customer=self.customer)
s.save()
request.session['last_customer'] = self.customer.user.get_display_name()
request.session['last_total'] = "%0.2f" % self.sum_basket(request)
......@@ -256,14 +260,10 @@ class CounterClick(DetailView):
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)
form = RefillForm(request.POST)
if form.is_valid():
form.instance.counter = self.object
form.instance.operator = operator
form.instance.operator = self.operator
form.instance.customer = self.customer
form.instance.save()
else:
......
......@@ -5,10 +5,6 @@ from accounting.models import CurrencyField
from counter.models import Counter, Product
from core.models import User
class Eboutic(Counter):
class Meta:
proxy = True
class Basket(models.Model):
"""
Basket is built when the user validate its session basket and asks for payment
......
from django.shortcuts import render
from django.core.urlresolvers import reverse_lazy
from eboutic.models import Eboutic
from django.views.generic import TemplateView, View
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.db import transaction, DataError
from django.utils.translation import ugettext as _
from counter.models import Product, Customer
from eboutic.models import Basket, Invoice, Eboutic, BasketItem, InvoiceItem
from counter.models import Product, Customer, Counter
from eboutic.models import Basket, Invoice, BasketItem, InvoiceItem
# Create your views here.
class EbouticMain(TemplateView):
......@@ -69,7 +68,7 @@ class EbouticMain(TemplateView):
def get_context_data(self, **kwargs):
kwargs = super(EbouticMain, self).get_context_data(**kwargs)
kwargs['basket_total'] = EbouticMain.sum_basket(self.request)
kwargs['eboutic'] = Eboutic.objects.filter(type="EBOUTIC").first()
kwargs['eboutic'] = Counter.objects.filter(type="EBOUTIC").first()
return kwargs
class EbouticCommand(TemplateView):
......
......@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-22 01:47+0200\n"
"POT-Creation-Date: 2016-07-22 13:32+0200\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
......@@ -30,11 +30,11 @@ msgstr "IBAN"
msgid "account number"
msgstr "numero de compte"
#: accounting/models.py:92 club/models.py:109 counter/models.py:214
#: accounting/models.py:92 club/models.py:109 counter/models.py:216
msgid "start date"
msgstr "date de début"
#: accounting/models.py:93 club/models.py:110 counter/models.py:215
#: accounting/models.py:93 club/models.py:110 counter/models.py:217
msgid "end date"
msgstr "date de fin"
......@@ -43,7 +43,7 @@ msgid "is closed"
msgstr "est fermé"
#: accounting/models.py:97 accounting/models.py:136 counter/models.py:21
#: counter/models.py:162
#: counter/models.py:164
msgid "amount"
msgstr "montant"
......@@ -55,8 +55,8 @@ msgstr "montant effectif"
msgid "number"
msgstr "numéro"
#: accounting/models.py:137 core/models.py:462 counter/models.py:165
#: counter/models.py:193 eboutic/models.py:17 eboutic/models.py:30
#: accounting/models.py:137 core/models.py:462 counter/models.py:167
#: counter/models.py:195 eboutic/models.py:13 eboutic/models.py:26
msgid "date"
msgstr "date"
......@@ -68,7 +68,7 @@ msgstr "intitulé"
msgid "remark"
msgstr "remarque"
#: accounting/models.py:140 counter/models.py:166 eboutic/models.py:32
#: accounting/models.py:140 counter/models.py:168 eboutic/models.py:28
#: subscription/models.py:34
msgid "payment method"
msgstr "méthode de paiement"
......@@ -144,10 +144,11 @@ msgstr "Nouveau compte club"
#: accounting/templates/accounting/bank_account_list.jinja:15
#: accounting/templates/accounting/club_account_details.jinja:44
#: accounting/templates/accounting/journal_details.jinja:51
#: club/templates/club/club_detail.jinja:7 core/templates/core/page.jinja:30
#: club/templates/club/club_detail.jinja:7 core/templates/core/page.jinja:31
#: core/templates/core/user_base.jinja:8
#: core/templates/core/user_tools.jinja:30
#: counter/templates/counter/counter_list.jinja:14
#: counter/templates/counter/counter_list.jinja:15
#: counter/templates/counter/counter_list.jinja:18
msgid "Edit"
msgstr "Éditer"
......@@ -227,7 +228,7 @@ msgid "No"
msgstr "Non"
#: accounting/templates/accounting/club_account_details.jinja:43
#: core/templates/core/page.jinja:27
#: core/templates/core/page.jinja:28
msgid "View"
msgstr "Voir"
......@@ -304,7 +305,7 @@ msgstr "Adresse"
msgid "You can not make loops in clubs"
msgstr "Vous ne pouvez pas faire de boucles dans les clubs"
#: club/models.py:107 eboutic/models.py:16 eboutic/models.py:29
#: club/models.py:107 eboutic/models.py:12 eboutic/models.py:25
msgid "user"
msgstr "nom d'utilisateur"
......@@ -342,7 +343,7 @@ msgstr "Club"
msgid "Back to list"
msgstr "Retour à la liste"
#: club/templates/club/club_detail.jinja:10 core/templates/core/page.jinja:33
#: club/templates/club/club_detail.jinja:10 core/templates/core/page.jinja:34
msgid "Prop"
msgstr "Propriétés"
......@@ -545,14 +546,18 @@ msgid "Users"
msgstr "Utilisateurs"
#: core/templates/core/base.jinja:30
msgid "Wiki"
msgstr ""
#: core/templates/core/base.jinja:31
msgid "Pages"
msgstr "Pages"
#: core/templates/core/base.jinja:31
#: core/templates/core/base.jinja:32
msgid "Clubs"
msgstr "Clubs"
#: core/templates/core/base.jinja:44
#: core/templates/core/base.jinja:45
msgid "Site made by good people"
msgstr "Site réalisé par des gens biens"
......@@ -624,7 +629,7 @@ msgid "Please login to see this page."
msgstr "Merci de vous identifier pour voir cette page."
#: core/templates/core/login.jinja:31
#: counter/templates/counter/counter_main.jinja:52
#: counter/templates/counter/counter_main.jinja:48
msgid "login"
msgstr "login"
......@@ -645,15 +650,15 @@ msgstr "Créer une page"
msgid "Not found"
msgstr "Non trouvé"
#: core/templates/core/page.jinja:28
#: core/templates/core/page.jinja:29
msgid "History"
msgstr "Historique"
#: core/templates/core/page.jinja:43
#: core/templates/core/page.jinja:45
msgid "Page does not exist"
msgstr "La page n'existe pas."
#: core/templates/core/page.jinja:45
#: core/templates/core/page.jinja:47
msgid "Create it?"
msgstr "La créer ?"
......@@ -669,6 +674,7 @@ msgid "Page history"
msgstr "Historique de la page"
#: core/templates/core/page_hist.jinja:5
#, python-format
msgid "You're seeing the history of page \"%(page_name)s\""
msgstr "Vous consultez l'historique de la page \"%(page_name)s\""
......@@ -911,25 +917,23 @@ msgstr "Bureau"
msgid "Eboutic"
msgstr "Eboutic"
#: counter/models.py:168
#: counter/models.py:170
msgid "bank"
msgstr "banque"
#: counter/models.py:189 eboutic/models.py:55
#: counter/models.py:191 eboutic/models.py:51
msgid "unit price"
msgstr "prix unitaire"
#: counter/models.py:190 eboutic/models.py:56
#: counter/models.py:192 eboutic/models.py:52
msgid "quantity"
msgstr "quantité"
#: counter/templates/counter/counter_click.jinja:20
#: counter/templates/counter/counter_main.jinja:12
msgid "Counter"
msgstr "Comptoir"
#: counter/templates/counter/counter_click.jinja:22
#: counter/templates/counter/counter_main.jinja:14
msgid "Club: "
msgstr "Club : "
......@@ -961,7 +965,7 @@ msgid "Basket: "
msgstr "Panier : "
#: counter/templates/counter/counter_click.jinja:58
#: counter/templates/counter/counter_main.jinja:28
#: counter/templates/counter/counter_main.jinja:24
#: eboutic/templates/eboutic/eboutic_main.jinja:31
msgid "Total: "
msgstr "Total : "
......@@ -971,7 +975,6 @@ msgid "Finish"
msgstr "Terminer"
#: counter/templates/counter/counter_click.jinja:69
#: counter/templates/counter/counter_main.jinja:15
#: eboutic/templates/eboutic/eboutic_main.jinja:39
msgid "Products: "
msgstr "Produits : "
......@@ -989,39 +992,43 @@ msgstr "Liste des comptoirs"
msgid "New counter"
msgstr "Nouveau comptoir"
#: counter/templates/counter/counter_list.jinja:18
#: counter/templates/counter/counter_list.jinja:23
msgid "There is no counters in this website."
msgstr "Il n'y a pas de comptoirs dans ce site web."
#: counter/templates/counter/counter_main.jinja:19
#: counter/templates/counter/counter_main.jinja:12
msgid "%(counter_name)s counter"
msgstr "Comptoir %(counter_name)s"
#: counter/templates/counter/counter_main.jinja:15
msgid "Sellings"
msgstr "Ventes"
#: counter/templates/counter/counter_main.jinja:21
#: counter/templates/counter/counter_main.jinja:17
msgid "Last selling: "
msgstr "Dernière vente : "
#: counter/templates/counter/counter_main.jinja:22
#: counter/templates/counter/counter_main.jinja:18
msgid "Client: "
msgstr "Client : "
#: counter/templates/counter/counter_main.jinja:22
#: counter/templates/counter/counter_main.jinja:18
msgid "New amount: "
msgstr "Nouveau montant : "
#: counter/templates/counter/counter_main.jinja:31
#: counter/templates/counter/counter_main.jinja:27
msgid "Enter client code:"
msgstr "Entrez un code client : "
#: counter/templates/counter/counter_main.jinja:35
#: counter/templates/counter/counter_main.jinja:31
msgid "validate"
msgstr "valider"
#: counter/templates/counter/counter_main.jinja:38
#: counter/templates/counter/counter_main.jinja:34
msgid "Please, login"
msgstr "Merci de vous identifier"
#: counter/templates/counter/counter_main.jinja:43
#: counter/templates/counter/counter_main.jinja:39
msgid "Barman: "
msgstr "Barman : "
......@@ -1034,43 +1041,43 @@ msgstr "Compte de %(user_name)s"
msgid "User account"
msgstr "Compte utilisateur"
#: counter/views.py:200
#: counter/views.py:208
msgid "END"
msgstr "FIN"
#: counter/views.py:202
#: counter/views.py:210
msgid "CAN"
msgstr "ANN"
#: counter/views.py:236
#: counter/views.py:240
msgid "You have not enough money to buy all the basket"
msgstr "Vous n'avez pas assez d'argent pour acheter le panier"
#: eboutic/models.py:31 sith/settings.py:231 sith/settings_sample.py:231
#: eboutic/models.py:27 sith/settings.py:231 sith/settings_sample.py:231
msgid "Credit card"
msgstr "Carte banquaire"
#: eboutic/models.py:31
#: eboutic/models.py:27
msgid "Sith account"
msgstr "Compte utilisateur"
#: eboutic/models.py:33
#: eboutic/models.py:29
msgid "validated"
msgstr "validé"
#: eboutic/models.py:44
#: eboutic/models.py:40
msgid "Invoice already validated"
msgstr "Facture déjà validée"
#: eboutic/models.py:54
#: eboutic/models.py:50
msgid "product name"
msgstr "nom du produit"
#: eboutic/models.py:65
#: eboutic/models.py:61
msgid "basket"
msgstr "panier"
#: eboutic/models.py:68
#: eboutic/models.py:64
msgid "invoice"
msgstr "facture"
......@@ -1094,7 +1101,7 @@ msgstr "Le paiement a échoué"
msgid "Payment successful"
msgstr "Le paiement a été effectué"
#: eboutic/views.py:117
#: eboutic/views.py:116
msgid "You have not enough money to buy the basket"
msgstr "Vous n'avez pas assez d'argent pour acheter le panier"
......@@ -1203,6 +1210,9 @@ msgid "You must either choose an existing user or create a new one properly"
msgstr ""
"Vous devez soit choisir un utilisateur existant, ou en créer un proprement."
#~ msgid "%(c)s counter"
#~ msgstr "Comptoir %(c)s"
#~ msgid "Page"
#~ msgstr "Page"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment