WMDE
/
eva
forked from tohe/eva
7
1
Fork 0

Compare commits

...

8 Commits

8 changed files with 109 additions and 18 deletions

View File

@ -20,17 +20,23 @@ class EvaForm(ModelForm):
'''this base class provides the required css class for all forms'''
required_css_class = 'required'
TYPE_CHOICES = {'IN': 'Eintritt', 'CHANGE': 'Veränderung', 'OUT': 'Austritt'}
# TYPE_CHOICES = {'IN': 'Eintritt', 'CHANGE': 'Veränderung', 'OUT': 'Austritt'}
TYPE_CHOICES = {'IN': 'Eintritt', 'OUT': 'Austritt'}
class PersonalForm(EvaForm):
# TODO: comment this back in to use implementation of change or exit process
# choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
# label='Welcher Prozess soll angestoßen werden?')
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
label='Welcher Prozess soll angestoßen werden?')
class Meta:
model = Employee
fields = ['firstname', 'lastname', 'department', 'team', ]
class OffboardingForm(EvaForm):
class Meta:
model = Employee
fields = ['lastdate_employment']
widgets = {'lastdate_employment' : DateInput(attrs={'type': 'date'})}
class WorkingForm(EvaForm):
def clean(self):

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.4 on 2021-11-10 08:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('evapp', '0002_auto_20210914_1055'),
]
operations = [
migrations.AlterField(
model_name='employee',
name='department',
field=models.CharField(choices=[('PROG', 'Programme'), ('SOFT', 'Softwareentwicklung'), ('CENT', 'Central'), ('KOMEV', 'Kommunikation und Events'), ('VOR', 'Vorstand')], max_length=5, verbose_name='Bereich'),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.1.4 on 2021-11-10 12:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('evapp', '0003_auto_20211110_0832'),
]
operations = [
migrations.AddField(
model_name='employee',
name='lastdate_employment',
field=models.DateField(null=True, verbose_name='Letzter Arbeitstag'),
),
migrations.AddField(
model_name='employee',
name='lastdate_presence',
field=models.DateField(null=True, verbose_name='Letzter Tag der Anwesenheit in der Geschäftsstelle'),
),
]

View File

@ -55,6 +55,8 @@ class Employee(models.Model):
# general work related stuff
firstdate_employment = models.DateField(null=True, verbose_name="Erster Arbeitstag")
firstdate_presence = models.DateField(null=True, verbose_name="Erster Tag der Anwesenheit in der Geschäftsstelle")
lastdate_employment= models.DateField(null=True, verbose_name="Letzter Arbeitstag")
lastdate_presence = models.DateField(null=True, verbose_name="Letzter 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)")
works_in_gs = models.BooleanField(verbose_name='Braucht Arbeitsplatz in der Geschäftsstelle?', default=True)

View File

@ -1,5 +1,5 @@
# temporary setting while change and exit is not yet fully implemented
ONLY_ONBOARDING = True
ONLY_ONBOARDING = False
# sender mail adress also used for MAILTEST mode
EVA_MAIL = 'it-support@wikimedia.de'

View File

@ -5,7 +5,7 @@ from django.conf import settings
from django.http import HttpResponse
from django.core import mail
from .forms import ITForm, WorkingForm, OfficeForm, DummyForm
from .forms import ITForm, WorkingForm, OfficeForm, DummyForm, OffboardingForm
class LoginTestCase(TestCase):
def setUp(self):
@ -45,8 +45,8 @@ class LoginTestCase(TestCase):
self.assertContains(self.response, 'Programme', status_code=200)
self.assertContains(self.response, 'Kommunikation und Events', status_code=200)
def testWizzard(self):
''' this test goes through the whole process of the EvaFormView from start to end '''
def test_wizzard_in(self):
''' this test goes through the whole onboarding process of the EvaFormView from start to end '''
self.assertEqual(200, self.response.status_code)
@ -55,6 +55,7 @@ class LoginTestCase(TestCase):
'0-firstname': 'Ara',
'0-lastname': 'Seva',
'0-department': 'CENT',
'0-choice': 'IN'
}, WorkingForm)
response = self._postform({
@ -83,8 +84,35 @@ class LoginTestCase(TestCase):
'eva_form_view-current_step': '5',
}, DummyForm)
def test_wizzard_out(self):
''' this test goes through the whole offboarding process of the EvaFormView from start to end '''
self.assertEqual(200, self.response.status_code)
response = self._postform({
'eva_form_view-current_step': '0',
'0-firstname': 'Ara',
'0-lastname': 'Seva',
'0-department': 'CENT',
'0-choice': 'OUT'
}, OffboardingForm)
response = self._postform({
'eva_form_view-current_step': '4',
'4-lastdate_employment': '2021-01-01',
'4-date_returning': '2021-01-01',
'4-lastdate_bvg': '2021-01-01',
'4-lastdate_bahncard': '2021-01-01',
}, DummyForm)
response = self._postform({
'eva_form_view-current_step': '5',
}, DummyForm)
def test_mail(self):
self.testWizzard()
self.test_wizzard_in()
# print(mail.outbox)
self.assertGreater(len(mail.outbox), 2)
self.assertIn("Ara Seva", mail.outbox[0].subject)

View File

@ -1,13 +1,13 @@
from django.urls import path
from .views import EvaFormView, success, long_process, change_process
from .views import EvaFormView, success, long_process, change_process, offboarding_process
urlpatterns = [
path('', EvaFormView.as_view(condition_dict = {'1': long_process,
'2': long_process,
'3': long_process,
'4': change_process,}),
'4': offboarding_process,}),
name='evaform'),
path('success', success, name='success')
]

View File

@ -14,7 +14,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from .models import Employee, DEPARTMENT_CHOICES, OS_CHOICES, VENDOR_CHOICES, \
LANG_CHOICES, ACCOUNT_CHOICES, TRANSPONDER_CHOICES, KEYBOARD_CHOICES
from .forms import PersonalForm, WorkingForm, ITForm, OfficeForm, DummyForm,\
ChangeForm, TYPE_CHOICES
ChangeForm, TYPE_CHOICES, OffboardingForm
from .settings import MAILS, EVA_MAIL, BASIC_DATA, ONLY_ONBOARDING
def success(request):
@ -28,14 +28,28 @@ def long_process(wizard):
return True
else:
data = wizard.get_cleaned_data_for_step('0') or {}
print(data)
if data.get('choice') != 'CHANGE':
# print(data)
if data.get('choice') == 'IN':
wizard.set_choice('IN')
print('PROZESS IN')
return True
else:
wizard.set_choice('CHANGE')
print('PROZESS NOT IN')
return False
#wizard.set_choice('CHANGE')
#print('PROZESS CHANGE')
#return False
def offboarding_process(wizard):
''' this method is called via urls.py to determine if the form is part of the change process'''
print('OFFBOARDING PROZESS')
if not ONLY_ONBOARDING:
data = wizard.get_cleaned_data_for_step('0') or {}
print(data)
if data.get('choice') == 'OUT':
#print("PPPPPPPPPPPPPPP")
wizard.set_choice('OUT')
return True
# wizard.set_choice('IN')
return False
def change_process(wizard):
@ -46,7 +60,7 @@ def change_process(wizard):
class EvaFormView(LoginRequiredMixin, CookieWizardView):
template_name = 'evapp/employee_form.html'
form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, ChangeForm, DummyForm]
form_list = [PersonalForm, WorkingForm, ITForm, OfficeForm, OffboardingForm, DummyForm]
instance = None
choice = 'IN'