mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Initial StockItem create form value addition
This commit is contained in:
parent
887893fb2d
commit
587ad96326
@ -1,4 +1,4 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
|
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
|
||||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, ProcessFormView, FormMixin
|
from django.views.generic.edit import UpdateView, CreateView, DeleteView, ProcessFormView, FormMixin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -39,7 +39,7 @@ class StockEditForm(forms.ModelForm):
|
|||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Stock
|
model = Stock
|
||||||
fields = ['name']
|
fields = ['name', 'counter']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(StockEditForm, self).__init__(*args, **kwargs)
|
super(StockEditForm, self).__init__(*args, **kwargs)
|
||||||
@ -81,5 +81,11 @@ class StockItemCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
|||||||
pk_url_kwarg = "stock_id"
|
pk_url_kwarg = "stock_id"
|
||||||
current_tab = "stocks"
|
current_tab = "stocks"
|
||||||
|
|
||||||
|
def get_initial(self):
|
||||||
|
ret = super(StockItemCreateView, self).get_initial()
|
||||||
|
if 'stock' in self.request.GET.keys():
|
||||||
|
ret['stock_owner'] = self.request.GET['stock']
|
||||||
|
return ret
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('stock:main', kwargs={'stock_id': self.object.stock_owner.id})
|
return reverse_lazy('stock:main', kwargs={'stock_id': self.object.stock_owner.id})
|
||||||
|
Loading…
Reference in New Issue
Block a user