Django Coding Test

The purpose of this coding test is to evaluate your skills using Python and the Django web framework.

The Problem

Luizalabs' team is growing every month and now we need to have some application to manage employees' information, such as name, e-mail and department. As any application written at Luizalabs, it must have an API to allow integrations.

Deliverables

"Luizalabs Employee Manager" app must have:

  • A Django Admin panel to manage employees' data
  • An API to list, add and remove employees

API example (list)

Request

curl -H "Content-Type: application/javascript" http://localhost:8000/employee/

Response

[
    {
        "name": "Arnaldo Pereira",
        "email": "arnaldo@luizalabs.com",
        "departament": "Architecture"
    },
    {
        "name": "Renato Pedigoni",
        "email": "renato@luizalabs.com",
        "departament": "E-commerce"
    },
    {
        "name": "Thiago Catoto",
        "email": "catoto@luizalabs.com",
        "departament": "Mobile"
    }
]

Usage

Clone the repository and create a virtualenv

$ git clone https://github.com/rodolphopivetta/luizalabs.git
$ cd luizalabs
$ virtualenv .venv

Active virtualenv and install all dependencies

$ source .venv/bin/activate
$ pip install -r requirements.txt

Migrate and create a superuser to access admin pages

$ python manage.py migrate
$ python manage.py createsuperuser

Perform tests

$ python manage.py test

Start the server

$ python manage.py runserver

Create an employee by curl

$ curl -H "Content-Type: application/json" -X POST -d '{"name":"Arnaldo Pereira", "email":"arnaldo@luizalabs.com", "departament": "Architecture"}' http://localhost:8000/employee/

Update an employee by curl

URL format: http://localhost:8000/employee/id/

$ curl -H "Content-Type: application/json" -X PUT -d '{"name":"Arnaldo Pereira", "email":"arnaldo@luizalabs.com", "departament": "Mobile"}' http://localhost:8000/employee/1/

Retrieve an employee by curl

URL format: http://localhost:8000/employee/id/

$ curl -H "Content-Type: application/json" http://localhost:8000/employee/1/

List employees by curl

This endpoint is paginated with 10 elements per page, so ?page=2 can be used.

$ curl -H "Content-Type: application/json" http://localhost:8000/employee/
$ curl -H "Content-Type: application/json" http://localhost:8000/employee/?page=2

Delete an employee by curl

URL format: http://localhost:8000/employee/id/

$ curl -X DELETE http://localhost:8000/employee/1/

Admin page to manage employees: http://localhost:8000/admin/employee/employee/