mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Finish back up app Stock
This commit is contained in:
parent
fa97929da8
commit
62200827c2
@ -1,6 +1,8 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
from counter.models import Counter, ProductType
|
from counter.models import Counter, ProductType
|
||||||
|
|
||||||
@ -17,6 +19,9 @@ class Stock(models.Model):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('stock:list')
|
return reverse('stock:list')
|
||||||
|
|
||||||
|
def can_be_viewed_by(self, user):
|
||||||
|
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||||
|
|
||||||
class StockItem(models.Model):
|
class StockItem(models.Model):
|
||||||
"""
|
"""
|
||||||
The StockItem class, element of the stock
|
The StockItem class, element of the stock
|
||||||
@ -34,6 +39,9 @@ class StockItem(models.Model):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('stock:items_list', kwargs={'stock_id':self.stock_owner.id})
|
return reverse('stock:items_list', kwargs={'stock_id':self.stock_owner.id})
|
||||||
|
|
||||||
|
def can_be_viewed_by(self, user):
|
||||||
|
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||||
|
|
||||||
class ShoppingList(models.Model):
|
class ShoppingList(models.Model):
|
||||||
"""
|
"""
|
||||||
The ShoppingList class, used to make an history of the shopping lists
|
The ShoppingList class, used to make an history of the shopping lists
|
||||||
@ -49,3 +57,6 @@ class ShoppingList(models.Model):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('stock:shoppinglist_list')
|
return reverse('stock:shoppinglist_list')
|
||||||
|
|
||||||
|
def can_be_viewed_by(self, user):
|
||||||
|
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||||
|
@ -22,8 +22,11 @@ class StockItemList(CounterAdminTabsMixin, CanCreateMixin, ListView):
|
|||||||
pk_url_kwarg = "stock_id"
|
pk_url_kwarg = "stock_id"
|
||||||
current_tab = "stocks"
|
current_tab = "stocks"
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def get_context_data(self):
|
||||||
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
ret = super(StockItemList, self).get_context_data()
|
||||||
|
if 'stock_id' in self.kwargs.keys():
|
||||||
|
ret['stock'] = Stock.objects.filter(id=self.kwargs['stock_id']).first();
|
||||||
|
return ret
|
||||||
|
|
||||||
class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||||
"""
|
"""
|
||||||
@ -67,9 +70,6 @@ class StockEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first()
|
context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
|
||||||
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
|
||||||
|
|
||||||
|
|
||||||
class StockItemEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
class StockItemEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user