mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +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.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
from counter.models import Counter, ProductType
|
||||
|
||||
@ -17,6 +19,9 @@ class Stock(models.Model):
|
||||
def get_absolute_url(self):
|
||||
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):
|
||||
"""
|
||||
The StockItem class, element of the stock
|
||||
@ -34,6 +39,9 @@ class StockItem(models.Model):
|
||||
def get_absolute_url(self):
|
||||
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):
|
||||
"""
|
||||
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):
|
||||
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"
|
||||
current_tab = "stocks"
|
||||
|
||||
def can_be_viewed_by(self, user):
|
||||
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||
def get_context_data(self):
|
||||
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):
|
||||
"""
|
||||
@ -35,7 +38,7 @@ class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||
|
||||
def can_be_viewed_by(self, user):
|
||||
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
|
||||
|
||||
|
||||
|
||||
class StockEditForm(forms.ModelForm):
|
||||
"""
|
||||
@ -66,9 +69,6 @@ class StockEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView):
|
||||
if 'stock' in self.request.GET.keys():
|
||||
context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first()
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user