chol
/
eva
forked from tohe/eva
1
0
Fork 0

add validation: desk must be present if not remote working

This commit is contained in:
Benni Bärmann 2021-02-09 12:45:33 +01:00
parent e3de93366a
commit 3953149e2f
3 changed files with 12 additions and 4 deletions

View File

@ -25,7 +25,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
SECRET_KEY = 'g%+i6+gkwt3zz@+k-5x1dtstuw4)&qd$lxd^bt2oswy5e1#dul'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True
STATIC_ROOT = BASE_DIR / 'staticfiles'

View File

@ -1,5 +1,6 @@
from django.db import models
from django.forms import ModelForm, DateInput, Form, ChoiceField, RadioSelect
from django.core.exceptions import ValidationError
from .models import Employee
@ -30,10 +31,17 @@ class PersonalForm(EvaForm):
fields = ['firstname', 'lastname', 'intern', 'email', 'department', 'team', ]
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:
model = Employee
fields = ['firstdate_employment', 'firstdate_presence', 'jobdescription_german',
'jobdescription_english', 'desk',]
'jobdescription_english', 'remote', 'desk',]
widgets = {'firstdate_employment': DateInput(attrs={'type': 'date'}),
'firstdate_presence': DateInput(attrs={'type': 'date'}),}

View File

@ -55,8 +55,8 @@ class Employee(models.Model):
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_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?")
# TODO: we need an optional question for remote work here
remote = models.BooleanField(verbose_name='Braucht keinen Arbeitsplatz weil Home-Office', default=False)
desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?")
# IT related stuff
laptop = models.CharField(max_length=2, choices=LAPTOP_CHOICES.items(), default='14')