diff --git a/requirements/dev.txt b/requirements/dev.txt index 1e597e5..8c4ad6c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -8,83 +8,82 @@ appdirs==1.4.4 # via black, virtualenv asgiref==3.2.10 # via django astroid==2.4.2 # via pylint -attrs==19.3.0 # via black -autopep8==1.5.3 -babel==2.8.0 # via django-phonenumber-field +autopep8==1.5.4 backcall==0.2.0 # via ipython -black==19.10b0 -cfgv==3.1.0 # via pre-commit +black==20.8b1 +cfgv==3.2.0 # via pre-commit click==7.1.2 # via black -coverage==5.1 +coverage==5.2.1 +dataclasses==0.6 # via black decorator==4.4.2 # via ipython, traitlets -distlib==0.3.0 # via virtualenv +distlib==0.3.1 # via virtualenv django-braces==1.14.0 # via django-model-reviews django-contrib-comments==1.9.2 # via django-model-reviews -django-crispy-forms==1.9.1 +django-crispy-forms==1.9.2 django-js-asset==1.2.2 # via django-mptt django-model-reviews==1.0.2 django-mptt==0.11.0 -django-phonenumber-field==4.0.0 +django-phonenumber-field==5.0.0 django-private-storage==2.2.2 -django==3.0.7 # via django-braces, django-contrib-comments, django-model-reviews, django-mptt, django-phonenumber-field, djangorestframework, model-mommy -djangorestframework==3.11.0 +django==3.1.1 # via django-braces, django-contrib-comments, django-model-reviews, django-mptt, django-phonenumber-field, djangorestframework, model-mommy +djangorestframework==3.11.1 fastdiff==0.2.0 # via snapshottest filelock==3.0.12 # via tox, virtualenv flake8==3.8.3 freezegun==0.3.15 -identify==1.4.20 # via pre-commit -importlib-metadata==1.6.1 # via flake8, importlib-resources, pluggy, pre-commit, tox, virtualenv -importlib-resources==2.0.1 # via pre-commit, virtualenv +identify==1.4.30 # via pre-commit +importlib-metadata==1.7.0 # via flake8, pluggy, pre-commit, tox, virtualenv +importlib-resources==3.0.0 # via pre-commit, virtualenv ipdb==0.13.3 ipython-genutils==0.2.0 # via traitlets -ipython==7.15.0 # via ipdb -isort==4.3.21 -jedi==0.17.1 # via ipython +ipython==7.16.1 # via ipdb +isort==5.4.2 +jedi==0.17.2 # via ipython lazy-object-proxy==1.4.3 # via astroid mccabe==0.6.1 # via flake8, pylint model-mommy==2.0.0 -mypy-extensions==0.4.3 # via mypy +mypy-extensions==0.4.3 # via black, mypy mypy==0.782 -nodeenv==1.4.0 # via pre-commit +nodeenv==1.5.0 # via pre-commit packaging==20.4 # via tox -parso==0.7.0 # via jedi +parso==0.7.1 # via jedi pathspec==0.8.0 # via black pep8==1.7.1 pexpect==4.8.0 # via ipython -phonenumberslite==8.12.6 +phonenumberslite==8.12.9 pickleshare==0.7.5 # via ipython -pillow==7.1.2 +pillow==7.2.0 pluggy==0.13.1 # via tox -pre-commit==2.5.1 -prompt-toolkit==3.0.5 # via ipython +pre-commit==2.7.1 +prompt-toolkit==3.0.7 # via ipython psycopg2-binary==2.8.5 ptyprocess==0.6.0 # via pexpect -py==1.8.2 # via tox +py==1.9.0 # via tox pycodestyle==2.6.0 -pydocstyle==5.0.2 +pydocstyle==5.1.1 pyflakes==2.2.0 # via flake8 pygments==2.6.1 # via ipython -pylint-django==2.0.15 +pylint-django==2.3.0 pylint-plugin-utils==0.6 # via pylint-django -pylint==2.5.3 +pylint==2.6.0 pyparsing==2.4.7 # via packaging python-dateutil==2.8.1 # via freezegun -pytz==2020.1 # via babel, django +pytz==2020.1 # via django pyyaml==5.3.1 # via pre-commit -regex==2020.6.8 # via black +regex==2020.7.14 # via black six==1.15.0 # via astroid, django-braces, django-contrib-comments, freezegun, packaging, python-dateutil, snapshottest, tox, traitlets, virtualenv snapshottest==0.5.1 snowballstemmer==2.0.0 # via pydocstyle sorl-thumbnail==12.6.3 sqlparse==0.3.1 # via django -tblib==1.6.0 +tblib==1.7.0 termcolor==1.1.0 # via snapshottest toml==0.10.1 # via autopep8, black, pre-commit, pylint, tox -tox==3.15.2 +tox==3.20.0 traitlets==4.3.3 # via ipython typed-ast==1.4.1 # via astroid, black, mypy -typing-extensions==3.7.4.2 # via mypy -virtualenv==20.0.25 # via pre-commit, tox +typing-extensions==3.7.4.3 # via black, mypy +virtualenv==20.0.31 # via pre-commit, tox voluptuous==0.11.7 wasmer==0.4.1 # via fastdiff wcwidth==0.2.5 # via prompt-toolkit diff --git a/small_small_hr/__init__.py b/small_small_hr/__init__.py index aff864e..0f22369 100644 --- a/small_small_hr/__init__.py +++ b/small_small_hr/__init__.py @@ -1,5 +1,5 @@ """Main init file for small_small_hr.""" -VERSION = (0, 2, 1) +VERSION = (0, 2, 2) __version__ = ".".join(str(v) for v in VERSION) # pylint: disable=invalid-name default_app_config = "small_small_hr.apps.SmallSmallHrConfig" # noqa diff --git a/small_small_hr/forms.py b/small_small_hr/forms.py index 2ba0dfe..93b6837 100644 --- a/small_small_hr/forms.py +++ b/small_small_hr/forms.py @@ -3,7 +3,7 @@ from django import forms from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # pylint: disable = imported-auth-user from django.db.models import Q from django.utils.translation import ugettext as _ @@ -526,6 +526,7 @@ class Meta: # pylint: disable=too-few-public-methods "emergency_contact_name", "emergency_contact_number", "emergency_contact_relationship", + "supervisor", ] def __init__(self, *args, **kwargs): @@ -544,6 +545,7 @@ def __init__(self, *args, **kwargs): self.helper.layout = Layout( Field("first_name",), Field("last_name",), + Field("supervisor",), Field("image",), Field("phone",), Field("id_number",), @@ -660,6 +662,7 @@ class Meta: # pylint: disable=too-few-public-methods "user", "first_name", "last_name", + "supervisor", "id_number", "image", "phone", @@ -697,6 +700,7 @@ def __init__(self, *args, **kwargs): Field("user",), Field("first_name",), Field("last_name",), + Field("supervisor",), Field("image",), Field("phone",), Field("id_number",), diff --git a/small_small_hr/models.py b/small_small_hr/models.py index 17fbade..3e97c25 100644 --- a/small_small_hr/models.py +++ b/small_small_hr/models.py @@ -507,7 +507,7 @@ def get_days(start: object, end: object): yield local_start.date() + timedelta(days=i) -def get_taken_leave_days( # pylint: disable=bad-continuation +def get_taken_leave_days( staffprofile: object, status: str, leave_type: str, start_year: int, end_year: int ): """ diff --git a/small_small_hr/reviews.py b/small_small_hr/reviews.py index c4e2f70..e83d549 100644 --- a/small_small_hr/reviews.py +++ b/small_small_hr/reviews.py @@ -1,6 +1,6 @@ """Review module for small-small-hr.""" from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # pylint: disable = imported-auth-user from django.db import models from model_reviews.models import Reviewer diff --git a/small_small_hr/serializers.py b/small_small_hr/serializers.py index 470036d..84b5cc6 100644 --- a/small_small_hr/serializers.py +++ b/small_small_hr/serializers.py @@ -1,7 +1,7 @@ """ Serializers for users app """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User # pylint: disable = imported-auth-user from rest_framework import serializers @@ -18,16 +18,18 @@ class Meta: # pylint: disable=too-few-public-methods """ meta options """ + model = User - fields = ('username', 'first_name', 'last_name', 'email') + fields = ("username", "first_name", "last_name", "email") class StaffProfileSerializer(serializers.ModelSerializer): """ Serializer class for StaffProfile model """ - first_name = serializers.CharField(source='user.first_name') - last_name = serializers.CharField(source='user.last_name') + + first_name = serializers.CharField(source="user.first_name") + last_name = serializers.CharField(source="user.last_name") id_number = serializers.SerializerMethodField() phone = serializers.SerializerMethodField() sex = serializers.SerializerMethodField() @@ -49,123 +51,124 @@ class Meta: # pylint: disable=too-few-public-methods """ class meta options """ + model = StaffProfile fields = [ - 'id', - 'first_name', - 'last_name', - 'created', - 'id_number', - 'phone', - 'sex', - 'modified', - 'role', - 'nhif', - 'emergency_contact_name', - 'nssf', - 'address', - 'birthday', - 'overtime_allowed', - 'leave_days', - 'start_date', - 'sick_days', - 'pin_number', - 'end_date', - 'emergency_contact_number', + "id", + "first_name", + "last_name", + "created", + "id_number", + "phone", + "sex", + "modified", + "role", + "nhif", + "emergency_contact_name", + "nssf", + "address", + "birthday", + "overtime_allowed", + "leave_days", + "start_date", + "sick_days", + "pin_number", + "end_date", + "emergency_contact_number", ] def get_id_number(self, obj): # pylint: disable=no-self-use """ Get id_number """ - return obj.data.get('id_number') + return obj.data.get("id_number") def get_phone(self, obj): # pylint: disable=no-self-use """ Get phone """ - return obj.data.get('phone') + return obj.data.get("phone") def get_sex(self, obj): # pylint: disable=no-self-use """ Get sex """ - return obj.data.get('sex') + return obj.data.get("sex") def get_role(self, obj): # pylint: disable=no-self-use """ Get role """ - return obj.data.get('role') + return obj.data.get("role") def get_nhif(self, obj): # pylint: disable=no-self-use """ Get nhhf """ - return obj.data.get('nhif') + return obj.data.get("nhif") def get_nssf(self, obj): # pylint: disable=no-self-use """ Get nssf """ - return obj.data.get('nssf') + return obj.data.get("nssf") def get_pin_number(self, obj): # pylint: disable=no-self-use """ Get pin_number """ - return obj.data.get('pin_number') + return obj.data.get("pin_number") def get_address(self, obj): # pylint: disable=no-self-use """ Get address """ - return obj.data.get('address') + return obj.data.get("address") def get_birthday(self, obj): # pylint: disable=no-self-use """ Get birthday """ - return obj.data.get('birthday') + return obj.data.get("birthday") def get_leave_days(self, obj): # pylint: disable=no-self-use """ Get leave_days """ - return obj.data.get('leave_days') + return obj.data.get("leave_days") def get_sick_days(self, obj): # pylint: disable=no-self-use """ Get sick_days """ - return obj.data.get('sick_days') + return obj.data.get("sick_days") def get_overtime_allowed(self, obj): # pylint: disable=no-self-use """ Get overtime_allowed """ - return obj.data.get('overtime_allowed') + return obj.data.get("overtime_allowed") def get_start_date(self, obj): # pylint: disable=no-self-use """ Get start_date """ - return obj.data.get('start_date') + return obj.data.get("start_date") def get_end_date(self, obj): # pylint: disable=no-self-use """ Get end_date """ - return obj.data.get('end_date') + return obj.data.get("end_date") def get_emergency_contact_name(self, obj): # pylint: disable=no-self-use """ Get emergency_contact_name """ - return obj.data.get('emergency_contact_name') + return obj.data.get("emergency_contact_name") def get_emergency_contact_number(self, obj): # pylint: disable=no-self-use """ Get emergency_contact_number """ - return obj.data.get('emergency_contact_number') + return obj.data.get("emergency_contact_number") diff --git a/small_small_hr/templates/small_small_hr/email/leave_application_email_body.html b/small_small_hr/templates/small_small_hr/email/leave_application_email_body.html index 2dd511d..c4ce072 100644 --- a/small_small_hr/templates/small_small_hr/email/leave_application_email_body.html +++ b/small_small_hr/templates/small_small_hr/email/leave_application_email_body.html @@ -2,7 +2,7 @@ {{ object.content_object.duration.days }} days of {{ object.content_object.get_leave_type_display}}
{{ object.content_object.start|date:"D, d M Y" }} - {{ object.content_object.end|date:"D, d M Y" }}
Available Balance: {{ object.content_object.staff.get_available_leave_days|floatformat:2 }} days

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

