mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 12:59:24 +00:00
general modifications
This commit is contained in:
@ -6,8 +6,6 @@ from django import forms
|
||||
from django.forms.models import modelform_factory
|
||||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
|
||||
|
||||
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, TabedViewMixin
|
||||
from counter.views import CounterAdminTabsMixin
|
||||
from counter.models import Counter
|
||||
@ -19,11 +17,17 @@ class StockMain(CounterAdminTabsMixin, CanCreateMixin, DetailView):
|
||||
"""
|
||||
The stock view for the counter owner
|
||||
"""
|
||||
model = Stock
|
||||
template_name = 'stock/stock_main.jinja'
|
||||
model = StockItem
|
||||
template_name = 'stock/stock_item_list.jinja'
|
||||
pk_url_kwarg = "stock_id"
|
||||
current_tab = "stocks"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(StockItemList, self).get_context_data(**kwargs)
|
||||
if 'stock' in self.request.GET.keys():
|
||||
context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first()
|
||||
return context
|
||||
|
||||
class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -70,13 +74,19 @@ class StockCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
||||
current_tab = "stocks"
|
||||
success_url = reverse_lazy('stock:list')
|
||||
|
||||
|
||||
def get_initial(self):
|
||||
ret = super(StockCreateView, self).get_initial()
|
||||
if 'counter' in self.request.GET.keys():
|
||||
ret['counter'] = self.request.GET['counter']
|
||||
return ret
|
||||
|
||||
class StockItemCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
||||
"""
|
||||
A create view for a new StockItem
|
||||
"""
|
||||
|
||||
model = StockItem
|
||||
form_class = modelform_factory(StockItem, fields=['name', 'unit_quantity', 'effective_quantity', 'stock_owner'])
|
||||
form_class = modelform_factory(StockItem, fields=['name', 'unit_quantity', 'effective_quantity', 'type', 'stock_owner'])
|
||||
template_name = 'core/create.jinja'
|
||||
pk_url_kwarg = "stock_id"
|
||||
current_tab = "stocks"
|
||||
|
Reference in New Issue
Block a user