Git Product home page Git Product logo

engage-backend's Introduction

CouncilTag

Dev Setup

To setup the development environment:

  1. Install redis https://redis.io/download
  • Make sure you use version 4.0.0

  • Compiling is very slow due to the testing suite.

    • if you use MacOS, use brew install redis

    • if ubuntu, use guide from digital ocean

  1. Clone this repo

  2. Set up a virtualenv and install all Python packages.

pip install virtualenv

virtualenv env -p /path/to/python3.6

source env/bin/activate

pip install -r requirements.txt

  1. Setup Postgres and PgAdmin for your platform if needed. PgAdmin is a useful GUI database manager.
  • Make sure you are using postgres from major vrsion 10, not 11
  1. Create the counciltag database if it does not exist.

  2. Create a database user, give the user a password and grant the user permissions for counciltag.

  3. Add the following environment variables for the project. You'll need database info, django secret key and 'CouncilTag' to run the project in DEBUG mode.

DB_NAME=counciltag
DB_USER=REPLACEME
DB_PASSWORD=REPLACEME
DJANGO_SECRET_KEY=someuniqueunpredictablevalue
SENDGRIDKEY="SG.-some_long_string"
RECAPTCHAKEY="some_string"
CouncilTag=debug
  1. To run tests on the package set these environment variables:
POSTGRES_USER=<Some user with DB create rights or who owns $POSTGRES_DB>
POSTGRES_PASSWORD=<Password for $POSTGRES_USER>
POSTGRES_DB=<Some DB that already exists or that you have create rights for>
DATABASE_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost/$POSTGRES_DB?sslmode=true
CouncilTag=test
DJANGO_SECRET_KEY=examplesecretkeydonotuseinprod
SENDGRIDKEY=SG.-thisisnotarealkeylol
  1. Then, run python manage.py test -k
  • -k keeps the existing database and is not necessary if your user is granted create rights on the system
  1. If it's your first time setting up the dev environment, run the following commands. In this order, these commands will 1) create the SQL tables needed, 2) load our list of tags, 3) scrape live data from the City of Santa Monica.

python manage.py migrate

python manage.py populate_tags

python manage.py scrape_data

  1. Then edit CouncilTags/urls.py to switch to localhost.
# url="https://backend.engage.town/api",
url="http://localhost:8000/api",
  1. (optional) If you want to scrape agendas nightly for a committee you must start the celery beat worker. My recommendation is to output the errors and logs to a text file like beats.tst

celery -A CouncilTag beat -l debug > beat.tst 2>&1 &

  1. (optional) If you want to process the PDFs for upcoming committee meetings you must start the celery worker. My recommendation is to output the errors and logs to a text file like worker.tst

celery -A CouncilTag worker -l debug > worker.tst 2>&1 &

  1. Finally, start the server.

python manage.py runserver

You can go to http://localhost:8000/swagger/ to look at the docs and interact with the API.

Continous Delivery

We have setup continous integration and deployment on CircleCI.

When you push to the master branch on this repo, this will trigger a build on the server and also run the Django test suite. If the tests fail, the build will not go through.

Django Documentation

If you are new to using Django, you can read up more about it here: https://docs.djangoproject.com/en/2.0/

engage-backend's People

Contributors

shariqt avatar vinvasir avatar dorachan2000 avatar teddycr avatar hungrymonkey avatar dstrodtman avatar tienyuan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.