From ca61437110136b65027f761a61177d1284c1e9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 31 Dec 2021 14:03:25 +0100 Subject: [PATCH] Add lot number to add stock form --- shimatta_kenkyusho/parts/forms.py | 3 ++- .../templates/parts/modals/add-stock-modal.html | 9 +++++++++ shimatta_kenkyusho/templates/parts/stocks-detail.html | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/shimatta_kenkyusho/parts/forms.py b/shimatta_kenkyusho/parts/forms.py index 1cbfbae..504d763 100644 --- a/shimatta_kenkyusho/parts/forms.py +++ b/shimatta_kenkyusho/parts/forms.py @@ -79,6 +79,7 @@ class AddStockForm(forms.Form): watermark = forms.IntegerField(min_value=0, required=True, initial=0) amount = forms.IntegerField(min_value=0, required=True, initial=1) component_uuid = forms.UUIDField(required=True) + lot = forms.CharField(max_length=255, required=False) def clean(self): cleaned_data = super().clean() @@ -103,7 +104,7 @@ class AddStockForm(forms.Form): if self.cleaned_data.get('watermark_active'): watermark = self.cleaned_data.get('watermark') - new_stock = parts_models.Stock.objects.create(storage=storage, component=component, watermark=watermark, amount=amount) + new_stock = parts_models.Stock.objects.create(storage=storage, component=component, watermark=watermark, amount=amount, lot=self.cleaned_data['lot']) new_stock.save() class EditComponentForm(forms.Form): diff --git a/shimatta_kenkyusho/templates/parts/modals/add-stock-modal.html b/shimatta_kenkyusho/templates/parts/modals/add-stock-modal.html index a617aa7..d9755bd 100644 --- a/shimatta_kenkyusho/templates/parts/modals/add-stock-modal.html +++ b/shimatta_kenkyusho/templates/parts/modals/add-stock-modal.html @@ -33,6 +33,15 @@ Input context: {% endfor %} +
+ + +
+ {% for msg in form.lot.errors %} + {{msg}} + {% endfor %} +
+
diff --git a/shimatta_kenkyusho/templates/parts/stocks-detail.html b/shimatta_kenkyusho/templates/parts/stocks-detail.html index 374a25d..753812b 100644 --- a/shimatta_kenkyusho/templates/parts/stocks-detail.html +++ b/shimatta_kenkyusho/templates/parts/stocks-detail.html @@ -76,6 +76,9 @@ {% if stock.component.manufacturer %} Manufacturer: {{stock.component.manufacturer}} {% endif %} + {% if stock.lot %} +
Lot: {{stock.lot}}
+ {% endif %}
Amount: {{stock.amount}} @@ -92,7 +95,7 @@
{% csrf_token %} - +