mac os enforced with mac. test about this. bugfix: remore renamed and

switched in meaning
This commit is contained in:
Benni Bärmann 2021-09-14 12:59:18 +02:00
parent bbd1e7ff6d
commit 20a38b5a82
6 changed files with 39 additions and 9 deletions

4
TODO
View File

@ -2,6 +2,6 @@
* use new it support adress in evapp/settings.py
* enforce Mac OS if Mac is choosen?
* better error handling with mail sending.
* test for complete run with all forms

View File

@ -35,18 +35,25 @@ class WorkingForm(EvaForm):
def clean(self):
data = self.cleaned_data
if not data['remote'] and data['desk'] is None:
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', 'remote', 'desk',]
'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 = [

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.4 on 2021-09-14 10:55
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('evapp', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='employee',
old_name='remote',
new_name='works_in_gs',
),
]

View File

@ -56,7 +56,7 @@ 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="Stellenbezeichnung(deutsch)")
jobdescription_english = models.CharField(null=True, max_length=100, verbose_name="Job description(english)")
remote = models.BooleanField(verbose_name='Braucht Arbeitsplatz in der Geschäftsstelle?', default=True)
works_in_gs = models.BooleanField(verbose_name='Braucht Arbeitsplatz in der Geschäftsstelle?', default=True)
desk = models.CharField(max_length=100, null=True, blank=True, verbose_name="Wo soll der Arbeitsplatz sein?")
# IT related stuff

View File

@ -13,7 +13,7 @@ MAILS = {
'MAIL': 'wmde-it@wikimedia.de',
'DATA': [
'laptop', 'os', 'comment', 'email', 'landline', 'lists', 'mobile',
'department', 'accounts', 'language', 'screen', 'remote', 'desk',
'department', 'accounts', 'language', 'screen', 'works_in_gs', 'desk',
'keyboard',
],
},
@ -21,7 +21,7 @@ MAILS = {
'MAIL': 'office@wikimedia.de',
'DATA': [
'transponder', 'special', 'post_office_box', 'sim', 'sim2',
'remote', 'desk',
'works_in_gs', 'desk',
],
},
'KOMM': {

View File

@ -32,5 +32,10 @@ class NoLoginTestCase(TestCase):
class ITFORMTestCase(TestCase):
def test_mac(self):
form = ITForm(data={"vendor": 'MAC', 'os': 'UBU'})
print (form.errors)
self.assertEqual(form.errors['os'], ['A MAC should have Mac OS installed'])
#print (form.errors)
self.assertEqual(form.non_field_errors(), ['Ein MAC sollte Mac OS installiert haben'])
def test_ubu(self):
form = ITForm(data={"vendor": 'STANDARD', 'os': 'UBU'})
#print (form.errors)
self.assertNotEqual(form.non_field_errors(), ['Ein MAC sollte Mac OS installiert haben'])