79 lines
2.7 KiB
Python
79 lines
2.7 KiB
Python
from django.db import models
|
|
from django.forms import ModelForm, DateInput, Form, ChoiceField, RadioSelect
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from .models import Employee
|
|
|
|
# class EmployeeForm(ModelForm):
|
|
# class Meta:
|
|
# model = Employee
|
|
# fields = '__all__'
|
|
# widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
|
|
# 'firstdate_presence': DateInput(attrs={'type': 'date'}),}
|
|
|
|
class DummyForm(ModelForm):
|
|
class Meta:
|
|
model = Employee
|
|
fields = []
|
|
|
|
class EvaForm(ModelForm):
|
|
'''this base class provides the required css class for all forms'''
|
|
required_css_class = 'required'
|
|
|
|
TYPE_CHOICES = {'IN': 'Eintritt', 'CHANGE': 'Veränderung', 'OUT': 'Austritt'}
|
|
|
|
class PersonalForm(EvaForm):
|
|
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
|
|
label='Welcher Prozess soll angestoßen werden?')
|
|
|
|
class Meta:
|
|
model = Employee
|
|
fields = ['firstname', 'lastname', 'department', 'team', ]
|
|
|
|
class OffboardingForm(EvaForm):
|
|
class Meta:
|
|
model: Employee
|
|
fields = ['lastdate_employment']
|
|
widgets = {'lastdate_employment' : DateInput(attrs={'type': 'date'})}
|
|
|
|
class WorkingForm(EvaForm):
|
|
|
|
def clean(self):
|
|
data = self.cleaned_data
|
|
if data['works_in_gs'] and data['desk'] is None:
|
|
raise ValidationError('Wer nicht remote arbeitet braucht einen Schreibtisch!')
|
|
return data
|
|
|
|
class Meta:
|
|
model = Employee
|
|
fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german',
|
|
'jobdescription_english', 'works_in_gs', 'desk',]
|
|
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
|
|
'firstdate_presence': DateInput(attrs={'type': 'date'}),}
|
|
|
|
class ITForm(EvaForm):
|
|
|
|
def clean(self):
|
|
data = self.cleaned_data
|
|
if data['vendor'] == 'MAC' and data['os'] != 'MOS':
|
|
raise ValidationError('Ein MAC sollte Mac OS installiert haben')
|
|
return data
|
|
|
|
class Meta:
|
|
model = Employee
|
|
fields = [
|
|
'vendor', 'os', 'keyboard', 'screen', 'mobile', 'comment',
|
|
'language', 'accounts', 'lists', 'rebu2go' ]
|
|
|
|
class OfficeForm(EvaForm):
|
|
class Meta:
|
|
model = Employee
|
|
fields = ['transponder', 'special', 'post_office_box',]
|
|
|
|
class ChangeForm(EvaForm):
|
|
class Meta:
|
|
model = Employee
|
|
fields = ['firstdate_employment', 'jobdescription_german', 'jobdescription_english',
|
|
'desk', 'comment', 'accounts', 'lists', 'transponder']
|
|
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),}
|