Workplan Preise has been implemented
This commit is contained in:
parent
b99f45c7af
commit
6991b0989e
12 changed files with 878 additions and 11 deletions
59
vergabe_teilnahme/apps/preise/forms.py
Normal file
59
vergabe_teilnahme/apps/preise/forms.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
from decimal import Decimal
|
||||
|
||||
from django import forms
|
||||
|
||||
from vergabe_teilnahme.apps.lose.models import Los
|
||||
from vergabe_teilnahme.apps.partner.models import Subunternehmer
|
||||
|
||||
from .models import Preispunkt
|
||||
|
||||
NUMBER_ATTRS = {'class': 'form-input', 'step': '0.01'}
|
||||
WEIGHT_ATTRS = {'class': 'form-input', 'step': '0.1', 'min': '0.0', 'max': '2.0', 'type': 'number'}
|
||||
|
||||
|
||||
class PreispunktForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Preispunkt
|
||||
fields = [
|
||||
'leistungstyp', 'konkrete_leistung', 'mengeneinheit', 'menge',
|
||||
'einzelpreis', 'gesamtpreis', 'waehrung', 'preisstand',
|
||||
'wiederkehrend', 'laufzeitbezug',
|
||||
'subunternehmeranteil', 'subunternehmer',
|
||||
'vergleichsgewicht', 'gewichtungsbegruendung', 'kommentar', 'los',
|
||||
]
|
||||
widgets = {
|
||||
'leistungstyp': forms.TextInput(attrs={'class': 'form-input', 'list': 'leistungstypen-list'}),
|
||||
'konkrete_leistung': forms.TextInput(attrs={'class': 'form-input'}),
|
||||
'mengeneinheit': forms.TextInput(attrs={'class': 'form-input'}),
|
||||
'menge': forms.NumberInput(attrs={**NUMBER_ATTRS, 'id': 'id_menge'}),
|
||||
'einzelpreis': forms.NumberInput(attrs={**NUMBER_ATTRS, 'id': 'id_einzelpreis'}),
|
||||
'gesamtpreis': forms.NumberInput(attrs={**NUMBER_ATTRS, 'id': 'id_gesamtpreis'}),
|
||||
'waehrung': forms.TextInput(attrs={'class': 'form-input'}),
|
||||
'preisstand': forms.DateInput(attrs={'class': 'form-input', 'type': 'date'}),
|
||||
'laufzeitbezug': forms.TextInput(attrs={'class': 'form-input'}),
|
||||
'vergleichsgewicht': forms.NumberInput(attrs=WEIGHT_ATTRS),
|
||||
'gewichtungsbegruendung': forms.Textarea(attrs={'class': 'form-input', 'rows': 2}),
|
||||
'kommentar': forms.Textarea(attrs={'class': 'form-input', 'rows': 2}),
|
||||
'subunternehmer': forms.Select(attrs={'class': 'form-select'}),
|
||||
'los': forms.Select(attrs={'class': 'form-select'}),
|
||||
}
|
||||
|
||||
def __init__(self, *args, ausschreibung=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['vergleichsgewicht'].initial = Decimal('1.0')
|
||||
for field in ['menge', 'gesamtpreis', 'preisstand', 'laufzeitbezug',
|
||||
'subunternehmeranteil', 'subunternehmer',
|
||||
'gewichtungsbegruendung', 'kommentar', 'los']:
|
||||
self.fields[field].required = False
|
||||
if ausschreibung is not None:
|
||||
self.fields['los'].queryset = Los.objects.filter(ausschreibung=ausschreibung)
|
||||
else:
|
||||
self.fields['los'].queryset = Los.objects.none()
|
||||
self.fields['subunternehmer'].queryset = Subunternehmer.objects.all()
|
||||
|
||||
def clean_vergleichsgewicht(self):
|
||||
wert = self.cleaned_data.get('vergleichsgewicht')
|
||||
if wert is not None:
|
||||
if wert < Decimal('0.0') or wert > Decimal('2.0'):
|
||||
raise forms.ValidationError('Vergleichsgewicht muss zwischen 0,0 und 2,0 liegen.')
|
||||
return wert
|
||||
Loading…
Add table
Add a link
Reference in a new issue