27 lines
996 B
Python
27 lines
996 B
Python
from django import forms
|
|
from .models import ExcelEntry, Betriebskosten
|
|
|
|
class ExcelEntryForm(forms.ModelForm):
|
|
class Meta:
|
|
model = ExcelEntry
|
|
fields = '__all__' # Include only the fields you want users to input
|
|
|
|
class BetriebskostenForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Betriebskosten
|
|
fields = ['buchungsdatum', 'rechnungsnummer', 'kostentyp', 'gas_volume', 'betrag', 'beschreibung']
|
|
widgets = {
|
|
'buchungsdatum': forms.DateInput(attrs={'type': 'date'}),
|
|
'beschreibung': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['gas_volume'].required = False
|
|
|
|
# Add price per liter field (readonly)
|
|
self.fields['price_per_liter'] = forms.CharField(
|
|
label='Preis pro Liter (€)',
|
|
required=False,
|
|
widget=forms.TextInput(attrs={'readonly': 'readonly'})
|
|
) |