Many right fix on counters

This commit is contained in:
Skia 2017-01-04 19:39:37 +01:00
parent 114272df2f
commit 72685618a6
3 changed files with 9 additions and 7 deletions

View File

@ -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()

View File

@ -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

View File

@ -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,