Skip to content

Commit

Permalink
Merge pull request #38 from moshthepitt/supervisorinforms
Browse files Browse the repository at this point in the history
Add support for supervisor in forms
  • Loading branch information
moshthepitt committed Sep 2, 2020
2 parents e3db9ee + 6ed6b80 commit 22c103c
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 83 deletions.
67 changes: 33 additions & 34 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion small_small_hr/__init__.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion small_small_hr/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _

Expand Down Expand Up @@ -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):
Expand All @@ -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",),
Expand Down Expand Up @@ -660,6 +662,7 @@ class Meta: # pylint: disable=too-few-public-methods
"user",
"first_name",
"last_name",
"supervisor",
"id_number",
"image",
"phone",
Expand Down Expand Up @@ -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",),
Expand Down
2 changes: 1 addition & 1 deletion small_small_hr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
"""
Expand Down
2 changes: 1 addition & 1 deletion small_small_hr/reviews.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
85 changes: 44 additions & 41 deletions small_small_hr/serializers.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
Expand All @@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ object.content_object.duration.days }} days of {{ object.content_object.get_leave_type_display}}<br />
{{ object.content_object.start|date:"D, d M Y" }} - {{ object.content_object.end|date:"D, d M Y" }}<br />
Available Balance: {{ object.content_object.staff.get_available_leave_days|floatformat:2 }} days<br /><br />
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 }}
<br/><br/>
Thank you,<br/>
{{SITE.name}}<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit 22c103c

Please sign in to comment.