Skip to content

Commit 22c103c

Browse files
authored
Merge pull request #38 from moshthepitt/supervisorinforms
Add support for supervisor in forms
2 parents e3db9ee + 6ed6b80 commit 22c103c

11 files changed

+99
-83
lines changed

requirements/dev.txt

+33-34
Original file line numberDiff line numberDiff line change
@@ -8,83 +8,82 @@
88
appdirs==1.4.4 # via black, virtualenv
99
asgiref==3.2.10 # via django
1010
astroid==2.4.2 # via pylint
11-
attrs==19.3.0 # via black
12-
autopep8==1.5.3
13-
babel==2.8.0 # via django-phonenumber-field
11+
autopep8==1.5.4
1412
backcall==0.2.0 # via ipython
15-
black==19.10b0
16-
cfgv==3.1.0 # via pre-commit
13+
black==20.8b1
14+
cfgv==3.2.0 # via pre-commit
1715
click==7.1.2 # via black
18-
coverage==5.1
16+
coverage==5.2.1
17+
dataclasses==0.6 # via black
1918
decorator==4.4.2 # via ipython, traitlets
20-
distlib==0.3.0 # via virtualenv
19+
distlib==0.3.1 # via virtualenv
2120
django-braces==1.14.0 # via django-model-reviews
2221
django-contrib-comments==1.9.2 # via django-model-reviews
23-
django-crispy-forms==1.9.1
22+
django-crispy-forms==1.9.2
2423
django-js-asset==1.2.2 # via django-mptt
2524
django-model-reviews==1.0.2
2625
django-mptt==0.11.0
27-
django-phonenumber-field==4.0.0
26+
django-phonenumber-field==5.0.0
2827
django-private-storage==2.2.2
29-
django==3.0.7 # via django-braces, django-contrib-comments, django-model-reviews, django-mptt, django-phonenumber-field, djangorestframework, model-mommy
30-
djangorestframework==3.11.0
28+
django==3.1.1 # via django-braces, django-contrib-comments, django-model-reviews, django-mptt, django-phonenumber-field, djangorestframework, model-mommy
29+
djangorestframework==3.11.1
3130
fastdiff==0.2.0 # via snapshottest
3231
filelock==3.0.12 # via tox, virtualenv
3332
flake8==3.8.3
3433
freezegun==0.3.15
35-
identify==1.4.20 # via pre-commit
36-
importlib-metadata==1.6.1 # via flake8, importlib-resources, pluggy, pre-commit, tox, virtualenv
37-
importlib-resources==2.0.1 # via pre-commit, virtualenv
34+
identify==1.4.30 # via pre-commit
35+
importlib-metadata==1.7.0 # via flake8, pluggy, pre-commit, tox, virtualenv
36+
importlib-resources==3.0.0 # via pre-commit, virtualenv
3837
ipdb==0.13.3
3938
ipython-genutils==0.2.0 # via traitlets
40-
ipython==7.15.0 # via ipdb
41-
isort==4.3.21
42-
jedi==0.17.1 # via ipython
39+
ipython==7.16.1 # via ipdb
40+
isort==5.4.2
41+
jedi==0.17.2 # via ipython
4342
lazy-object-proxy==1.4.3 # via astroid
4443
mccabe==0.6.1 # via flake8, pylint
4544
model-mommy==2.0.0
46-
mypy-extensions==0.4.3 # via mypy
45+
mypy-extensions==0.4.3 # via black, mypy
4746
mypy==0.782
48-
nodeenv==1.4.0 # via pre-commit
47+
nodeenv==1.5.0 # via pre-commit
4948
packaging==20.4 # via tox
50-
parso==0.7.0 # via jedi
49+
parso==0.7.1 # via jedi
5150
pathspec==0.8.0 # via black
5251
pep8==1.7.1
5352
pexpect==4.8.0 # via ipython
54-
phonenumberslite==8.12.6
53+
phonenumberslite==8.12.9
5554
pickleshare==0.7.5 # via ipython
56-
pillow==7.1.2
55+
pillow==7.2.0
5756
pluggy==0.13.1 # via tox
58-
pre-commit==2.5.1
59-
prompt-toolkit==3.0.5 # via ipython
57+
pre-commit==2.7.1
58+
prompt-toolkit==3.0.7 # via ipython
6059
psycopg2-binary==2.8.5
6160
ptyprocess==0.6.0 # via pexpect
62-
py==1.8.2 # via tox
61+
py==1.9.0 # via tox
6362
pycodestyle==2.6.0
64-
pydocstyle==5.0.2
63+
pydocstyle==5.1.1
6564
pyflakes==2.2.0 # via flake8
6665
pygments==2.6.1 # via ipython
67-
pylint-django==2.0.15
66+
pylint-django==2.3.0
6867
pylint-plugin-utils==0.6 # via pylint-django
69-
pylint==2.5.3
68+
pylint==2.6.0
7069
pyparsing==2.4.7 # via packaging
7170
python-dateutil==2.8.1 # via freezegun
72-
pytz==2020.1 # via babel, django
71+
pytz==2020.1 # via django
7372
pyyaml==5.3.1 # via pre-commit
74-
regex==2020.6.8 # via black
73+
regex==2020.7.14 # via black
7574
six==1.15.0 # via astroid, django-braces, django-contrib-comments, freezegun, packaging, python-dateutil, snapshottest, tox, traitlets, virtualenv
7675
snapshottest==0.5.1
7776
snowballstemmer==2.0.0 # via pydocstyle
7877
sorl-thumbnail==12.6.3
7978
sqlparse==0.3.1 # via django
80-
tblib==1.6.0
79+
tblib==1.7.0
8180
termcolor==1.1.0 # via snapshottest
8281
toml==0.10.1 # via autopep8, black, pre-commit, pylint, tox
83-
tox==3.15.2
82+
tox==3.20.0
8483
traitlets==4.3.3 # via ipython
8584
typed-ast==1.4.1 # via astroid, black, mypy
86-
typing-extensions==3.7.4.2 # via mypy
87-
virtualenv==20.0.25 # via pre-commit, tox
85+
typing-extensions==3.7.4.3 # via black, mypy
86+
virtualenv==20.0.31 # via pre-commit, tox
8887
voluptuous==0.11.7
8988
wasmer==0.4.1 # via fastdiff
9089
wcwidth==0.2.5 # via prompt-toolkit

