adam-grandt-tts / data-driven-acquisition

This system is a POC of a document management tool that will initiate acquisition document packages, and allow the acquisition work force to manage them as data. Handling some of the manual work of keeping the document up to date from an intuitive user interface.
Other
2 stars 1 forks source link

Collaborative Acquisition Tool

This system is a POC of a document management tool that will initiate acquisition document packages, and allow the acquisition work force to manage them as data. Handling some of the manual work of keeping the document up to date from an intuitive user interface.

Documentation

Model Design

I opted to use relational database to allow rapid development using Django, and PostgreSQL. Data model is available https://dbdiagram.io/d/5db0a60602e6e93440f28f98

data model

Design concepts:

Github integration

TODO:

Trelo Integration

TODO:

https://trello.com/b/SL7jTaz3/oia-acquisition-tracker

Third party libraries

Quickstart

Docker

The easiest way to get rolling is to use Docker:

# Build the application and database images
docker-compose build

# Run database migrations
docker-compose run app python manage.py migrate

# Load fixtures
docker-compose run app python manage.py loaddata data_driven_acquisition/fixtures/*

# Create a superuser
docker-compose run app python manage.py createsuperuser

Then, to start the application and its database:

docker-compose up

Use CTRL+C to stop.

Manual setup

Alternatively, follow these setup steps:

  1. Database Setup

    1. install PostgreSQL.

    2. Create database

    3. Configure your Create a new DB and role. e.g.:

      $ psql
      CREATE DATABASE myproject;
      CREATE USER myprojectuser WITH PASSWORD 'password';
      ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
      ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
      ALTER ROLE myprojectuser SET timezone TO 'UTC';
      GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
      \q
    4. Create the hsstore extention in the database by running:

      $ psql myproject
      CREATE EXTENSION IF NOT EXISTS hstore;
  2. Project set up

    1. Create project folder

      mkdir data-driven-acquisition
    2. Create virtual environment (using virtual env wrapper in this example).

    mkvirtualenv data-driven-acquisition --python=python37
    1. Install the requirements

      pip install -r requirements.txt
    2. Optional: Install the development and testing requirements if needed.

      pip install -r requirements_dev.txt
      pip install -r requirements_test.txt
    3. Create a .env file looking like so

      # Set debug settings globally to the app, makes logging very verbose. (on/off)
      DEBUG=on
      # Used for all encryption operations. Use something like this to generate.
      # python -c "import random; ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])"
      SECRET_KEY=your-secret-key
      DATABASE_URL=psql://DB_USER:DB_PASS@DB_IP/URL:DB_PORT/DB_NAME
      ALLOWED_HOSTS=127.0.0.1,0.0.0.0 # Prod IP goes here
      
      # GitHub Config
      # https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
      GITHUB_ACCESS_KEY=your-key-goes-here
      # MAke sure your github user has access to repo 
      GITHUB_TEMPLATE_REPO=github-repo-containing-templates
      
      # if you want ot use trello 
      #Do we use trello, def to no
      USER_TRELLO=yes
      # Set trello API Key, required if use trello is yes
      #https://developers.trello.com/reference#api-key-tokens
      TRELLO_APP_KEY=trello-api-key
      TRELLO_APP_SECRET=trello-oauth-secret
      # https://developers.trello.com/page/authorization
      # Get token by running and visiting the URL
      # trello_auth_url = ''.join([
      #             'https://trello.com/1/authorize?expiration=never',
      #            '&name=DataDrivenAcquisition&scope=read,write&response_type=token',
      #            f'&key={settings.TRELLO["APP_KEY"]}'])
      TRELLO_TOKEN=token-goes-here
      # Get the board ID from the URL of your trello board
      TRELLO_BORED_ID=board-id
      
    4. Collect static and run

      python manage.py collectstatic
      python manage.py migrate
      python manage.py loaddata data_driven_acquisition/fixtures/*

Cloud.gov CF Setup

```
    cf login -a api.fr.cloud.gov  --sso
    # Follow instructions to get key
    cf target -o sandbox-gsa -s adam.grandt
    cf push data_driven_acquisition
    # login to web UI to:
    #     * Create the same env vars described in the .env section above.
    #     * Create and bind shared postgres service
    cf restart data_driven_acquisition
    cf shell
    # in the cf shell run : 
        /tmp/lifecycle/shell
        python manage.py createsuperuser
        # Follow instructions 
    # Visit the URL configured in the manifest file 
```

Features

Running Tests

Does the code actually work?

```shell
    (myenv) $ pip install tox (or -r requirements_test.txt)
    (myenv) $ tox
```

Resources