From 75af525945f547c6c6251c560cc38932edc30a9c Mon Sep 17 00:00:00 2001 From: guillaume-renaud Date: Wed, 26 Oct 2016 22:12:56 +0200 Subject: [PATCH] Addition of the StockItem class addition of Stock app, model, templates, urls Addition of the stock parameter to the counter admin list Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Stock application creation Addition of the StockItem class addition of Stock app, model, templates, urls Addition of the stock parameter to the counter admin list Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Initial StockItem create form value addition general modifications Stock admin gestion, items list views, create and edit items remove stock_main.jinja Stock application creation Addition of the StockItem class addition of Stock app, model, templates, urls Addition of the stock parameter to the counter admin list Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Addition of the StockItem class addition of Stock app, model, templates, urls Addition of the stock parameter to the counter admin list Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Initial StockItem create form value addition general modifications Stock admin gestion, items list views, create and edit items Shopping list structure view addition correct missing endif a correct missing endif Stock application creation addition of Stock app, model, templates, urls Addition of the stock parameter to the counter admin list Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Stock application creation addition of Stock app, model, templates, urls Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Initial StockItem create form value addition general modifications Stock admin gestion, items list views, create and edit items remove stock_main.jinja Stock application creation addition of Stock app, model, templates, urls Addition of the stock parameter to the counter admin list Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Fix translation files Creation of the Stock list, edit, create views and creation StockItem create view Initial StockItem create form value addition general modifications Shopping list structure view addition correct missing endif --- stock/views.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/stock/views.py b/stock/views.py index 0f8af903..614d9752 100644 --- a/stock/views.py +++ b/stock/views.py @@ -46,6 +46,45 @@ class StockEditForm(forms.ModelForm): return super(StockEditForm, self).save(*args, **kwargs) +class StockEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView): + """ + An edit view for the stock + """ + model = Stock + form_class = StockEditForm + 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 + """ + model = Stock + template_name = 'stock/stock_list.jinja' + current_tab = "stocks" + + +class StockEditForm(forms.ModelForm): + """ + A form to change stock's characteristics + """ + class Meta: + model = Stock + fields = ['name', 'counter'] + + def __init__(self, *args, **kwargs): + super(StockEditForm, self).__init__(*args, **kwargs) + + def save(self, *args, **kwargs): + return super(StockEditForm, self).save(*args, **kwargs) + + class StockEditView(CounterAdminTabsMixin, CanEditPropMixin, UpdateView): """ An edit view for the stock @@ -119,3 +158,8 @@ class StockShoppingListView(CounterAdminTabsMixin, CanViewMixin, ListView): if 'stock_id' in self.kwargs.keys(): ret['stock'] = Stock.objects.filter(id=self.kwargs['stock_id']).first(); return ret + +class StockItemOutEditView(CounterAdminTabsMixin, CanViewMixin, UpdateView): + """ + docstring for StockItemOutList + """