Skip to content

sam-bertin/maykin

Repository files navigation

Maykin Django App

This is a Django app for the Maykin case study. It uses Docker for deployment and requires a .env file for configuration. Make sure to replace the parts in between brackets < > with your own values.

Setup

  1. Clone this repository to your local machine.
  2. Create a .env file in the root of the project directory with the following contents (replace the placeholder values with your own):
# General Settings
DEBUG=1
SECRET_KEY=mysecretkey
ALLOWED_HOSTS='["*"]'

# Maykin Config
CSV_USERNAME=<username>
CSV_PASSWORD=<password>
CSV_CITY_URL=<city_url>
CSV_HOTEL_URL=<hotel_url>

# Superuser
DJANGO_SUPERUSER_USERNAME=<su_user>
DJANGO_SUPERUSER_PASSWORD=<su_pass>
DJANGO_SUPERUSER_EMAIL=<su_email>
  1. Build the Docker image by running the following command in the root of the project directory:
docker build -t maykin-django-app .
  1. Start the Docker container in detached mode by running the following command:
docker run -d --name maykin-django-container -p 8000:8000 --env-file .env maykin-django-app

This will start the container in the background and map port 8000 on the host machine to port 8000 in the container. It will also pass the environment variables from the .env file to the container.

Usage

To access the app, open a web browser and navigate to http://localhost:8000. You should see the Maykin Django app homepage.

From the homepage, you can choose to log in using the credentials that you set for the Django superuser. This will give you access to the Django admin interface, where you can create new users and designate them as managers of a city of their choice. You can also create users who are not managers.

Managers can edit, add, or delete hotels in their designated city. Non-manager users can view all hotels, but cannot modify or delete them. The superuser has full access to all functionality.

To stop the container, run the following command:

docker stop maykin-django-container

To start the container again, run the following command:

docker start maykin-django-container

To view the container logs, run the following command:

docker logs maykin-django-container

That's it! You should now be able to use the Maykin Django app with Docker.

Optional

Start the scheduler to import data (every 5 min for now) I might update to give the ability to configure the task interval for the user.

docker exec -it <container_name> bash -c "source /app/venv/bin/activate && python /app/manage.py start_scheduler"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published