From d240fd609f3d64781e699cb43f259a8395911be1 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 17:49:33 +0300 Subject: [PATCH 01/19] Add sorl-thumbnail --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9d3e63b..338d81a 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,8 @@ 'phonenumberslite', 'django-phonenumber-field', 'django-crispy-forms', - 'djangorestframework' + 'djangorestframework', + 'sorl-thumbnail', ], classifiers=[ 'Programming Language :: Python', From d5e9d81bca2eeca099f9328ea9b94c16d2d9730c Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 17:50:07 +0300 Subject: [PATCH 02/19] Update packages --- Pipfile.lock | 126 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 90 insertions(+), 36 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index a955118..e49222b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -25,10 +25,10 @@ }, "django": { "hashes": [ - "sha256:3eb25c99df1523446ec2dc1b00e25eb2ecbdf42c9d8b0b8b32a204a8db9011f8", - "sha256:69ff89fa3c3a8337015478a1a0744f52a9fef5d12c1efa01a01f99bcce9bf10c" + "sha256:97886b8a13bbc33bfeba2ff133035d3eca014e2309dff2b6da0bdfc0b8656613", + "sha256:e900b73beee8977c7b887d90c6c57d68af10066b9dac898e1eaf0f82313de334" ], - "version": "==2.0.6" + "version": "==2.0.7" }, "django-crispy-forms": { "hashes": [ @@ -63,10 +63,10 @@ }, "phonenumberslite": { "hashes": [ - "sha256:0054c94d53e7b12cfb95290118cb5108b04270d8fd62851a06a474aad7b1b8d0", - "sha256:76d44fd38ec9aec918f65d02b0f18ca4d429f2771d4d3ab8405537b4b35a1005" + "sha256:1ccb25d6656bbcc0df52bac2ffc2558c54532657797ae4ce37396757ab4f1fff", + "sha256:3a9a3e68be823d22b3ed284ae984222d7f8bf6682ad37b35c658c2cf36ca12eb" ], - "version": "==8.9.8" + "version": "==8.9.10" }, "psycopg2-binary": { "hashes": [ @@ -84,8 +84,11 @@ "sha256:5221f5a3f4ca2ddf0d58e8b8a32ca50948be9a43351fda797eb4e72d7a7aa34d", "sha256:5c6ca0b507540a11eaf9e77dee4f07c131c2ec80ca0cffa146671bf690bc1c02", "sha256:789bd89d71d704db2b3d5e67d6d518b158985d791d3b2dec5ab85457cfc9677b", + "sha256:7b94d29239efeaa6a967f3b5971bd0518d2a24edd1511edbf4a2c8b815220d07", "sha256:89bc65ef3301c74cf32db25334421ea6adbe8f65601ea45dcaaf095abed910bb", + "sha256:89d6d3a549f405c20c9ae4dc94d7ed2de2fa77427a470674490a622070732e62", "sha256:97521704ac7127d7d8ba22877da3c7bf4a40366587d238ec679ff38e33177498", + "sha256:a395b62d5f44ff6f633231abe568e2203b8fabf9797cd6386aa92497df912d9a", "sha256:a6d32c37f714c3f34158f3fa659f3a8f2658d5f53c4297d45579b9677cc4d852", "sha256:a89ee5c26f72f2d0d74b991ce49e42ddeb4ac0dc2d8c06a0f2770a1ab48f4fe0", "sha256:b4c8b0ef3608e59317bfc501df84a61e48b5445d45f24d0391a24802de5f2d84", @@ -102,10 +105,10 @@ }, "pytz": { "hashes": [ - "sha256:65ae0c8101309c45772196b21b74c46b2e5d11b6275c45d251b150d5da334555", - "sha256:c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749" + "sha256:a061aa0a9e06881eb8b3b2b43f05b9439d6583c206d0a6c340ff72a7b6669053", + "sha256:ffb9ef1de172603304d9d2819af6f5ece76f2e85ec10692a524dd876e72bf277" ], - "version": "==2018.4" + "version": "==2018.5" }, "sorl-thumbnail": { "hashes": [ @@ -125,10 +128,10 @@ "develop": { "astroid": { "hashes": [ - "sha256:0ef2bf9f07c3150929b25e8e61b5198c27b0dca195e156f0e4d5bdd89185ca1a", - "sha256:fc9b582dba0366e63540982c3944a9230cbc6f303641c51483fa547dcc22393a" + "sha256:0a0c484279a5f08c9bcedd6fa9b42e378866a7dcc695206b92d59dc9f2d9760d", + "sha256:218e36cf8d98a42f16214e8670819ce307fa707d1dcf7f9af84c7aede1febc7f" ], - "version": "==1.6.5" + "version": "==2.0.1" }, "autopep8": { "hashes": [ @@ -149,10 +152,13 @@ "sha256:03481e81d558d30d230bc12999e3edffe392d244349a90f4ef9b88425fac74ba", "sha256:0b136648de27201056c1869a6c0d4e23f464750fd9a9ba9750b8336a244429ed", "sha256:104ab3934abaf5be871a583541e8829d6c19ce7bde2923b2751e0d3ca44db60a", + "sha256:10a46017fef60e16694a30627319f38a2b9b52e90182dddb6e37dcdab0f4bf95", "sha256:15b111b6a0f46ee1a485414a52a7ad1d703bdf984e9ed3c288a4414d3871dcbd", "sha256:198626739a79b09fa0a2f06e083ffd12eb55449b5f8bfdbeed1df4910b2ca640", "sha256:1c383d2ef13ade2acc636556fd544dba6e14fa30755f26812f54300e401f98f2", + "sha256:23d341cdd4a0371820eb2b0bd6b88f5003a7438bbedb33688cd33b8eae59affd", "sha256:28b2191e7283f4f3568962e373b47ef7f0392993bb6660d079c62bd50fe9d162", + "sha256:2a5b73210bad5279ddb558d9a2bfedc7f4bf6ad7f3c988641d83c40293deaec1", "sha256:2eb564bbf7816a9d68dd3369a510be3327f1c618d2357fa6b1216994c2e3d508", "sha256:337ded681dd2ef9ca04ef5d93cfc87e52e09db2594c296b4a0a3662cb1b41249", "sha256:3a2184c6d797a125dca8367878d3b9a178b6fdd05fdc2d35d758c3006a1cd694", @@ -195,10 +201,10 @@ }, "django": { "hashes": [ - "sha256:3eb25c99df1523446ec2dc1b00e25eb2ecbdf42c9d8b0b8b32a204a8db9011f8", - "sha256:69ff89fa3c3a8337015478a1a0744f52a9fef5d12c1efa01a01f99bcce9bf10c" + "sha256:97886b8a13bbc33bfeba2ff133035d3eca014e2309dff2b6da0bdfc0b8656613", + "sha256:e900b73beee8977c7b887d90c6c57d68af10066b9dac898e1eaf0f82313de334" ], - "version": "==2.0.6" + "version": "==2.0.7" }, "flake8": { "hashes": [ @@ -240,10 +246,10 @@ }, "jedi": { "hashes": [ - "sha256:1972f694c6bc66a2fac8718299e2ab73011d653a6d8059790c3476d2353b99ad", - "sha256:5861f6dc0c16e024cbb0044999f9cf8013b292c05f287df06d3d991a87a4eb89" + "sha256:b409ed0f6913a701ed474a614a3bb46e6953639033e31f769ca7581da5bd1ec1", + "sha256:c254b135fb39ad76e78d4d8f92765ebc9bf92cbc76f49e97ade1d5f5121e1f6f" ], - "version": "==0.12.0" + "version": "==0.12.1" }, "lazy-object-proxy": { "hashes": [ @@ -294,12 +300,19 @@ "index": "pypi", "version": "==1.6.0" }, + "packaging": { + "hashes": [ + "sha256:e9215d2d2535d3ae866c3d6efc77d5b24a0192cce0ff20e42896cc0664f889c0", + "sha256:f019b770dd64e585a99714f1fd5e01c7a8f11b45635aa953fd41c689a657375b" + ], + "version": "==17.1" + }, "parso": { "hashes": [ - "sha256:cdef26e8adc10d589f3ec4eb444bd0a29f3f1eb6d72a4292ab8afcb9d68976a6", - "sha256:f0604a40b96e062b0fd99cf134cc2d5cdf66939d0902f8267d938b0d5b26707f" + "sha256:35704a43a3c113cce4de228ddb39aab374b8004f4f2407d070b6a2ca784ce8a2", + "sha256:895c63e93b94ac1e1690f5fdd40b65f07c8171e3e53cbd7793b5b96c0e0a7f24" ], - "version": "==0.2.1" + "version": "==0.3.1" }, "pep8": { "hashes": [ @@ -342,17 +355,17 @@ }, "ptyprocess": { "hashes": [ - "sha256:e64193f0047ad603b71f202332ab5527c5e52aa7c8b609704fc28c0dc20c4365", - "sha256:e8c43b5eee76b2083a9badde89fd1bbce6c8942d1045146e100b7b5e014f4f1a" + "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", + "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" ], - "version": "==0.5.2" + "version": "==0.6.0" }, "py": { "hashes": [ - "sha256:29c9fab495d7528e80ba1e343b958684f4ace687327e6f789a94bf3d1915f881", - "sha256:983f77f3331356039fdd792e9220b7b8ee1aa6bd2b25f567a963ff1de5a64f6a" + "sha256:3fd59af7435864e1a243790d322d763925431213b6b8529c6ca71081ace3bbf7", + "sha256:e31fb2767eb657cbde86c454f02e99cb846d3cd9d61b318525140214fdc0e98e" ], - "version": "==1.5.3" + "version": "==1.5.4" }, "pycodestyle": { "hashes": [ @@ -378,18 +391,30 @@ }, "pylint": { "hashes": [ - "sha256:a48070545c12430cfc4e865bf62f5ad367784765681b3db442d8230f0960aa3c", - "sha256:fff220bcb996b4f7e2b0f6812fd81507b72ca4d8c4d05daf2655c333800cb9b3" + "sha256:248a7b19138b22e6390cba71adc0cb03ac6dd75a25d3544f03ea1728fa20e8f4", + "sha256:9cd70527ef3b099543eeabeb5c80ff325d86b477aa2b3d49e264e12d12153bc8" ], "index": "pypi", - "version": "==1.9.2" + "version": "==2.0.0" + }, + "pyparsing": { + "hashes": [ + "sha256:0832bcf47acd283788593e7a0f542407bd9550a55a8a8435214a1960e04bcb04", + "sha256:281683241b25fe9b80ec9d66017485f6deff1af5cde372469134b56ca8447a07", + "sha256:8f1e18d3fd36c6795bb7e02a39fd05c611ffc2596c1e0d995d34d67630426c18", + "sha256:9e8143a3e15c13713506886badd96ca4b579a87fbdf49e550dbfc057d6cb218e", + "sha256:b8b3117ed9bdf45e14dcc89345ce638ec7e0e29b2b579fa1ecf32ce45ebac8a5", + "sha256:e4d45427c6e20a59bf4f88c639dcc03ce30d193112047f94012102f235853a58", + "sha256:fee43f17a9c4087e7ed1605bd6df994c6173c1e977d7ade7b651292fab2bd010" + ], + "version": "==2.2.0" }, "pytz": { "hashes": [ - "sha256:65ae0c8101309c45772196b21b74c46b2e5d11b6275c45d251b150d5da334555", - "sha256:c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749" + "sha256:a061aa0a9e06881eb8b3b2b43f05b9439d6583c206d0a6c340ff72a7b6669053", + "sha256:ffb9ef1de172603304d9d2819af6f5ece76f2e85ec10692a524dd876e72bf277" ], - "version": "==2018.4" + "version": "==2018.5" }, "simplegeneric": { "hashes": [ @@ -414,11 +439,11 @@ }, "tox": { "hashes": [ - "sha256:96efa09710a3daeeb845561ebbe1497641d9cef2ee0aea30db6969058b2bda2f", - "sha256:9ee7de958a43806402a38c0d2aa07fa8553f4d2c20a15b140e9f771c2afeade0" + "sha256:4df108a1fcc93a7ee4ac97e1a3a1fc3d41ddd22445d518976604e2ef05025280", + "sha256:9f0cbcc36e08c2c4ae90d02d3d1f9a62231f974bcbc1df85e8045946d8261059" ], "index": "pypi", - "version": "==3.0.0" + "version": "==3.1.2" }, "traitlets": { "hashes": [ @@ -427,6 +452,35 @@ ], "version": "==4.3.2" }, + "typed-ast": { + "hashes": [ + "sha256:0948004fa228ae071054f5208840a1e88747a357ec1101c17217bfe99b299d58", + "sha256:10703d3cec8dcd9eef5a630a04056bbc898abc19bac5691612acba7d1325b66d", + "sha256:1f6c4bd0bdc0f14246fd41262df7dfc018d65bb05f6e16390b7ea26ca454a291", + "sha256:25d8feefe27eb0303b73545416b13d108c6067b846b543738a25ff304824ed9a", + "sha256:29464a177d56e4e055b5f7b629935af7f49c196be47528cc94e0a7bf83fbc2b9", + "sha256:2e214b72168ea0275efd6c884b114ab42e316de3ffa125b267e732ed2abda892", + "sha256:3e0d5e48e3a23e9a4d1a9f698e32a542a4a288c871d33ed8df1b092a40f3a0f9", + "sha256:519425deca5c2b2bdac49f77b2c5625781abbaf9a809d727d3a5596b30bb4ded", + "sha256:57fe287f0cdd9ceaf69e7b71a2e94a24b5d268b35df251a88fef5cc241bf73aa", + "sha256:668d0cec391d9aed1c6a388b0d5b97cd22e6073eaa5fbaa6d2946603b4871efe", + "sha256:68ba70684990f59497680ff90d18e756a47bf4863c604098f10de9716b2c0bdd", + "sha256:6de012d2b166fe7a4cdf505eee3aaa12192f7ba365beeefaca4ec10e31241a85", + "sha256:79b91ebe5a28d349b6d0d323023350133e927b4de5b651a8aa2db69c761420c6", + "sha256:8550177fa5d4c1f09b5e5f524411c44633c80ec69b24e0e98906dd761941ca46", + "sha256:898f818399cafcdb93cbbe15fc83a33d05f18e29fb498ddc09b0214cdfc7cd51", + "sha256:94b091dc0f19291adcb279a108f5d38de2430411068b219f41b343c03b28fb1f", + "sha256:a26863198902cda15ab4503991e8cf1ca874219e0118cbf07c126bce7c4db129", + "sha256:a8034021801bc0440f2e027c354b4eafd95891b573e12ff0418dec385c76785c", + "sha256:bc978ac17468fe868ee589c795d06777f75496b1ed576d308002c8a5756fb9ea", + "sha256:c05b41bc1deade9f90ddc5d988fe506208019ebba9f2578c622516fd201f5863", + "sha256:c9b060bd1e5a26ab6e8267fd46fc9e02b54eb15fffb16d112d4c7b1c12987559", + "sha256:edb04bdd45bfd76c8292c4d9654568efaedf76fe78eb246dde69bdb13b2dad87", + "sha256:f19f2a4f547505fe9072e15f6f4ae714af51b5a681a97f187971f50c283193b6" + ], + "markers": "python_version < '3.7' and implementation_name == 'cpython'", + "version": "==1.1.0" + }, "virtualenv": { "hashes": [ "sha256:2ce32cd126117ce2c539f0134eb89de91a8413a29baac49cbab3eb50e2026669", From e7211d6f4a8c5ba1ded5efc02c5ce690cdcd6596 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 17:58:43 +0300 Subject: [PATCH 03/19] Pylint cleanup --- small_small_hr/models.py | 21 ++++++++++----------- small_small_hr/serializers.py | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/small_small_hr/models.py b/small_small_hr/models.py index 5069def..65db3c5 100644 --- a/small_small_hr/models.py +++ b/small_small_hr/models.py @@ -33,7 +33,7 @@ class TimeStampedModel(models.Model): auto_now=True) # pylint: disable=too-few-public-methods - class Meta(object): + class Meta: """ Meta options for TimeStampedModel """ @@ -47,7 +47,7 @@ class Role(TimeStampedModel, models.Model): name = models.CharField(_('Name'), max_length=255) description = models.TextField(_('Description'), blank=True, default='') - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for StaffDocument """ @@ -108,7 +108,7 @@ class StaffProfile(TimeStampedModel, models.Model): help_text=_('The end date of employment')) data = JSONField(_('Data'), default=dict, blank=True) - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for StaffProfile """ @@ -186,7 +186,7 @@ def get_available_sick_days(self, year: int = datetime.today().year): return leave_record.get_available_leave_days() def __str__(self): - return self.get_name() + return self.get_name() # pylint: disable=no-member class StaffDocument(TimeStampedModel, models.Model): @@ -210,7 +210,7 @@ class StaffDocument(TimeStampedModel, models.Model): max_file_size=1048576 ) - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for StaffDocument """ @@ -248,7 +248,7 @@ class BaseStaffRequest(TimeStampedModel, models.Model): blank=True, db_index=True) comments = models.TextField(_('Comments'), blank=True, default='') - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for StaffDocument """ @@ -273,7 +273,7 @@ class Leave(BaseStaffRequest): objects = LeaveManager() - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for Leave """ @@ -296,7 +296,7 @@ class OverTime(BaseStaffRequest): start = models.TimeField(_('Start'), auto_now=False, auto_now_add=False) end = models.TimeField(_('End'), auto_now=False, auto_now_add=False) - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for OverTime """ @@ -306,8 +306,7 @@ class Meta(object): # pylint: disable=too-few-public-methods ordering = ['staff', 'date', 'start'] def __str__(self): - # pylint: disable=no-member - name = self.staff.get_name() + name = self.staff.get_name() # pylint: disable=no-member return _(f'{name}: {self.date} from {self.start} to {self.end}') def get_duration(self): @@ -344,7 +343,7 @@ class AnnualLeave(TimeStampedModel, models.Model): _('Carried Over Leave days'), default=0, blank=True, help_text=_('Number of leave days carried over into this year.')) - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ Meta options for AnnualLeave """ diff --git a/small_small_hr/serializers.py b/small_small_hr/serializers.py index 91e46c1..470036d 100644 --- a/small_small_hr/serializers.py +++ b/small_small_hr/serializers.py @@ -14,7 +14,7 @@ class UserSerializer(serializers.ModelSerializer): UserSerializer class """ - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ meta options """ @@ -45,7 +45,7 @@ class StaffProfileSerializer(serializers.ModelSerializer): emergency_contact_name = serializers.SerializerMethodField() emergency_contact_number = serializers.SerializerMethodField() - class Meta(object): # pylint: disable=too-few-public-methods + class Meta: # pylint: disable=too-few-public-methods """ class meta options """ From 664ffb759289cd5fc12f2db0ef62c2bd43ff5cd7 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 18:44:02 +0300 Subject: [PATCH 04/19] Install pillow --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 338d81a..8de8e0e 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,7 @@ 'django-crispy-forms', 'djangorestframework', 'sorl-thumbnail', + 'Pillow' ], classifiers=[ 'Programming Language :: Python', From f697d9a569a715fd9a53895677f87e4c61a42d2b Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 18:44:22 +0300 Subject: [PATCH 05/19] Add staff image --- small_small_hr/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/small_small_hr/models.py b/small_small_hr/models.py index 65db3c5..2ca8653 100644 --- a/small_small_hr/models.py +++ b/small_small_hr/models.py @@ -7,13 +7,14 @@ from django.conf import settings from django.contrib.postgres.fields import JSONField from django.db import models -from django.db.models import Value as V from django.db.models import Sum +from django.db.models import Value as V from django.db.models.functions import Coalesce from django.utils.translation import ugettext as _ from phonenumber_field.modelfields import PhoneNumberField from private_storage.fields import PrivateFileField +from sorl.thumbnail import ImageField from small_small_hr.managers import LeaveManager @@ -83,6 +84,9 @@ class StaffProfile(TimeStampedModel, models.Model): user = models.OneToOneField( USER, verbose_name=_('User'), on_delete=models.CASCADE) + image = ImageField(upload_to="staff-images/", max_length=255, + verbose_name=_("Profile Image"), + help_text=_("A square image works best"), blank=True) sex = models.CharField(_('Gender'), choices=SEX_CHOICES, max_length=1, default=NOT_KNOWN, blank=True, db_index=True) role = models.ForeignKey(Role, verbose_name=_('Role'), blank=True, @@ -199,7 +203,7 @@ class StaffDocument(TimeStampedModel, models.Model): description = models.TextField(_('Description'), blank=True, default='') file = PrivateFileField( _('File'), upload_to='staff-documents/', - help_text=_("Upload staff member drocument"), + help_text=_("Upload staff member document"), content_types=[ 'application/pdf', 'application/msword', From e78917a7136f8ed0462aa8ff49d7872790ba33bc Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 18:44:42 +0300 Subject: [PATCH 06/19] Add migration file --- .../migrations/0002_auto_20180722_1808.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 small_small_hr/migrations/0002_auto_20180722_1808.py diff --git a/small_small_hr/migrations/0002_auto_20180722_1808.py b/small_small_hr/migrations/0002_auto_20180722_1808.py new file mode 100644 index 0000000..4b30bc6 --- /dev/null +++ b/small_small_hr/migrations/0002_auto_20180722_1808.py @@ -0,0 +1,26 @@ +# Generated by Django 2.0.7 on 2018-07-22 15:08 + +from django.db import migrations +import private_storage.fields +import private_storage.storage.files +import sorl.thumbnail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('small_small_hr', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='staffprofile', + name='image', + field=sorl.thumbnail.fields.ImageField(blank=True, help_text='A square image works best', max_length=255, upload_to='staff-images/', verbose_name='Profile Image'), + ), + migrations.AlterField( + model_name='staffdocument', + name='file', + field=private_storage.fields.PrivateFileField(help_text='Upload staff member document', storage=private_storage.storage.files.PrivateFileSystemStorage(), upload_to='staff-documents/', verbose_name='File'), + ), + ] From 55300547d500e1cbf2ac7f387ff7dd7ccf5cb43a Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 18:44:55 +0300 Subject: [PATCH 07/19] Fix typo --- small_small_hr/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/small_small_hr/forms.py b/small_small_hr/forms.py index 6510743..d70e866 100644 --- a/small_small_hr/forms.py +++ b/small_small_hr/forms.py @@ -488,9 +488,9 @@ class StaffProfileAdminForm(forms.ModelForm): nssf = forms.CharField(label=_('NSSF'), required=False) pin_number = forms.CharField(label=_('PIN Number'), required=False) emergency_contact_name = forms.CharField( - label=_('Emergecy Contact Name'), required=False) + label=_('Emergency Contact Name'), required=False) emergency_contact_relationship = forms.CharField( - label=_('Emergecy Contact Relationship'), required=False) + label=_('Emergency Contact Relationship'), required=False) emergency_contact_number = PhoneNumberField( label=_('Emergency Contact Phone Number'), required=False) From f132f6e39573d556e4dbf4d61a6dadef847d73f6 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 18:45:12 +0300 Subject: [PATCH 08/19] Load pylint-django --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index e53f252..43d2e79 100644 --- a/.pylintrc +++ b/.pylintrc @@ -22,7 +22,7 @@ jobs=1 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +load-plugins=pylint_django # Pickle collected data for later comparisons. persistent=yes From 4999ac58c4127f43bdcf9b891f8cce5db6d96ed1 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 18:45:22 +0300 Subject: [PATCH 09/19] Update packages --- Pipfile | 1 + Pipfile.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 9c79c9d..39f12a2 100644 --- a/Pipfile +++ b/Pipfile @@ -22,3 +22,4 @@ ipdb = "*" model-mommy = "*" "autopep8" = "*" tblib = "*" +pylint-django = {git = "https://github.com/PyCQA/pylint-django.git", ref = "4316c3d90f4ac6cbbeddfc8d431f5d4e031d5cf1"} diff --git a/Pipfile.lock b/Pipfile.lock index e49222b..cb2fea1 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "9739adabea36485558a160338a4626eeb04b782817667901b2371cd3b9382714" + "sha256": "c25f51bef8cf481e4e932c92c300179c73bd1174db48bce3c11e092d2c6b5aac" }, "pipfile-spec": 6, "requires": { @@ -68,6 +68,61 @@ ], "version": "==8.9.10" }, + "pillow": { + "hashes": [ + "sha256:00def5b638994f888d1058e4d17c86dec8e1113c3741a0a8a659039aec59a83a", + "sha256:026449b64e559226cdb8e6d8c931b5965d8fc90ec18ebbb0baa04c5b36503c72", + "sha256:03dbb224ee196ef30ed2156d41b579143e1efeb422974719a5392fc035e4f574", + "sha256:03eb0e04f929c102ae24bc436bf1c0c60a4e63b07ebd388e84d8b219df3e6acd", + "sha256:087b0551ce2d19b3f092f2b5f071a065f7379e748867d070b29999cc83db15e3", + "sha256:091a0656688d85fd6e10f49a73fa3ab9b37dbfcb2151f5a3ab17f8b879f467ee", + "sha256:0f3e2d0a9966161b7dfd06d147f901d72c3a88ea1a833359b92193b8e1f68e1c", + "sha256:114398d0e073b93e1d7da5b5ab92ff4b83c0180625c8031911425e51f4365d2e", + "sha256:1be66b9a89e367e7d20d6cae419794997921fe105090fafd86ef39e20a3baab2", + "sha256:1c5e93c40d4ce8cb133d3b105a869be6fa767e703f6eb1003eb4b90583e08a59", + "sha256:1e977a3ed998a599bda5021fb2c2889060617627d3ae228297a529a082a3cd5c", + "sha256:22cf3406d135cfcc13ec6228ade774c8461e125c940e80455f500638429be273", + "sha256:24adccf1e834f82718c7fc8e3ec1093738da95144b8b1e44c99d5fc7d3e9c554", + "sha256:2a3e362c97a5e6a259ee9cd66553292a1f8928a5bdfa3622fdb1501570834612", + "sha256:3518f9fc666cbc58a5c1f48a6a23e9e6ceef69665eab43cdad5144de9383e72c", + "sha256:3709339f4619e8c9b00f53079e40b964f43c5af61fb89a923fe24437167298bb", + "sha256:3832e26ecbc9d8a500821e3a1d3765bda99d04ae29ffbb2efba49f5f788dc934", + "sha256:452d159024faf37cc080537df308e8fa0026076eb38eb75185d96ed9642bd6d7", + "sha256:4fd1f0c2dc02aaec729d91c92cd85a2df0289d88e9f68d1e8faba750bb9c4786", + "sha256:4fda62030f2c515b6e2e673c57caa55cb04026a81968f3128aae10fc28e5cc27", + "sha256:5044d75a68b49ce36a813c82d8201384207112d5d81643937fc758c05302f05b", + "sha256:522184556921512ec484cb93bd84e0bab915d0ac5a372d49571c241a7f73db62", + "sha256:5914cff11f3e920626da48e564be6818831713a3087586302444b9c70e8552d9", + "sha256:653d48fe46378f40e3c2b892be88d8440efbb2c9df78559da44c63ad5ecb4142", + "sha256:6661a7908d68c4a133e03dac8178287aa20a99f841ea90beeb98a233ae3fd710", + "sha256:6735a7e560df6f0deb78246a6fe056cf2ae392ba2dc060ea8a6f2535aec924f1", + "sha256:6d26a475a19cb294225738f5c974b3a24599438a67a30ed2d25638f012668026", + "sha256:791f07fe13937e65285f9ef30664ddf0e10a0230bdb236751fa0ca67725740dd", + "sha256:79258a8df3e309a54c7ef2ef4a59bb8e28f7e4a8992a3ad17c24b1889ced44f3", + "sha256:7d74c20b8f1c3e99d3f781d3b8ff5abfefdd7363d61e23bdeba9992ff32cc4b4", + "sha256:81918afeafc16ba5d9d0d4e9445905f21aac969a4ebb6f2bff4b9886da100f4b", + "sha256:8194d913ca1f459377c8a4ed8f9b7ad750068b8e0e3f3f9c6963fcc87a84515f", + "sha256:84d5d31200b11b3c76fab853b89ac898bf2d05c8b3da07c1fcc23feb06359d6e", + "sha256:989981db57abffb52026b114c9a1f114c7142860a6d30a352d28f8cbf186500b", + "sha256:a3d7511d3fad1618a82299aab71a5fceee5c015653a77ffea75ced9ef917e71a", + "sha256:a4a6ac01b8c2f9d2d83719f193e6dea493e18445ce5bfd743d739174daa974d9", + "sha256:acb90eb6c7ed6526551a78211d84c81e33082a35642ff5fe57489abc14e6bf6e", + "sha256:b3ef168d4d6fd4fa6685aef7c91400f59f7ab1c0da734541f7031699741fb23f", + "sha256:c1c5792b6e74bbf2af0f8e892272c2a6c48efa895903211f11b8342e03129fea", + "sha256:c5dcb5a56aebb8a8f2585042b2f5c496d7624f0bcfe248f0cc33ceb2fd8d39e7", + "sha256:d16f90810106822833a19bdb24c7cb766959acf791ca0edf5edfec674d55c8ee", + "sha256:dcdc9cd9880027688007ff8f7c8e7ae6f24e81fae33bfd18d1e691e7bda4855f", + "sha256:e2807aad4565d8de15391a9548f97818a14ef32624015c7bf3095171e314445e", + "sha256:e2bed4a04e2ca1050bb5f00865cf2f83c0b92fd62454d9244f690fcd842e27a4", + "sha256:e87a527c06319428007e8c30511e1f0ce035cb7f14bb4793b003ed532c3b9333", + "sha256:ebcfc33a6c34984086451e230253bc33727bd17b4cdc4b39ec03032c3a6fc9e9", + "sha256:f63e420180cbe22ff6e32558b612e75f50616fc111c5e095a4631946c782e109", + "sha256:f7717eb360d40e7598c30cc44b33d98f79c468d9279379b66c1e28c568e0bf47", + "sha256:f8582e1ab155302ea9ef1235441a0214919f4f79c4c7c21833ce9eec58181781", + "sha256:f8b3d413c5a8f84b12cd4c5df1d8e211777c9852c6be3ee9c094b626644d3eab" + ], + "version": "==5.2.0" + }, "psycopg2-binary": { "hashes": [ "sha256:04afb59bbbd2eab3148e6816beddc74348078b8c02a1113ea7f7822f5be4afe3", @@ -397,6 +452,10 @@ "index": "pypi", "version": "==2.0.0" }, + "pylint-django": { + "git": "https://github.com/PyCQA/pylint-django.git", + "ref": "4316c3d90f4ac6cbbeddfc8d431f5d4e031d5cf1" + }, "pyparsing": { "hashes": [ "sha256:0832bcf47acd283788593e7a0f542407bd9550a55a8a8435214a1960e04bcb04", From ff1dd2a93141f4799c20dc7aac701290f233634c Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 19:03:58 +0300 Subject: [PATCH 10/19] Add image to forms --- small_small_hr/forms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/small_small_hr/forms.py b/small_small_hr/forms.py index d70e866..b769acd 100644 --- a/small_small_hr/forms.py +++ b/small_small_hr/forms.py @@ -503,6 +503,7 @@ class Meta: # pylint: disable=too-few-public-methods 'first_name', 'last_name', 'id_number', + 'image', 'phone', 'sex', 'role', @@ -534,6 +535,7 @@ def __init__(self, *args, **kwargs): self.helper.layout = Layout( Field('first_name',), Field('last_name',), + Field('image',), Field('phone',), Field('id_number',), Field('sex',), @@ -652,6 +654,7 @@ class Meta: # pylint: disable=too-few-public-methods 'first_name', 'last_name', 'id_number', + 'image', 'phone', 'sex', 'role', @@ -684,6 +687,7 @@ def __init__(self, *args, **kwargs): Field('user',), Field('first_name',), Field('last_name',), + Field('image',), Field('phone',), Field('id_number',), Field('sex',), @@ -721,6 +725,7 @@ class Meta: # pylint: disable=too-few-public-methods 'first_name', 'last_name', 'id_number', + 'image', 'phone', 'sex', 'nhif', @@ -746,6 +751,7 @@ def __init__(self, *args, **kwargs): self.helper.layout = Layout( Field('first_name',), Field('last_name',), + Field('image',), Field('phone',), Field('id_number',), Field('sex',), From 443698c517c2a39225b11a5c67203ad026fa3db4 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Sun, 22 Jul 2018 19:04:34 +0300 Subject: [PATCH 11/19] Update tests --- tests/fixtures/profile.png | Bin 0 -> 3414 bytes tests/test_forms.py | 330 +++++++++++++++++++++---------------- 2 files changed, 188 insertions(+), 142 deletions(-) create mode 100644 tests/fixtures/profile.png diff --git a/tests/fixtures/profile.png b/tests/fixtures/profile.png new file mode 100644 index 0000000000000000000000000000000000000000..3489953a5e318796ce4de4910c110a2f19e090b7 GIT binary patch literal 3414 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 Date: Sun, 22 Jul 2018 19:05:30 +0300 Subject: [PATCH 12/19] Fix styling --- tests/test_forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_forms.py b/tests/test_forms.py index a3a8669..3101fd9 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -791,8 +791,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( + 'Father', staffprofile.data['emergency_contact_relationship']) self.assertEqual('+254722111111', staffprofile.data['emergency_contact_number']) From fd22292f086f4ef624f21611b2533d89d31620c4 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 19:39:36 +0300 Subject: [PATCH 13/19] format code --- .../migrations/0002_auto_20180722_1808.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/small_small_hr/migrations/0002_auto_20180722_1808.py b/small_small_hr/migrations/0002_auto_20180722_1808.py index 4b30bc6..3efed98 100644 --- a/small_small_hr/migrations/0002_auto_20180722_1808.py +++ b/small_small_hr/migrations/0002_auto_20180722_1808.py @@ -16,11 +16,21 @@ class Migration(migrations.Migration): migrations.AddField( model_name='staffprofile', name='image', - field=sorl.thumbnail.fields.ImageField(blank=True, help_text='A square image works best', max_length=255, upload_to='staff-images/', verbose_name='Profile Image'), + field=sorl.thumbnail.fields.ImageField( + blank=True, + help_text='A square image works best', + max_length=255, + upload_to='staff-images/', + verbose_name='Profile Image'), ), migrations.AlterField( model_name='staffdocument', name='file', - field=private_storage.fields.PrivateFileField(help_text='Upload staff member document', storage=private_storage.storage.files.PrivateFileSystemStorage(), upload_to='staff-documents/', verbose_name='File'), + field=private_storage.fields.PrivateFileField( + help_text='Upload staff member document', + storage=private_storage.storage.files.PrivateFileSystemStorage( + ), + upload_to='staff-documents/', + verbose_name='File'), ), ] From 6edacc2b81cd8548c5ffad087617f6508f6cb99c Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 19:39:59 +0300 Subject: [PATCH 14/19] Add public field to StaffDocument --- small_small_hr/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/small_small_hr/models.py b/small_small_hr/models.py index 2ca8653..4bb2f72 100644 --- a/small_small_hr/models.py +++ b/small_small_hr/models.py @@ -213,6 +213,10 @@ class StaffDocument(TimeStampedModel, models.Model): ], max_file_size=1048576 ) + public = models.BooleanField( + _('Public'), + help_text=_('If public, it will be available to everyone.'), + blank=True, default=False) class Meta: # pylint: disable=too-few-public-methods """ From 73b999cb23f5257a85f79a4d237332c28e3b727d Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 19:55:31 +0300 Subject: [PATCH 15/19] Add migration file --- .../migrations/0003_staffdocument_public.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 small_small_hr/migrations/0003_staffdocument_public.py diff --git a/small_small_hr/migrations/0003_staffdocument_public.py b/small_small_hr/migrations/0003_staffdocument_public.py new file mode 100644 index 0000000..8cc0c90 --- /dev/null +++ b/small_small_hr/migrations/0003_staffdocument_public.py @@ -0,0 +1,21 @@ +# Generated by Django 2.0.7 on 2018-07-25 16:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('small_small_hr', '0002_auto_20180722_1808'), + ] + + operations = [ + migrations.AddField( + model_name='staffdocument', + name='public', + field=models.BooleanField( + default=False, + help_text='If public, it will be available to everyone.', + verbose_name='Public'), + ), + ] From b4614a90f145e9ea2c265c1b64c4af72e2e1730f Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 19:56:47 +0300 Subject: [PATCH 16/19] Add media root --- tests/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/settings.py b/tests/settings.py index ea5c1fb..09dc701 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -40,6 +40,7 @@ SECRET_KEY = "i love oov" PRIVATE_STORAGE_ROOT = '/tmp/' +MEDIA_ROOT = '/tmp/' PRIVATE_STORAGE_AUTH_FUNCTION = 'private_storage.permissions.allow_staff' # try and load local_settings if present From cecb567247ef25cfd66fd387e4dcebf37dc06dfc Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 19:57:07 +0300 Subject: [PATCH 17/19] Add public field --- small_small_hr/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/small_small_hr/forms.py b/small_small_hr/forms.py index b769acd..a584120 100644 --- a/small_small_hr/forms.py +++ b/small_small_hr/forms.py @@ -406,6 +406,7 @@ class Meta: # pylint: disable=too-few-public-methods 'staff', 'name', 'description', + 'public', 'file', ] @@ -424,6 +425,7 @@ def __init__(self, *args, **kwargs): Field('name',), Field('description',), Field('file',), + Field('public',), FormActions( Submit('submitBtn', _('Submit'), css_class='btn-primary'), ) From 07398c01224ed84765b38b72a1c92c67fadbf61a Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 19:57:19 +0300 Subject: [PATCH 18/19] Add tests --- tests/test_forms.py | 52 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tests/test_forms.py b/tests/test_forms.py index 3101fd9..e1e3851 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -16,7 +16,8 @@ ApplyOverTimeForm, LeaveForm, OverTimeForm, RoleForm, StaffDocumentForm, StaffProfileAdminCreateForm, - StaffProfileAdminForm, StaffProfileUserForm) + StaffProfileAdminForm, StaffProfileUserForm, + UserStaffDocumentForm) from small_small_hr.models import Leave, OverTime, StaffProfile from small_small_hr.serializers import StaffProfileSerializer @@ -705,7 +706,8 @@ def test_staffdocumentform(self): 'staff': staffprofile.id, 'name': 'Employment Contract', 'description': 'This is the employment contract!', - 'file': contract_file + 'file': contract_file, + 'public': True } file_dict = { @@ -722,6 +724,52 @@ def test_staffdocumentform(self): self.assertEqual(staffprofile, doc.staff) self.assertEqual('Employment Contract', doc.name) + self.assertEqual(True, doc.public) + self.assertEqual( + 'This is the employment contract!', doc.description) + + with open(path, 'r+b') as contract_file: + self.assertTrue(contract_file.read(), doc.file.read()) + + @override_settings(PRIVATE_STORAGE_ROOT='/tmp/') + def test_userstaffdocumentform(self): + """ + Test UserStaffDocumentForm + """ + user = mommy.make('auth.User', first_name='Bob', last_name='Ndoe') + staffprofile = mommy.make('small_small_hr.StaffProfile', user=user) + + request = self.factory.get('/') + request.session = {} + request.user = user + + path = os.path.join( + BASE_DIR, 'tests', 'fixtures', 'contract.pdf') + + with open(path, 'r+b') as contract_file: + data = { + 'staff': staffprofile.id, + 'name': 'Employment Contract', + 'description': 'This is the employment contract!', + 'file': contract_file + } + + file_dict = { + 'file': SimpleUploadedFile( + name=contract_file.name, + content=contract_file.read(), + content_type='application/pdf' + )} + + form = UserStaffDocumentForm( + data=data, files=file_dict, request=request) + + self.assertTrue(form.is_valid()) + doc = form.save() + + self.assertEqual(staffprofile, doc.staff) + self.assertEqual('Employment Contract', doc.name) + self.assertEqual(False, doc.public) self.assertEqual( 'This is the employment contract!', doc.description) From 59f203c6f9396562da20f9ff7f4a034aee8902c3 Mon Sep 17 00:00:00 2001 From: Kelvin Jayanoris Date: Wed, 25 Jul 2018 20:31:46 +0300 Subject: [PATCH 19/19] tag v0.0.8 --- small_small_hr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/small_small_hr/__init__.py b/small_small_hr/__init__.py index 23b7d13..0b2778c 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, 0, 7) +VERSION = (0, 0, 8) __version__ = '.'.join(str(v) for v in VERSION)