BenCh94 / gas_dash

0 stars 0 forks source link

Cannot login or see dashboard, no clear setup instructions #133

Open wfclark5 opened 4 years ago

wfclark5 commented 4 years ago

Describe the bug

I have been trying to create documentation on how another developer can start and contribute to the features of this application. (Ex. Adding the environment variables to path, running the needed Django commands, Requirements, etc etc). Do you have any insights on this?

As of right now I have been able to start your application but when trying to sign in with the admin user I recieve this error.

Environment:

Request Method: GET Request URL: http://127.0.0.1:8000/dash/

Django Version: 2.2.10 Python Version: 3.6.9 Installed Applications: ['home.apps.HomeConfig', 'dashboard.apps.DashboardConfig', 'django.contrib.auth', 'django.contrib.admin', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'coverage', 'whitenoise.runserver_nostatic'] Installed Middleware: ('whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:

File "/home/cirrus/.local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/home/cirrus/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/cirrus/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/cirrus/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view

  1. return view_func(request, *args, **kwargs)

File "/mnt/c/Users/19193/Desktop/azimuth/gas_dash/dashboard/views/dash_views.py" in index

  1. context['stocks'] = portfolio.get_current_quotes()

Exception Type: AttributeError at /dash/ Exception Value: 'NoneType' object has no attribute 'get_current_quotes'

Expected behaviour Dashboard is shown

BenCh94 commented 4 years ago

Hi There Will,

I've been working on the app in my spare time so haven't formalised the documentation and setup instructions yet. There are a few issues that need to be worked through. Let me get back to you tomorrow when I have some time with some setup instructions.

wfclark5 commented 4 years ago

Sounds great Ben!

I will continue to work through your code and send any documentation that I come up with as well.

BenCh94 commented 4 years ago

Hi Will,

As I said yesterday there is still a ways to go to get this project up and running for contributions. But to help you get started I'll share the setup that I'm using to test.

.envrc (using direnv to manage environment variables locally):

export SECRET_KEY="
export DJANGO_LOG_LEVEL=
export EMAIL_PASSWORD=
export EMAIL=
export ADMIN=
export DATABASE_URL=
export db_pass=
export test_password=
export DJANGO_SETTINGS_MODULE=
export IEX_API=
export IEX_BASE_URL=
export LOCAL_CHROME=

You will need an IEX cloud API key to get started: https://iexcloud.io/cloud-login#/register

The issue you were seeing relates to the portfolio object, which contains a user's stocks trades etc. This isn't created by default (yet) when the user is set up so you will need to do it manually. You can create it easily in the admin console by going to {root_url}/snail_master when logged in as admin.

You can populate the tickers table from IEX using the mgmt command: python manage.py populate_ticker

Just be aware filling the ticker table brings you close to 10,000 rows off the bat. If you're using a cloud-based DB this could put you to the limit of their free tier.

Another important thing to note is the portfolio update function which I run daily in my test app using a Heroku scheduler. This will pull stock price data from IEX and update the portfolio data.

mgmt command: python manage.py update_portfolios

Not sure if you're familiar with Terraform but below is terraform setup for a Heroku pipeline with staging and production app, DBS and schedulers:

# Configure heroku provider
provider "heroku" {
  email = "{insert email here}"
  api_key = "{Heroku API key here}"
}

# Create Heroku apps for staging and production
resource "heroku_app" "staging" {
  name = "some-app-name-staging"
  region = "us"
}

resource "heroku_app" "production" {
  name = "some-app-name-production"
  region = "us"
}

# Create a Heroku pipeline
resource "heroku_pipeline" "app_pipeline" {
  name = "some-app-name"
}

# Couple apps to different pipeline stages
resource "heroku_pipeline_coupling" "staging" {
  app      = "${heroku_app.staging.name}"
  pipeline = "${heroku_pipeline.app_pipeline.id}"
  stage    = "staging"
}

resource "heroku_pipeline_coupling" "production" {
  app      = "${heroku_app.production.name}"
  pipeline = "${heroku_pipeline.app_pipeline.id}"
  stage    = "production"
}

# Create databases for apps
resource "heroku_addon" "prod_db" {
    app    = "${heroku_app.production.name}"
    plan   = "heroku-postgresql:hobby-dev"
}

resource "heroku_addon" "staging_db" {
    app    = "${heroku_app.staging.name}"
    plan   = "heroku-postgresql:hobby-dev"
}

# Create scheduler add ons for updating data
resource "heroku_addon" "production_scheduler" {
    app    = "${heroku_app.production.name}"
    plan   = "scheduler:standard"
}

resource "heroku_addon" "staging_scheduler" {
    app    = "${heroku_app.staging.name}"
    plan   = "scheduler:standard"
}

Hopefully, that can get you started as I work on documenting more and fixing some of the setup issues. I'm eager to get contributions on this project but probably not at that stage just yet.

Let me know if there's anything else causing issues I'll do my best to help out.

Thanks, Ben