small_small_hr/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Main init file for small_small_hr."""
2-
VERSION = (0, 2, 1)
2+
VERSION = (0, 2, 2)
33
__version__ = ".".join(str(v) for v in VERSION)
44
# pylint: disable=invalid-name
55
default_app_config = "small_small_hr.apps.SmallSmallHrConfig" # noqa

small_small_hr/forms.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from django import forms
55
from django.conf import settings
6-
from django.contrib.auth.models import User
6+
from django.contrib.auth.models import User # pylint: disable = imported-auth-user
77
from django.db.models import Q
88
from django.utils.translation import ugettext as _
99

@@ -526,6 +526,7 @@ class Meta: # pylint: disable=too-few-public-methods
526526
"emergency_contact_name",
527527
"emergency_contact_number",
528528
"emergency_contact_relationship",
529+
"supervisor",
529530
]
530531

531532
def __init__(self, *args, **kwargs):
@@ -544,6 +545,7 @@ def __init__(self, *args, **kwargs):
544545
self.helper.layout = Layout(
545546
Field("first_name",),
546547
Field("last_name",),
548+
Field("supervisor",),
547549
Field("image",),
548550
Field("phone",),
549551
Field("id_number",),
@@ -660,6 +662,7 @@ class Meta: # pylint: disable=too-few-public-methods
660662
"user",
661663
"first_name",
662664
"last_name",
665+
"supervisor",
663666
"id_number",
664667
"image",
665668
"phone",
@@ -697,6 +700,7 @@ def __init__(self, *args, **kwargs):
697700
Field("user",),
698701
Field("first_name",),
699702
Field("last_name",),
703+
Field("supervisor",),
700704
Field("image",),
701705
Field("phone",),
702706
Field("id_number",),

small_small_hr/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def get_days(start: object, end: object):
507507
yield local_start.date() + timedelta(days=i)
508508

509509

510-
def get_taken_leave_days( # pylint: disable=bad-continuation
510+
def get_taken_leave_days(
511511
staffprofile: object, status: str, leave_type: str, start_year: int, end_year: int
512512
):
513513
"""

