from django import forms from .models import * class ConsumableGoodsCategoryForm(forms.ModelForm): class Meta: model = ConsumableGoodsCategory fields = '__all__' widgets = { 'category_name': forms.TextInput(attrs={'class': 'form-control'}), 'description': forms.Textarea(attrs={'class': 'form-control'}), } class ConsumableGoodsInventoryForm(forms.ModelForm): class Meta: model = ConsumableGoodsInventory exclude = ['current_inventory', 'replenishment_alert'] def __init__(self, *args, **kwargs): super(ConsumableGoodsInventoryForm, self).__init__(*args, **kwargs) for field_name in self.fields: if field_name not in ['item_name', 'category']: self.fields[field_name].required = False class CompanyMobilePhoneUsageRegistryForm(forms.ModelForm): class Meta: model = CompanyMobilePhoneUsageRegistry fields = '__all__' widgets = { 'mobile_number': forms.TextInput(attrs={'class': 'form-control'}), 'owner': forms.TextInput(attrs={'class': 'form-control'}), 'current_user': forms.TextInput(attrs={'class': 'form-control'}), 'purpose': forms.TextInput(attrs={'class': 'form-control'}), } class BusinessVehicleUsageRegistryForm(forms.ModelForm): class Meta: model = BusinessVehicleUsageRegistry fields = '__all__' widgets = { 'license_plate': forms.TextInput(attrs={'class': 'form-control'}), 'checkout_time': forms.DateTimeInput(attrs={'class': 'form-control', 'type': 'datetime-local'}), 'borrower': forms.TextInput(attrs={'class': 'form-control'}), 'accompanying_personnel': forms.TextInput(attrs={'class': 'form-control'}), 'reason': forms.TextInput(attrs={'class': 'form-control'}), 'destination': forms.TextInput(attrs={'class': 'form-control'}), 'days_of_use': forms.NumberInput(attrs={'class': 'form-control'}), 'return_time': forms.DateTimeInput(attrs={'class': 'form-control', 'type': 'datetime-local'}), } class MembershipAccountsRegistryForm(forms.ModelForm): class Meta: model = MembershipAccountsRegistry exclude = ['status'] widgets = { 'platform_name': forms.TextInput(attrs={'class': 'form-control'}), 'purpose': forms.TextInput(attrs={'class': 'form-control'}), 'price': forms.NumberInput(attrs={'class': 'form-control'}), 'unit': forms.TextInput(attrs={'class': 'form-control','placeholder': '年/月/周'}), 'manager': forms.TextInput(attrs={'class': 'form-control'}), 'account': forms.TextInput(attrs={'class': 'form-control'}), 'email': forms.EmailInput(attrs={'class': 'form-control'}), 'phone_number': forms.TextInput(attrs={'class': 'form-control'}), 'effective_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}), 'expiration_date': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}), } class StoredValueCardRegistrationForm(forms.ModelForm): class Meta: model = StoredValueCardRegistration exclude = ['usage_records', 'balance'] widgets = { 'merchant_name': forms.TextInput(attrs={'class': 'form-control'}), 'merchant_type': forms.TextInput(attrs={'class': 'form-control'}) }