diff --git a/shimatta_kenkyusho/parts/views.py b/shimatta_kenkyusho/parts/views.py index 3823c28..17581cf 100644 --- a/shimatta_kenkyusho/parts/views.py +++ b/shimatta_kenkyusho/parts/views.py @@ -391,7 +391,7 @@ class ComponentDetailView(LoginRequiredMixin, BaseTemplateMixin, DetailView): base_title = '' navbar_selected = 'Components' - def preparae_initial_param_formset_data(self): + def prepare_initial_param_formset_data(self): parameters = ComponentParameter.objects.filter(component=self.object) initdata = [] for param in parameters: @@ -411,7 +411,9 @@ class ComponentDetailView(LoginRequiredMixin, BaseTemplateMixin, DetailView): ParameterFormset = forms.formset_factory(EditComponentParameterForm, extra=0, max_num=100) context['param_formset'] = ParameterFormset( - initial=self.preparae_initial_param_formset_data()) + initial=self.prepare_initial_param_formset_data()) + + context['stocks'] = Stock.objects.filter(component=self.object) return context def handle_submit_edit_post(self, request, **kwargs): @@ -437,11 +439,7 @@ class ComponentDetailView(LoginRequiredMixin, BaseTemplateMixin, DetailView): def handle_submit_edit_params_post(self, request, **kwargs): - f = EditComponentParameterForm(data=request.POST) - if f.is_valid(): - print('Valid') - else: - print('Invalid') + context = self.get_context_data() return self.render_to_response(context) diff --git a/shimatta_kenkyusho/templates/parts/components-detail.html b/shimatta_kenkyusho/templates/parts/components-detail.html index 1f62822..9b4e25a 100644 --- a/shimatta_kenkyusho/templates/parts/components-detail.html +++ b/shimatta_kenkyusho/templates/parts/components-detail.html @@ -89,7 +89,7 @@ - {{f.parameter_type_object.unit}} + {{f.parameter_type_object.unit|default_if_none:""}} {% endfor %} @@ -99,6 +99,20 @@

Stocks

+ + + + + + + {% for stock in stocks %} + + + + + {% endfor %} + +
StorageAmount
{{stock.storage.get_full_path}}{{stock.amount}}