Skip to content

Latest commit

 

History

History
45 lines (40 loc) · 1.84 KB

README.md

File metadata and controls

45 lines (40 loc) · 1.84 KB

Description

      Application for creating, retrieving, listing and deleting employees inside company.
      After creating employee will get email with login and password.
      Each employee with department HR will get staff status.

Installing

$ pip install -r requirments.txt  
$ python3 manage.py makemigrations  
$ python3 manage.py migrate  
$ python3 manage.py loaddata fixtures.json  
$ python3 manage.py runserver  

      It will create a database with following employees:

  • login: admin, password: admin123
  • login: HRUser, password: LDJ7LZ59
  • login: Buyer, password: CGP7RNGG

Endpoints

  • /api/employees/ GET list of employees
  • /api/employees/ POST create employee (staff only)
  • /api/employees/:id/ GET retrieve employee
  • /api/employees/:id/ PUT update employee (staff only)
  • /api/employees/:id/ PATCH partial update (owner only)
  • /api/employees/:id/ DELETE delete employee (staff only)

Usage with curl

      Create new employee with
           username "NewUser"
           rank "Senior
           department "Digital"
           email "[email protected]":

curl -u HRUser -d "username=NewUser&rank=S&department=DG&[email protected]" -X POST http://localhost:8000/api/employees/

      Get list of employees:

curl http://localhost:8000/api/employees/  

      Retrieve data of employee with id 3:

curl http://localhost:8000/api/employees/3/