This is a temporary repository to showcase the solution for the programming tasks explained below:
-
Create the Django polls app with Django version 2.2 or later, Python 3.7 or later and PostgreSQL version 11.0 or later as database system
- Completed! -> open localhost:8000/polls in browser after running the docker image as instructions given below.
-
Implement a Django command for importing thousands of polls at a time from a source of your choice (e.g. CSV)
-
2.1 Validate the functionality of your command by implementing unit and/or integration tests
-
Completed! -> Please see tests/test_commands.py for details. You can run tests inside docker container. See details in docker section below.
-
-
Add an IP address field to the author model and implement a custom lookup field for IsContainedByOrEqual using PostgreSQL inet operators
- Completed! -> I've implemented django-netfields and I've written a test to show how it can be used. Please see tests/test_lookups.py for details
-
Implement a password protected healthcheck endpoint covering:
-
- Django app is up and running and not in dev mode
-
- Database is accessible and can be queried
-
- App server has disk space left
-
Completed! -> I've implemented watchman for monitoring the health of databases, caches and default file storage.
-
You have to be a logged-in staff user to display the page for system status at:
{website}/watchman/dashboard/
-
Adjust the Django admin panel for the Author model that IP addresses are displayed but the last 8 bits are masked with asterisk
- Completed! -> last 8 bits of IP addresses are encrypted with using regex in a custom method for django admin list display field.
-
Provide a brief concept of how you would provide a redundant setup of the above Django app. (at least one App/DB server at a time can fail) in any form you prefer (e.g. Text, Diagram, Presentation, Dockerfiles etc.)
- Completed! -> I've used containerization with Docker. Please see build instructions below to test the functionality of the app.
- Describe briefly how you would build and distribute this app for a Debian based server infrastructure
- Clone the repo
git clone https://github.com/talented/Django-Polls-App-Extended.git
- Run
cd django-polls-app-extended
docker-compose build
docker-compose up
- Without stopping the running server open a new tab in your terminal, get into the same directory and run command below to run tests
docker-compose run app sh -c "python manage.py test"
- In order to populate the database for testing purposes with a few poll questions with author information, run commands below to get into the running container and run command to import data from given csv file
docker exec -it django-polls-app-extended_app_1 sh
python manage.py import_from_csv /pgdata/polls.csv
- You have to create a superuser to see the admin backend functionality. Run command below inside the docker container to create an admin user
python manage.py createsuperuser