Thank you,
{{SITE.name}}
diff --git a/small_small_hr/templates/small_small_hr/email/leave_application_email_body.txt b/small_small_hr/templates/small_small_hr/email/leave_application_email_body.txt index ec10080..c1f3028 100644 --- a/small_small_hr/templates/small_small_hr/email/leave_application_email_body.txt +++ b/small_small_hr/templates/small_small_hr/email/leave_application_email_body.txt @@ -4,7 +4,7 @@ {{ object.content_object.start|date:"D, d M Y" }} - {{ object.content_object.end|date:"D, d M Y" }} Available Balance: {{ object.content_object.staff.get_available_leave_days|floatformat:2 }} days -Please log in to process the above: http://{{SITE.name}}/reviews/{{ object.pk }} +Please log in to process the above: http://{{SITE.domain}}/reviews/{{ object.pk }} Thank you, diff --git a/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.html b/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.html index 6a9078b..c92c37d 100644 --- a/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.html +++ b/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.html @@ -1,7 +1,7 @@ {% load small_small_hr %}{{ object.content_object.staff.get_name }} requested overtime:

{{ object.content_object.duration|overtime_duration }} on {{ object.content_object.date|date:"D, d M Y" }}
{{ object.content_object.start|date:"P" }} - {{ object.content_object.end|date:"P" }}

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

