Commit 62200827 authored by Lo-J's avatar Lo-J

Finish back up app Stock

parent fa97929d
Pipeline #682 failed with stage
in 2 minutes and 17 seconds
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):
......
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