Commit df20bf6d authored by Skia's avatar Skia

Reindent stock app

parent 20deda8a
......@@ -7,80 +7,80 @@ from django.conf import settings
from counter.models import Counter, ProductType
class Stock(models.Model):
"""
The Stock class, this one is used to know how many products are left for a specific counter
"""
name = models.CharField(_('name'), max_length=64)
counter = models.OneToOneField(Counter, verbose_name=_('counter'), related_name='stock')
"""
The Stock class, this one is used to know how many products are left for a specific counter
"""
name = models.CharField(_('name'), max_length=64)
counter = models.OneToOneField(Counter, verbose_name=_('counter'), related_name='stock')
def __str__(self):
return "%s (%s)" % (self.name, self.counter)
def __str__(self):
return "%s (%s)" % (self.name, self.counter)
def get_absolute_url(self):
return reverse('stock:list')
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)
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
"""
name = models.CharField(_('name'), max_length=64)
unit_quantity = models.IntegerField(_('unit quantity'), default=0, help_text=_('number of element in one box'))
effective_quantity = models.IntegerField(_('effective quantity'), default=0, help_text=_('number of box'))
minimal_quantity = models.IntegerField(_('minimal quantity'), default=1,
help_text=_('if the effective quantity is less than the minimal, item is added to the shopping list'))
type = models.ForeignKey(ProductType, related_name="stock_items", verbose_name=_("type"), null=True, blank=True,
on_delete=models.SET_NULL)
stock_owner = models.ForeignKey(Stock, related_name="items")
def __str__(self):
return "%s" % (self.name)
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)
"""
The StockItem class, element of the stock
"""
name = models.CharField(_('name'), max_length=64)
unit_quantity = models.IntegerField(_('unit quantity'), default=0, help_text=_('number of element in one box'))
effective_quantity = models.IntegerField(_('effective quantity'), default=0, help_text=_('number of box'))
minimal_quantity = models.IntegerField(_('minimal quantity'), default=1,
help_text=_('if the effective quantity is less than the minimal, item is added to the shopping list'))
type = models.ForeignKey(ProductType, related_name="stock_items", verbose_name=_("type"), null=True, blank=True,
on_delete=models.SET_NULL)
stock_owner = models.ForeignKey(Stock, related_name="items")
def __str__(self):
return "%s" % (self.name)
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
"""
date = models.DateTimeField(_('date'))
name = models.CharField(_('name'), max_length=64)
todo = models.BooleanField(_('todo'))
comment = models.TextField(_('comment'), null=True, blank=True)
stock_owner = models.ForeignKey(Stock, null=True, related_name="shopping_lists")
"""
The ShoppingList class, used to make an history of the shopping lists
"""
date = models.DateTimeField(_('date'))
name = models.CharField(_('name'), max_length=64)
todo = models.BooleanField(_('todo'))
comment = models.TextField(_('comment'), null=True, blank=True)
stock_owner = models.ForeignKey(Stock, null=True, related_name="shopping_lists")
def __str__(self):
return "%s (%s)" % (self.name, self.date)
def __str__(self):
return "%s (%s)" % (self.name, self.date)
def get_absolute_url(self):
return reverse('stock:shoppinglist_list')
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)
def can_be_viewed_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
class ShoppingListItem(models.Model):
"""
"""
shopping_lists = models.ManyToManyField(ShoppingList, verbose_name=_("shopping lists"), related_name="shopping_items_to_buy")
stockitem_owner = models.ForeignKey(StockItem, related_name="shopping_item", null=True)
name = models.CharField(_('name'), max_length=64)
type = models.ForeignKey(ProductType, related_name="shoppinglist_items", verbose_name=_("type"), null=True, blank=True,
on_delete=models.SET_NULL)
tobuy_quantity = models.IntegerField(_('quantity to buy'), default=6, help_text=_("quantity to buy during the next shopping session"))
bought_quantity = models.IntegerField(_('quantity bought'), default=0, help_text=_("quantity bought during the last shopping session"))
def __str__(self):
return "%s - %s" % (self.name, self.shopping_lists.first())
def can_be_viewed_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
def get_absolute_url(self):
return reverse('stock:shoppinglist_list')
"""
"""
shopping_lists = models.ManyToManyField(ShoppingList, verbose_name=_("shopping lists"), related_name="shopping_items_to_buy")
stockitem_owner = models.ForeignKey(StockItem, related_name="shopping_item", null=True)
name = models.CharField(_('name'), max_length=64)
type = models.ForeignKey(ProductType, related_name="shoppinglist_items", verbose_name=_("type"), null=True, blank=True,
on_delete=models.SET_NULL)
tobuy_quantity = models.IntegerField(_('quantity to buy'), default=6, help_text=_("quantity to buy during the next shopping session"))
bought_quantity = models.IntegerField(_('quantity bought'), default=0, help_text=_("quantity bought during the last shopping session"))
def __str__(self):
return "%s - %s" % (self.name, self.shopping_lists.first())
def can_be_viewed_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID)
def get_absolute_url(self):
return reverse('stock:shoppinglist_list')
......@@ -3,28 +3,28 @@ from django.conf.urls import include, url
from stock.views import *
urlpatterns = [
#Stock urls
url(r'^new/counter/(?P<counter_id>[0-9]+)$', StockCreateView.as_view(), name='new'),
url(r'^edit/(?P<stock_id>[0-9]+)$', StockEditView.as_view(), name='edit'),
url(r'^list$', StockListView.as_view(), name='list'),
#Stock urls
url(r'^new/counter/(?P<counter_id>[0-9]+)$', StockCreateView.as_view(), name='new'),
url(r'^edit/(?P<stock_id>[0-9]+)$', StockEditView.as_view(), name='edit'),
url(r'^list$', StockListView.as_view(), name='list'),
# StockItem urls
url(r'^(?P<stock_id>[0-9]+)$', StockItemList.as_view(), name='items_list'),
url(r'^(?P<stock_id>[0-9]+)/stockItem/newItem$', StockItemCreateView.as_view(), name='new_item'),
url(r'^stockItem/(?P<item_id>[0-9]+)/edit$', StockItemEditView.as_view(), name='edit_item'),
url(r'^(?P<stock_id>[0-9]+)/stockItem/takeItems$', StockTakeItemsBaseFormView.as_view(), name='take_items'),
# StockItem urls
url(r'^(?P<stock_id>[0-9]+)$', StockItemList.as_view(), name='items_list'),
url(r'^(?P<stock_id>[0-9]+)/stockItem/newItem$', StockItemCreateView.as_view(), name='new_item'),
url(r'^stockItem/(?P<item_id>[0-9]+)/edit$', StockItemEditView.as_view(), name='edit_item'),
url(r'^(?P<stock_id>[0-9]+)/stockItem/takeItems$', StockTakeItemsBaseFormView.as_view(), name='take_items'),
# ShoppingList urls
url(r'^(?P<stock_id>[0-9]+)/shoppingList/list$', StockShoppingListView.as_view(), name='shoppinglist_list'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/create$', StockItemQuantityBaseFormView.as_view(), name='shoppinglist_create'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/items$', StockShoppingListItemListView.as_view(),
name='shoppinglist_items'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/delete$', StockShoppingListDeleteView.as_view(),
name='shoppinglist_delete'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/setDone$', StockShopppingListSetDone.as_view(),
name='shoppinglist_set_done'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/setTodo$', StockShopppingListSetTodo.as_view(),
name='shoppinglist_set_todo'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/updateStock$', StockUpdateAfterShopppingBaseFormView.as_view(),
name='update_after_shopping'),
]
# ShoppingList urls
url(r'^(?P<stock_id>[0-9]+)/shoppingList/list$', StockShoppingListView.as_view(), name='shoppinglist_list'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/create$', StockItemQuantityBaseFormView.as_view(), name='shoppinglist_create'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/items$', StockShoppingListItemListView.as_view(),
name='shoppinglist_items'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/delete$', StockShoppingListDeleteView.as_view(),
name='shoppinglist_delete'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/setDone$', StockShopppingListSetDone.as_view(),
name='shoppinglist_set_done'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/setTodo$', StockShopppingListSetTodo.as_view(),
name='shoppinglist_set_todo'),
url(r'^(?P<stock_id>[0-9]+)/shoppingList/(?P<shoppinglist_id>[0-9]+)/updateStock$', StockUpdateAfterShopppingBaseFormView.as_view(),
name='update_after_shopping'),
]
This diff is collapsed.
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