mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Many right fix on counters
This commit is contained in:
parent
114272df2f
commit
72685618a6
@ -161,7 +161,7 @@ class Counter(models.Model):
|
|||||||
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
if self.type == "BAR" or self.type == "EBOUTIC":
|
if self.type == "BAR":
|
||||||
return True
|
return True
|
||||||
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user in self.sellers.all()
|
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
|
return tab_list
|
||||||
|
|
||||||
class CounterMain(CounterTabsMixin, DetailView, ProcessFormView, FormMixin):
|
class CounterMain(CounterTabsMixin, CanViewMixin, DetailView, ProcessFormView, FormMixin):
|
||||||
"""
|
"""
|
||||||
The public (barman) view
|
The public (barman) view
|
||||||
"""
|
"""
|
||||||
@ -148,7 +148,7 @@ class CounterMain(CounterTabsMixin, DetailView, ProcessFormView, FormMixin):
|
|||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('counter:click', args=self.args, kwargs=self.kwargs)
|
return reverse_lazy('counter:click', args=self.args, kwargs=self.kwargs)
|
||||||
|
|
||||||
class CounterClick(CounterTabsMixin, DetailView):
|
class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
The click view
|
The click view
|
||||||
This is a detail view not to have to worry about loading the counter
|
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.utils.translation import ugettext as _
|
||||||
from django.conf import settings
|
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
|
from eboutic.models import Basket, Invoice, BasketItem, InvoiceItem
|
||||||
|
|
||||||
class EbouticMain(TemplateView):
|
class EbouticMain(TemplateView):
|
||||||
@ -37,6 +37,7 @@ class EbouticMain(TemplateView):
|
|||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
||||||
request.path)
|
request.path)
|
||||||
|
self.object = Counter.objects.filter(type="EBOUTIC").first()
|
||||||
self.make_basket(request)
|
self.make_basket(request)
|
||||||
return super(EbouticMain, self).get(request, *args, **kwargs)
|
return super(EbouticMain, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ class EbouticMain(TemplateView):
|
|||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
||||||
request.path)
|
request.path)
|
||||||
|
self.object = Counter.objects.filter(type="EBOUTIC").first()
|
||||||
self.make_basket(request)
|
self.make_basket(request)
|
||||||
if 'add_product' in request.POST['action']:
|
if 'add_product' in request.POST['action']:
|
||||||
self.add_product(request)
|
self.add_product(request)
|
||||||
@ -55,7 +57,7 @@ class EbouticMain(TemplateView):
|
|||||||
def add_product(self, request):
|
def add_product(self, request):
|
||||||
""" Add a product to the basket """
|
""" Add a product to the basket """
|
||||||
try:
|
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():
|
if not p.buying_groups.exists():
|
||||||
self.basket.add_product(p)
|
self.basket.add_product(p)
|
||||||
for g in p.buying_groups.all():
|
for g in p.buying_groups.all():
|
||||||
@ -68,7 +70,7 @@ class EbouticMain(TemplateView):
|
|||||||
def del_product(self, request):
|
def del_product(self, request):
|
||||||
""" Delete a product from the basket """
|
""" Delete a product from the basket """
|
||||||
try:
|
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)
|
self.basket.del_product(p)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -144,7 +146,7 @@ class EbouticPayWithSith(TemplateView):
|
|||||||
else:
|
else:
|
||||||
eboutic = Counter.objects.filter(type="EBOUTIC").first()
|
eboutic = Counter.objects.filter(type="EBOUTIC").first()
|
||||||
for it in b.items.all():
|
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(
|
Selling(
|
||||||
label=it.product_name,
|
label=it.product_name,
|
||||||
counter=eboutic,
|
counter=eboutic,
|
||||||
|
Loading…
Reference in New Issue
Block a user