Skip to content

Commit

Permalink
Add emergency contact relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
moshthepitt committed Jun 21, 2018
1 parent c8fe66c commit 67f9af3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions small_small_hr/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ class StaffProfileAdminForm(forms.ModelForm):
pin_number = forms.CharField(label=_('PIN Number'), required=False)
emergency_contact_name = forms.CharField(
label=_('Emergecy Contact Name'), required=False)
emergency_contact_relationship = forms.CharField(
label=_('Emergecy Contact Relationship'), required=False)
emergency_contact_number = PhoneNumberField(
label=_('Emergency Contact Phone Number'), required=False)

Expand Down Expand Up @@ -444,6 +446,7 @@ class Meta: # pylint: disable=too-few-public-methods
'end_date',
'emergency_contact_name',
'emergency_contact_number',
'emergency_contact_relationship'
]

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -475,6 +478,7 @@ def __init__(self, *args, **kwargs):
Field('end_date',),
Field('emergency_contact_name',),
Field('emergency_contact_number',),
Field('emergency_contact_relationship',),
FormActions(
Submit('submitBtn', _('Submit'), css_class='btn-primary'),
)
Expand Down Expand Up @@ -544,6 +548,8 @@ def save(self, commit=True): # pylint: disable=unused-argument
'pin_number': self.cleaned_data.get('pin_number'),
'emergency_contact_name': self.cleaned_data.get(
'emergency_contact_name'),
'emergency_contact_relationship': self.cleaned_data.get(
'emergency_contact_relationship'),
'emergency_contact_number': emergency_phone,
}
staffprofile.data = json_data
Expand Down Expand Up @@ -588,6 +594,7 @@ class Meta: # pylint: disable=too-few-public-methods
'end_date',
'emergency_contact_name',
'emergency_contact_number',
'emergency_contact_relationship'
]

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -620,6 +627,7 @@ def __init__(self, *args, **kwargs):
Field('end_date',),
Field('emergency_contact_name',),
Field('emergency_contact_number',),
Field('emergency_contact_relationship',),
FormActions(
Submit('submitBtn', _('Submit'), css_class='btn-primary'),
)
Expand Down Expand Up @@ -650,6 +658,7 @@ class Meta: # pylint: disable=too-few-public-methods
'birthday',
'emergency_contact_name',
'emergency_contact_number',
'emergency_contact_relationship'
]

def __init__(self, *args, **kwargs):
Expand All @@ -676,6 +685,7 @@ def __init__(self, *args, **kwargs):
Field('birthday',),
Field('emergency_contact_name',),
Field('emergency_contact_number',),
Field('emergency_contact_relationship',),
FormActions(
Submit('submitBtn', _('Submit'), css_class='btn-primary'),
)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ def test_staff_profile_user_form(self):
'nssf': '222222',
'pin_number': 'A0000000Y',
'emergency_contact_name': 'Bob Father',
'emergency_contact_relationship': 'Father',
'emergency_contact_number': '+254722111111',
'phone': '+254722111111',
'address': 'This is the address.',
Expand Down Expand Up @@ -772,6 +773,8 @@ def test_staff_profile_user_form(self):
staffprofile.data['pin_number'])
self.assertEqual('Bob Father',
staffprofile.data['emergency_contact_name'])
self.assertEqual('Father',
staffprofile.data['emergency_contact_relationship'])
self.assertEqual('+254722111111',
staffprofile.data['emergency_contact_number'])

Expand Down

0 comments on commit 67f9af3

Please sign in to comment.