From 20a38b5a8266a9f14b9401b4d38c39696825531a Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 14 Sep 2021 12:59:18 +0200 Subject: [PATCH] mac os enforced with mac. test about this. bugfix: remore renamed and switched in meaning --- TODO | 4 ++-- evapp/forms.py | 11 +++++++++-- evapp/migrations/0002_auto_20210914_1055.py | 18 ++++++++++++++++++ evapp/models.py | 2 +- evapp/settings.py | 4 ++-- evapp/tests.py | 9 +++++++-- 6 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 evapp/migrations/0002_auto_20210914_1055.py diff --git a/TODO b/TODO index 4670e0b..b729cf0 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/evapp/forms.py b/evapp/forms.py index 1ebaa0e..0bf81ec 100644 --- a/evapp/forms.py +++ b/evapp/forms.py @@ -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 = [ diff --git a/evapp/migrations/0002_auto_20210914_1055.py b/evapp/migrations/0002_auto_20210914_1055.py new file mode 100644 index 0000000..0797935 --- /dev/null +++ b/evapp/migrations/0002_auto_20210914_1055.py @@ -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', + ), + ] diff --git a/evapp/models.py b/evapp/models.py index 2ad4f52..79bda50 100644 --- a/evapp/models.py +++ b/evapp/models.py @@ -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 diff --git a/evapp/settings.py b/evapp/settings.py index a519907..f403169 100644 --- a/evapp/settings.py +++ b/evapp/settings.py @@ -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': { diff --git a/evapp/tests.py b/evapp/tests.py index 519ce75..f897265 100644 --- a/evapp/tests.py +++ b/evapp/tests.py @@ -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'])