Skip to content

An extended dockerized version of Django Polls application.

Notifications You must be signed in to change notification settings

talented/Django-Polls-App-Extended

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This is a temporary repository to showcase the solution for the programming tasks explained below:

Main Tasks

  1. 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.

  1. 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.


  1. 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

  1. Implement a password protected healthcheck endpoint covering:

      1. Django app is up and running and not in dev mode
      1. Database is accessible and can be queried
      1. 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/

  1. 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.

Optional Tasks

  1. 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.

  1. Describe briefly how you would build and distribute this app for a Debian based server infrastructure

Build instructions with Docker Compose

  1. Clone the repo
git clone https://github.com/talented/Django-Polls-App-Extended.git
  1. Run
cd django-polls-app-extended

docker-compose build

docker-compose up
  1. 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"
  1. 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
  1. 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

About

An extended dockerized version of Django Polls application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published