Commit 72685618 authored by Skia's avatar Skia

Many right fix on counters

parent 114272df
Pipeline #676 passed with stage
in 3 minutes and 13 seconds
......@@ -161,7 +161,7 @@ class Counter(models.Model):
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
def can_be_viewed_by(self, user):
if self.type == "BAR" or self.type == "EBOUTIC":
if self.type == "BAR":
return True
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user in self.sellers.all()
......
......@@ -90,7 +90,7 @@ class CounterTabsMixin(TabedViewMixin):
})
return tab_list
class CounterMain(CounterTabsMixin, DetailView, ProcessFormView, FormMixin):
class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, FormMixin):
"""
The public (barman) view
"""
......@@ -148,7 +148,7 @@ class CounterMain(CounterTabsMixin, DetailView, ProcessFormView, FormMixin):
def get_success_url(self):
return reverse_lazy('counter:click', args=self.args, kwargs=self.kwargs)
class CounterClick(CounterTabsMixin, DetailView):
class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
"""
The click view
This is a detail view not to have to worry about loading the counter
......
......@@ -15,7 +15,7 @@ from django.db import transaction, DataError
from django.utils.translation import ugettext as _
from django.conf import settings
from counter.models import Product, Customer, Counter, ProductType, Selling
from counter.models import Customer, Counter, ProductType, Selling
from eboutic.models import Basket, Invoice, BasketItem, InvoiceItem
class EbouticMain(TemplateView):
......@@ -37,6 +37,7 @@ class EbouticMain(TemplateView):
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
request.path)
self.object = Counter.objects.filter(type="EBOUTIC").first()
self.make_basket(request)
return super(EbouticMain, self).get(request, *args, **kwargs)
......@@ -44,6 +45,7 @@ class EbouticMain(TemplateView):
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
request.path)
self.object = Counter.objects.filter(type="EBOUTIC").first()
self.make_basket(request)
if 'add_product' in request.POST['action']:
self.add_product(request)
......@@ -55,7 +57,7 @@ class EbouticMain(TemplateView):
def add_product(self, request):
""" Add a product to the basket """
try:
p = Product.objects.filter(id=int(request.POST['product_id'])).first()
p = self.object.products.filter(id=int(request.POST['product_id'])).first()
if not p.buying_groups.exists():
self.basket.add_product(p)
for g in p.buying_groups.all():
......@@ -68,7 +70,7 @@ class EbouticMain(TemplateView):
def del_product(self, request):
""" Delete a product from the basket """
try:
p = Product.objects.filter(id=int(request.POST['product_id'])).first()
p = self.object.products.filter(id=int(request.POST['product_id'])).first()
self.basket.del_product(p)
except:
pass
......@@ -144,7 +146,7 @@ class EbouticPayWithSith(TemplateView):
else:
eboutic = Counter.objects.filter(type="EBOUTIC").first()
for it in b.items.all():
product = Product.objects.filter(id=it.product_id).first()
product = eboutic.products.filter(id=it.product_id).first()
Selling(
label=it.product_name,
counter=eboutic,
......
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