small_small_hr/reviews.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Review module for small-small-hr."""
22
from django.conf import settings
3-
from django.contrib.auth.models import User
3+
from django.contrib.auth.models import User # pylint: disable = imported-auth-user
44
from django.db import models
55

66
from model_reviews.models import Reviewer

small_small_hr/serializers.py

+44-41
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Serializers for users app
33
"""
4-
from django.contrib.auth.models import User
4+
from django.contrib.auth.models import User # pylint: disable = imported-auth-user
55

66
from rest_framework import serializers
77

@@ -18,16 +18,18 @@ class Meta: # pylint: disable=too-few-public-methods
1818
"""
1919
meta options
2020
"""
21+
2122
model = User
22-
fields = ('username', 'first_name', 'last_name', 'email')
23+
fields = ("username", "first_name", "last_name", "email")
2324

2425

2526
class StaffProfileSerializer(serializers.ModelSerializer):
2627
"""
2728
Serializer class for StaffProfile model
2829
"""
29-
first_name = serializers.CharField(source='user.first_name')
30-
last_name = serializers.CharField(source='user.last_name')
30+
31+
first_name = serializers.CharField(source="user.first_name")
32+
last_name = serializers.CharField(source="user.last_name")
3133
id_number = serializers.SerializerMethodField()
3234
phone = serializers.SerializerMethodField()
3335
sex = serializers.SerializerMethodField()
@@ -49,123 +51,124 @@ class Meta: # pylint: disable=too-few-public-methods
4951
"""
5052
class meta options
5153
"""
54+
5255
model = StaffProfile
5356
fields = [
54-
'id',
55-
'first_name',
56-
'last_name',
57-
'created',
58-
'id_number',
59-
'phone',
60-
'sex',
61-
'modified',
62-
'role',
63-
'nhif',
64-
'emergency_contact_name',
65-
'nssf',
66-
'address',
67-
'birthday',
68-
'overtime_allowed',
69-
'leave_days',
70-
'start_date',
71-
'sick_days',
72-
'pin_number',
73-
'end_date',
74-
'emergency_contact_number',
57+
"id",
58+
"first_name",
59+
"last_name",
60+
"created",
61+
"id_number",
62+
"phone",
63+
"sex",
64+
"modified",
65+
"role",
66+
"nhif",
67+
"emergency_contact_name",
68+
"nssf",
69+
"address",
70+
"birthday",
71+
"overtime_allowed",
72+
"leave_days",
73+
"start_date",
74+
"sick_days",
75+
"pin_number",
76+
"end_date",
77+
"emergency_contact_number",
7578
]
7679

7780
def get_id_number(self, obj): # pylint: disable=no-self-use
7881
"""
7982
Get id_number
8083
"""
81-
return obj.data.get('id_number')
84+
return obj.data.get("id_number")
8285

8386
def get_phone(self, obj): # pylint: disable=no-self-use
8487
"""
8588
Get phone
8689
"""
87-
return obj.data.get('phone')
90+
return obj.data.get("phone")
8891

8992
def get_sex(self, obj): # pylint: disable=no-self-use
9093
"""
9194
Get sex
9295
"""
93-
return obj.data.get('sex')
96+
return obj.data.get("sex")
9497

9598
def get_role(self, obj): # pylint: disable=no-self-use
9699
"""
97100
Get role
98101
"""
99-
return obj.data.get('role')
102+
return obj.data.get("role")
100103