Thank you,
{{SITE.name}}
diff --git a/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.txt b/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.txt index 6130123..d584395 100644 --- a/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.txt +++ b/small_small_hr/templates/small_small_hr/email/overtime_application_email_body.txt @@ -3,7 +3,7 @@ {{ object.content_object.duration|overtime_duration }} on {{ object.content_object.date|date:"D, d M Y" }} {{ object.content_object.start|date:"P" }} - {{ object.content_object.end|date:"P" }} -Please log in to process the above: http://{{SITE.name}}/reviews/{{ object.pk }} +Please log in to process the above: http://{{SITE.domain}}/reviews/{{ object.pk }} Thank you, diff --git a/tests/test_forms.py b/tests/test_forms.py index 819b81f..51d94eb 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -1190,6 +1190,9 @@ def test_staff_profile_admin_create_form(self): """Test StaffProfileAdminCreateForm.""" user = mommy.make("auth.User") + manager = mommy.make("auth.User", username="manager") + managerprofile = mommy.make("small_small_hr.StaffProfile", user=manager) + request = self.factory.get("/") request.session = {} request.user = AnonymousUser() @@ -1217,6 +1220,7 @@ def test_staff_profile_admin_create_form(self): "start_date": "2017-09-25", "end_date": "2018-12-31", "image": image_file, + "supervisor": managerprofile.pk, } file_dict = { @@ -1241,6 +1245,7 @@ def test_staff_profile_admin_create_form(self): self.assertEqual(21, staffprofile.leave_days) self.assertEqual(9, staffprofile.sick_days) self.assertEqual(True, staffprofile.overtime_allowed) + self.assertEqual(managerprofile, staffprofile.supervisor) self.assertEqual("This is the address.", staffprofile.address) self.assertEqual("1996-01-27", str(staffprofile.birthday)) @@ -1261,6 +1266,9 @@ def test_staff_profile_admin_create_form(self): def test_staff_profile_admin_form(self): """Test StaffProfileAdminForm.""" + manager = mommy.make("auth.User", username="manager") + managerprofile = mommy.make("small_small_hr.StaffProfile", user=manager) + user = mommy.make("auth.User") staffprofile = mommy.make("small_small_hr.StaffProfile", user=user) @@ -1291,6 +1299,7 @@ def test_staff_profile_admin_form(self): "start_date": "2017-09-25", "end_date": "2018-12-31", "image": image_file, + "supervisor": managerprofile.pk, } file_dict = { @@ -1315,6 +1324,7 @@ def test_staff_profile_admin_form(self): self.assertEqual(21, staffprofile.leave_days) self.assertEqual(9, staffprofile.sick_days) self.assertEqual(True, staffprofile.overtime_allowed) + self.assertEqual(managerprofile, staffprofile.supervisor) self.assertEqual("This is the address.", staffprofile.address) self.assertEqual("1996-01-27", str(staffprofile.birthday))