shimatta-kenkyusho/shimatta_kenkyusho/parts/forms.py

33 lines
1.2 KiB
Python

from django import forms
from parts import models as parts_models
class MyTestForm(forms.Form):
pass
class AddSubStorageForm(forms.Form):
storage_name = forms.CharField(label="storage_name", initial='')
responsible = forms.CharField(label='responsible_user')
class EditStockForm(forms.Form):
stock_uuid = forms.UUIDField()
increment = forms.IntegerField(label='Change Amount')
watermark_active = forms.BooleanField()
watermark = forms.IntegerField(min_value=0)
class EditStockForm(forms.Form):
def __init__(self, *args, **kwargs):
# only change attributes if an instance is passed
instance = kwargs.get('instance')
if instance:
self.fields['amount_change'] = forms.IntegerField(min_value=0)
wm = instance.watermark
wm_active = True
if wm < 0:
wm = 0
wm_active = False
self.fields['watermark'] = forms.IntegerField(min_value=0, initial=wm)
self.fields['watermark_active'] = forms.BooleanField(initial=wm_active)
print('Hohew')
super().__init__(*args, **kwargs)
class DeleteStockForm(forms.Form):
stock_uuid = forms.UUIDField()