Two solutions have been provided:
- RestAPI: Using the Django REST API Framework to allow create, retrieve, update, delete functionality
- Web: A Django views web interface that allows display of products, product detail and deletion. Uses bootstrap 5.
Poetry is used for managing dependencies and building a python source distribution and pure wheel.
Instructions for installing poetry are provided here
A Makefile has been provided to simplify setup and development.
- Download poetry, details are provided in the prerequisites section above
- Download data and create admin user:
make setup
- Create an admin user:
make createsuperuser
- Run Tests:
make test
- Run Server:
make run
In a browser try out the following webviews:
Swagger documentation for the Rest API solution can be found by visiting http://localhost:8000/api/schema/swagger-ui/ This documents the RestAPI endpoints for creating, fetching, updating and deleting products.
The following web views are available:
- Uses flake8 linter to enforce code style and reduce errors before commit.
- Uses black code and isort formatting tools to automate formatting of code, such as alphabetic ordering of imports etc.
- Uses pre-commit to install hooks to run linting and code formatting before local commits
- Uses bootstrap 5 to render templates for Django views
A docker-compose stack has been provided. To run in docker, issue the following command:
make up
This will build a docker image. On startup the docker container will create a default user of
admin
with a password of Pa55w0rd
. The .env-sample
file in the root folder contains configuration
variables for the docker environment. Rename this file to .env
for docker-compose to use
the environment variables to configure the containers.
DJANGO_DEBUG=True
DJANGO_EXT_PORT=5000
DJANGO_SECRET_KEY=Pa55w0rd
DJANGO_SUPERUSER_EMAIL=me@example.com
DJANGO_SUPERUSER_PASSWORD=Pa55w0rd
DJANGO_SUPERUSER_USERNAME=admin
NGINX_EXT_PORT=8000
Fork this project and send us a pull request
Write a simple python webservice that uses, manipuates and returns the data found here: https://www.unisport.dk/api/products/batch/.
/products/
should return the first 10 objects ordered with the cheapest first.
/products/?page=2
The products should be paginated where page in the url above should return the next 10 objects
/products/id/
should return the individual product.
Remember to test Remember to document (why, not how)
extend the service so the products can also be created, edited and deleted in a backend of choice.
You are welcome to use any thirdparty python web framework or library that you are familiar with.
Information on how to work with forks and pull requests can be found here https://help.github.com/categories/collaborating-with-issues-and-pull-requests/