Add Stock overview to component detail apge
This commit is contained in:
parent
4fe9bb1431
commit
5c3197e040
@ -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)
|
||||
|
@ -89,7 +89,7 @@
|
||||
<tr>
|
||||
<td><input type="text" class="form-control" name="{{f.parameter_type.name}}" value="{{f.parameter_type.value}}"></td>
|
||||
<td><input type="text" class="form-control" name="{{f.value.name}}" value="{{f.value.value}}"></td>
|
||||
<td>{{f.parameter_type_object.unit}}</td>
|
||||
<td>{{f.parameter_type_object.unit|default_if_none:""}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -99,6 +99,20 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<h2>Stocks</h2>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th scope="col">Storage</th>
|
||||
<th scope="col">Amount</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stock in stocks %}
|
||||
<tr>
|
||||
<td><a class="text-decoration-none text-primary" href="{% url 'parts-stocks-detail' uuid=stock.storage.id %}">{{stock.storage.get_full_path}}</a></td>
|
||||
<td>{{stock.amount}}</td>
|
||||
<tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user