Skip to content

akvo/partos-pat

Repository files navigation

partos-pat

Power Awarness Tool

Coverage Status DBdocs

Table of Contents

Prerequisites

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/akvo/partos-pat.git
    cd partos-pat
  2. Environment Setup:

    • Copy .env.example to .env and change the values to suit your local environment:
      cp .env.example .env
    • Set the desired values for the following variables:
    MAILJET_APIKEY=YOUR_MAILJET_API_KEY
    MAILJET_SECRET=YOUR_MAILJET_SECRET
    WEBDOMAIN="<<full site URL (default: http://localhost:3000)>>"
    
  3. Build and Start the Containers:

    Run the following command to build and start all services:

    docker compose up -d

    This will spin up the following services:

    • Backend
    • Frontend
    • PostgreSQL Database
    • PgAdmin
  4. Stopping the Containers:

    To stop the containers without removing them, run:

    docker compose stop

    To stop and remove the containers, networks, and volumes, run:

    docker compose down

Services

Backend

The backend service runs on port 8000 and handles the core application logic. Access it at http://localhost:8000.

Frontend

The frontend service runs on port 3000 and provides the user interface. Access it at http://localhost:3000.

API Documentation

API documentation (Swagger) is hosted at http://localhost:3000/api/docs.

PgAdmin

PgAdmin for managing your PostgreSQL database is accessible on port 5050. Access it at http://localhost:5050.

PgAdmin Credentials

Use the following credentials to log in to PgAdmin:

Commands

Export Users to CSV

This command allows you to export user data from the database to a CSV file. Admin users can then download this file from the Manage Users page in the admin panel.

Usage

To run the command and generate the CSV file, use the following command in the terminal:

docker compose exec backend python manage.py export_users_csv

Details

  • Command: export_users_csv
  • Functionality: Exports user data from the database into a CSV format.
  • File Location: The generated CSV file is stored in the ./storage directory, where it can be accessed via the admin dashboard under the Manage Users page.

Creating an admin user

This command allows you to create a superuser account in the PARTOS-PAT platform. A superuser has full administrative rights and can access the PARTOS-PAT admin panel to manage users and view statistics.

Usage

Run the command below in your terminal.

docker compose exec backend python manage.py createsuperuser

Follow the prompts to enter details like username, email, and password for the superuser. Once created, you can log in to the PARTOS-PAT admin interface using the credentials provided.

References: https://docs.djangoproject.com/en/1.8/intro/tutorial02/#creating-an-admin-user


Troubleshooting

  • If a service fails to start, check the logs with:

    docker compose logs <service-name>
  • Common issues may include port conflicts or missing environment variables. Ensure all ports are available and all required .env files are present.