chol
/
eva
forked from tohe/eva
1
0
Fork 0
eva/evapp/forms.py

79 lines
2.7 KiB
Python
Raw Normal View History

from django.db import models
from django.forms import ModelForm, DateInput, Form, ChoiceField, RadioSelect
from django.core.exceptions import ValidationError
from .models import Employee
2021-01-13 12:12:40 +00:00
# class EmployeeForm(ModelForm):
# class Meta:
# model = Employee
# fields = '__all__'
# widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
# 'firstdate_presence': DateInput(attrs={'type': 'date'}),}
2021-01-11 15:12:20 +00:00
class DummyForm(ModelForm):
class Meta:
model = Employee
fields = []
2021-02-04 09:41:52 +00:00
class EvaForm(ModelForm):
2021-01-13 13:17:21 +00:00
'''this base class provides the required css class for all forms'''
required_css_class = 'required'
TYPE_CHOICES = {'IN': 'Eintritt', 'CHANGE': 'Veränderung', 'OUT': 'Austritt'}
2021-02-04 09:41:52 +00:00
class PersonalForm(EvaForm):
2021-11-10 08:34:40 +00:00
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
label='Welcher Prozess soll angestoßen werden?')
2021-01-11 15:12:20 +00:00
class Meta:
model = Employee
fields = ['firstname', 'lastname', 'department', 'team', ]
2021-01-11 15:12:20 +00:00
2021-11-10 12:11:00 +00:00
class OffboardingForm(EvaForm):
class Meta:
2021-11-10 14:48:12 +00:00
model = Employee
2021-11-10 12:11:00 +00:00
fields = ['lastdate_employment']
widgets = {'lastdate_employment' : DateInput(attrs={'type': 'date'})}
2021-02-04 09:41:52 +00:00
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
2021-01-11 15:12:20 +00:00
class Meta:
model = Employee
2021-01-13 12:12:40 +00:00
fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german',
'jobdescription_english', 'works_in_gs', 'desk',]
2021-01-11 15:12:20 +00:00
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
'firstdate_presence': DateInput(attrs={'type': 'date'}),}
2021-01-13 12:12:40 +00:00
2021-02-04 09:41:52 +00:00
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
2021-01-13 12:12:40 +00:00
class Meta:
model = Employee
fields = [
'vendor', 'os', 'keyboard', 'screen', 'mobile', 'comment',
2021-02-08 14:51:39 +00:00
'language', 'accounts', 'lists', 'rebu2go' ]
2021-01-13 12:12:40 +00:00
2021-02-04 09:41:52 +00:00
class OfficeForm(EvaForm):
2021-01-13 12:12:40 +00:00
class Meta:
model = Employee
fields = ['transponder', 'special', 'post_office_box',]
2021-02-02 09:30:00 +00:00
2021-02-04 09:41:52 +00:00
class ChangeForm(EvaForm):
2021-02-02 09:30:00 +00:00
class Meta:
model = Employee
fields = ['firstdate_employment', 'jobdescription_german', 'jobdescription_english',
'desk', 'comment', 'accounts', 'lists', 'transponder']
2021-02-02 09:33:51 +00:00
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),}