101104
def get_nhif(self, obj): # pylint: disable=no-self-use
102105
"""
103106
Get nhhf
104107
"""
105-
return obj.data.get('nhif')
108+
return obj.data.get("nhif")
106109

107110
def get_nssf(self, obj): # pylint: disable=no-self-use
108111
"""
109112
Get nssf
110113
"""
111-
return obj.data.get('nssf')
114+
return obj.data.get("nssf")
112115

113116
def get_pin_number(self, obj): # pylint: disable=no-self-use
114117
"""
115118
Get pin_number
116119
"""
117-
return obj.data.get('pin_number')
120+
return obj.data.get("pin_number")
118121

119122
def get_address(self, obj): # pylint: disable=no-self-use
120123
"""
121124
Get address
122125
"""
123-
return obj.data.get('address')
126+
return obj.data.get("address")
124127

125128
def get_birthday(self, obj): # pylint: disable=no-self-use
126129
"""
127130
Get birthday
128131
"""
129-
return obj.data.get('birthday')
132+
return obj.data.get("birthday")
130133

131134
def get_leave_days(self, obj): # pylint: disable=no-self-use
132135
"""
133136
Get leave_days
134137
"""
135-
return obj.data.get('leave_days')
138+
return obj.data.get("leave_days")
136139

137140
def get_sick_days(self, obj): # pylint: disable=no-self-use
138141
"""
139142
Get sick_days
140143
"""
141-
return obj.data.get('sick_days')
144+
return obj.data.get("sick_days")
142145

143146
def get_overtime_allowed(self, obj): # pylint: disable=no-self-use
144147
"""
145148
Get overtime_allowed
146149
"""
147-
return obj.data.get('overtime_allowed')
150+
return obj.data.get("overtime_allowed")
148151

149152
def get_start_date(self, obj): # pylint: disable=no-self-use
150153
"""
151154
Get start_date
152155
"""
153-
return obj.data.get('start_date')
156+
return obj.data.get("start_date")
154157

155158
def get_end_date(self, obj): # pylint: disable=no-self-use
156159
"""
157160
Get end_date
158161
"""
159-
return obj.data.get('end_date')
162+
return obj.data.get("end_date")
160163

161164
def get_emergency_contact_name(self, obj): # pylint: disable=no-self-use
162165
"""
163166
Get emergency_contact_name
164167
"""
165-
return obj.data.get('emergency_contact_name')
168+
return obj.data.get("emergency_contact_name")
166169

167170
def get_emergency_contact_number(self, obj): # pylint: disable=no-self-use
168171
"""
169172
Get emergency_contact_number
170173
"""
171-
return obj.data.get('emergency_contact_number')
174+
return obj.data.get("emergency_contact_number")

small_small_hr/templates/small_small_hr/email/leave_application_email_body.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{ object.content_object.duration.days }} days of {{ object.content_object.get_leave_type_display}}<br />
33
{{ object.content_object.start|date:"D, d M Y" }} - {{ object.content_object.end|date:"D, d M Y" }}<br />
44
Available Balance: {{ object.content_object.staff.get_available_leave_days|floatformat:2 }} days<br /><br />
5-
Please log in to process the above: http://{{SITE.name}}/reviews/{{ object.pk }}
5+
Please log in to process the above: http://{{SITE.domain}}/reviews/{{ object.pk }}
66
<br/><br/>
77
Thank you,<br/>
88
{{SITE.name}}<br/>

small_small_hr/templates/small_small_hr/email/leave_application_email_body.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{ object.content_object.start|date:"D, d M Y" }} - {{ object.content_object.end|date:"D, d M Y" }}
55
Available Balance: {{ object.content_object.staff.get_available_leave_days|floatformat:2 }} days
66

7-
Please log in to process the above: http://{{SITE.name}}/reviews/{{ object.pk }}
7+
Please log in to process the above: http://{{SITE.domain}}/reviews/{{ object.pk }}
88

99
Thank you,
1010

0 commit comments

Comments
 (0)