add validation: desk must be present if not remote working
This commit is contained in:
parent
e3de93366a
commit
3953149e2f
|
@ -25,7 +25,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul'
|
SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.forms import ModelForm, DateInput, Form, ChoiceField, RadioSelect
|
from django.forms import ModelForm, DateInput, Form, ChoiceField, RadioSelect
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from .models import Employee
|
from .models import Employee
|
||||||
|
|
||||||
|
@ -30,10 +31,17 @@ class PersonalForm(EvaForm):
|
||||||
fields = ['firstname', 'lastname', 'intern', 'email', 'department', 'team', ]
|
fields = ['firstname', 'lastname', 'intern', 'email', 'department', 'team', ]
|
||||||
|
|
||||||
class WorkingForm(EvaForm):
|
class WorkingForm(EvaForm):
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
data = self.cleaned_data
|
||||||
|
if not data['remote'] and data['desk'] is None:
|
||||||
|
raise ValidationError('Wer nicht remote arbeitet braucht einen Schreibtisch!')
|
||||||
|
return data
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Employee
|
model = Employee
|
||||||
fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german',
|
fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german',
|
||||||
'jobdescription_english', 'desk',]
|
'jobdescription_english', 'remote', 'desk',]
|
||||||
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
|
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
|
||||||
'firstdate_presence': DateInput(attrs={'type': 'date'}),}
|
'firstdate_presence': DateInput(attrs={'type': 'date'}),}
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ class Employee(models.Model):
|
||||||
firstdate_presence = models.DateField(null=True, verbose_name="erster Tag der Anwesenheit in der Geschäftsstelle")
|
firstdate_presence = models.DateField(null=True, verbose_name="erster Tag der Anwesenheit in der Geschäftsstelle")
|
||||||
jobdescription_german = models.CharField(null=True, max_length=100, verbose_name="Stellenbeschreibung(deutsch)")
|
jobdescription_german = models.CharField(null=True, max_length=100, verbose_name="Stellenbeschreibung(deutsch)")
|
||||||
jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="job description(english)")
|
jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="job description(english)")
|
||||||
desk = models.CharField(max_length=100, null=True, verbose_name="Wo soll der Arbeitsplatz sein?")
|
remote = models.BooleanField(verbose_name='Braucht keinen Arbeitsplatz weil Home-Office', default=False)
|
||||||
# TODO: we need an optional question for remote work here
|
desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?")
|
||||||
|
|
||||||
# IT related stuff
|
# IT related stuff
|
||||||
laptop = models.CharField(max_length=2, choices=LAPTOP_CHOICES.items(), default='14')
|
laptop = models.CharField(max_length=2, choices=LAPTOP_CHOICES.items(), default='14')
|
||||||
|
|
Loading…
Reference in New Issue