- This project was built using python 2.7.13.
- The packages in the requirements.txt file should be installed.
pip install -r requirements.txt
-
As this is a mini application, SQLite Database was used.
-
open a terminal and clone the repository as follows:
git clone https://github.com/popsonebz/tangent_leave_app_solution.git
This creates a folder called tangent_leave_app_solution in the current directory.
- switch to that directory
cd tangent_leave_app_solution
- To create the database and tables, run the migration command
python manage.py migrate
- We can now startup the server
python manage.py runserver localhost:8010
First of all, we need to add employees to the system
http://localhost:8010/admin/add-employee/
Note:
- By default, all employees have 18 days of leave.
- This page was just added based on initiative as it was not specified in the task.
- To apply for leave, the employee visits this url
http://localhost:8010/leave/apply
-
He/She is redirected to the login page for authentication
-
If Authentication is successful, the application page is displayed.
-
On selecting the start and end dates, the following are checked:
- Both either start or end date or end date cannot be less than the current date.
- The end date cannot be less than the start date.
- Start date cannot later than end date.
- End date cannot be the same as start date.
- Notify the user when there is no working days within the specified period.
- Preventing duration which exceeds the maximum 18 days of leave allocated.
- Employees who have not spent up to 3 months in the company from appying for leave.
- Employee who has exhausted his leave.
- Employee taking more than the remaining leave days he has.
Note: To use the functional test, the following needs to be done:
-
Chrome webdriver needs to be downloaden and placed into the folder path (tanget_leave_app_solution/leave/)
-
The webdriver path needs to be set accordingly as seen in leave/test.py (the current path only works on my laptop).
-
Open the link http://localhost:8010/admin/add-employee/
-
Create the following users:
first name = kate, last name = perry, employment date = 01/01/2017, username = kate, password= kate
first name = ben, last name = carson, employment date = 29/05/2017, username = ben, password= ben
- Then run the command:
python manage.py test
The system carry's over a maximum of 5 days leave.
This is done in the management command defined in leave/management/commands/carry_leave_over_the_year.py
The operation can be carried out in 2 ways:
- Manually at the end of the year
python manage.py carry_leave_over_the_year
- Automatically by creating a linux crontab job which executes once a day to check if its the last day of the year.
if the condition is met, the command in option 1 will be executed.