This repository has been archived by the owner. It is now read-only.
Switch branches/tags
www-in-manifest version-bump v update-travis-vars update-style update-style-2 update-repo update-release-notes-date update-preview-text update-jquery update-contribution-limits-pdf uglify-js turn-off-slack travis-redeploy temp-shutdown-rad-form tables-for-resources switch-datetime-on-banner-announcements revert-develop-master restore-rad-contact-form remove_anne_ravel remove-ravel remove-folder-model release/public-beta-20160720 release-issue redirect-mitigation redeploy redeploy-0803 re-deploy-slack-fix-travis rad-form-add-link public-beta-20170519 public-beta-20170512 public-beta-20170427 public-beta-20170419 public-beta-20170413 public-beta-20170405 public-beta-20170324 public-beta-20170324-2 public-beta-20170306 public-beta-20170216 public-beta-20170202 public-beta-20170118 public-beta-20170104 public-beta-20161221 public-beta-20161207 public-beta-20161123 public-beta-20161109 public-beta-20161026 public-beta-20161012 public-beta-20161005 public-beta-20160928.1 public-beta-20160928 public-beta-20160920 public-beta-20160914 public-beta-20160831.2 public-beta-20160831.1 public-beta-20160831 public-beta-20160817 public-beta-20160803 public-beta-20160728 public-beta-20160720 public-beta-20160707 public-beta-20160628 public-beta-20160622 public-beta-20160608 public-beta-20160525 public-beta-20160429 public-beta-20160428 public-beta-20160413 public-beta-20160316 public-beta-20160218 public-beta-20160203 public-beta-20151217 public-20180307 public-20180220 public-20180125 public-20180117 public-20180103-c public-20180103-b public-20171220 public-20171206 public-20171206-release public-20171122 public-20171109 public-20171109-fix public-20171011 public-20170811 public-20170629 public-20170614 public-20170601 public-20170523 preserve-query-params pin-fec-style-github minor-content-fixes merge-alignment-fix meeting_template_item_audio latest-updates-typo individual-filter hotfix/purchase-typo homepage-hide-draft-posts homepage-calendar
Nothing to show
Clone or download
Pull request Compare This branch is 714 commits behind fecgov:develop.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
.github Made instructions more concise Nov 7, 2017
bin Update web server tooling Apr 11, 2017
fec fixes image path for no headshot image Mar 8, 2018
.cfignore remove dist comment Oct 10, 2017
.gitignore Moving sass processing to compressor Aug 28, 2017
.hound.yml Add javascript boilerplate. Dec 19, 2015
.jshintignore
.jshintrc Add javascript boilerplate. Dec 19, 2015
CONTRIBUTING.md Added commit section back in after branching section Nov 29, 2017
LICENSE.md Adds non-public domain licenses Nov 7, 2017
Procfile Deploy to Cloud Foundry. Aug 18, 2015
README.md Replacing out the references to the old repo Feb 22, 2018
karma.conf.js
manifest_base.yml Making the debug false explicit in all environments Oct 3, 2017
manifest_dev.yml Updated S3 environment variables to point the bound S3 bucket Jan 12, 2018
manifest_feature.yml Updated S3 environment variables to point the bound S3 bucket Jan 12, 2018
manifest_prod.yml Updated S3 environment variables to point the bound S3 bucket Jan 12, 2018
manifest_stage.yml Updated S3 environment variables to point the bound S3 bucket Jan 12, 2018
newrelic.ini Update New Relic config Jan 5, 2017
package-lock.json update moment package to 2.20.1 Mar 5, 2018
package.json Updated moment library to latest version(2.20.1) Mar 2, 2018
requirements.txt
runtime.txt Switched test DB name, updated README.md and Python runtime version Sep 21, 2017
tasks.py re-enabling cache in circle config and reverting dev space to deploy … Feb 9, 2018

README.md

Develop CircleCI

Master Dependency Status

Campaign finance for everyone

The Federal Election Commission (FEC) releases information to the public about money that’s raised and spent in federal elections — that’s elections for US President, Senate, and House of Representatives.

Are you interested in seeing how much money a candidate raised? Or spent? How much debt they took on? Who contributed to their campaign? The FEC is the authoritative source for that information.

The new FEC.gov is a collaboration between 18F and the FEC. It aims to make campaign finance information more accessible (and understandable) to all users.

FEC repositories

We welcome you to explore, make suggestions, and contribute to our code.

This repository, fec-cms, houses the content management system (CMS) for the new FEC.gov.

  • FEC: a general discussion forum. We compile feedback from the FEC.gov feedback widget here, and this is the best place to submit general feedback.
  • openFEC: the first RESTful API for the Federal Election Commission
  • fec-cms: the content management system (CMS) for the new FEC.gov. This project uses Wagtail, an open source CMS written in Python and built on the Django framework.

Get involved

We’re thrilled you want to get involved!

  • Read our contributing guidelines. Then, file an issue or submit a pull request.
  • Send us an email at betafeedback@fec.gov.
  • If you're a developer, follow the installation instructions in the README.md page of each repository to run the apps on your computer.

Set up

We are always trying to improve our documentation. If you have suggestions or run into problems please file an issue!

Project prerequisites

  1. Ensure you have the following requirements installed:

    • Python (the latest 3.5 release, which includes pip and and a built-in version of virtualenv called venv).
    • The latest long term support (LTS) or stable release of Node.js (which includes npm).
    • PostgreSQL (the latest 9.6 release).
  2. Set up your Node environment — learn how to do this with our Javascript Ecosystem Guide.

  3. Set up your Python environment — learn how to do this with our Python Ecosystem Guide.

  4. Clone this repository.

Install project dependencies

Use pip to install the Python dependencies:

pip install -r requirements.txt

Use npm to install JavaScript dependencies:

npm install

Give default user privileges to create database

If you would like your default user to create the database, alter their user role:

sudo su - postgres
psql
alter user [default_username] createdb;
\q
exit

Create local databases

Before you can run this project locally, you'll need a development database:

createdb cfdm_cms_test
Load our sample data into the local development database:

For details see the section below: Restoring your local database from a backup

Set environment variables

You will also need to set the environment variables:

Set local environment variables

Connection string for the local database as an environment variable:

export DATABASE_URL=postgresql://:@/cfdm_cms_test

running with openFEC API

By default, FEC_API_URL points to the local running instance of the API (http://localhost:5000). To set the URL for the API as an environment variable, run:

export FEC_API_URL=http://localhost:5000

Set it to either production, dev, or staging API URLs if you are not running the API locally.

for example: (prod API) https://api.open.fec.gov export FEC_API_URL=https://api.open.fec.gov

The base settings file will read this value in instead of using the default (which is http://localhost:5000).

Also set API keys: FEC_WEB_API_KEY and FEC_WEB_API_KEY_PUBLIC

Finish project setup

Once all prerequisites and dependencies are installed, you can finish the project setup by running these commands:

npm run build
cd fec/
./manage.py migrate
./manage.py createsuperuser

Running the application

In the root project folder, run:

cd fec/
./manage.py runserver

Front End Development

Front end assets are all located in /fec/fec/static/*.

Icon building

Icons only need to be built if there are new SVG files in the /fec/fec/static/icons/input directory, which transforms that SVG file into a SCSS variable to be used on the stylesheets.

npm run build-icons

SCSS compilation

npm run build-sass

JavaScript compilation

npm run build-js

Compilation of both SCSS and JS files

npm run build

Command to watch for SCSS and JS changes

npm run watch

Running tests

There are two kinds of tests that you can run with the project, Python tests and JavaScript tests.

To run the JavaScript tests, run this command in the root project directory:

npm run test-single

Note: You may be prompted to allow node to accept connections; this is okay and required for the tests to run.

To run the Python tests, run these commands in the root project directory:

cd fec/
./manage.py test

It's necessary to specify the Postgresql URL, which can be done on the command line, e.g.:

env DATABASE_URL=postgresql://:@/cfdm_cms_test ./manage.py test

Enabling/toggling features

settings/base.py includes a set of FEATURES which can also be enabled using environment flags:

FEC_FEATURE_LEGAL=1 python fec/manage.py runserver

Additional local development instructions

Watch for static asset changes

To watch for changes to JavaScript files, run this command in the root project directory:

npm run watch

Restoring your local database from a backup

Likely only useful for FEC team members

Load our sample data into the local development database from a production backup

first download the web app sample database dump

FEC team can download from the project's google drive folder: CMS DB Backups

then save the file to a local drive: <path/to/backup_file>

then run this command:

pg_restore --dbname cfdm_cms_test --no-acl --no-owner <path/to/backup_file>

Lastly run migrations to account for any very recent changes that are not present in the latest backup run this command: ./manage.py migrate

Deploy

Likely only useful for FEC team members

We use Travis for automated deploys after tests pass. If you want to deploy something it is much better to push an empty commit with a tag than doing a manual deploy.

If there is a problem with Travis and something needs to be deployed, you can do so with the following commands. Though, you will need to pull the environment variables from the space you are deploying to and remake your static assets. That will ensure things like the links are correct. You will also want to clear your dist/ directory. That way, you will not exceed the alloted space.

Before deploying, install the Cloud Foundry CLI and the autopilot plugin:

cf install-plugin autopilot -r CF-Community

Provision development database:

cf create-service rds micro-psql fec-rds-stage

Provision credentials service:

cf cups cms-creds-dev -p '{"DJANGO_SECRET_KEY": "..."}'

To deploy to Cloud Foundry, run invoke deploy. The deploy task will attempt to detect the appropriate Cloud Foundry space based the current branch; to override, pass the optional --space flag:

invoke deploy --space feature

The deploy task will use the FEC_CF_USERNAME and FEC_CF_PASSWORD environment variables to log in. If these variables are not provided, you will be prompted for your Cloud Foundry credentials.

Deploys of a single app can be performed manually by targeting the env/space, and specifying the corresponding manifest, as well as the app you want, like so:

cf target -s [feature|dev|stage|prod] && cf push -f manifest_<[feature|dev|stage|prod]>.yml [api|cms]

NOTE: Performing a deploy in this manner will result in a brief period of downtime.

A note about deploying to the feature space

As noted above, you can manually deploy the application if you specify the space you want to deploy to, e.g., invoke deploy --space feature.

In the case of the feature space, there are a few things to note:

  • To deploy to the feature space, an automated deployer account has been set up. To trigger, go to the tasks.py file DEPLOY_RULES here.
  • Only the CMS app is setup and configured for the feature space; it points to the dev space for all other things (e.g., the API).
  • The feature version of the CMS does have New Relic running against it.
  • The CMS in the feature space has its own database that has been loaded with data from a production backup; this data can be refreshed in the future using the same steps outlined in the Wiki.
  • The feature space has its own S3 bucket for content.

SSH

Likely only useful for FEC team members

You can SSH directly into the running app container to help troubleshoot or inspect things with the instance(s). Run the following command:

cf ssh <app name>

Where is the name of the application instance you want to connect to. Once you are logged into the remote secure shell, you'll also want to run this command to setup the shell environment correctly:

. /home/vcap/app/bin/cf_env_setup.sh

More information about using SSH with cloud.dov can be found in the cloud.gov SSH documentation.

Accounts

Accounts are handled in the cms admin. All accounts will be reviewed annually.

Licensing and attribution

A few parts of this project are not in the public domain. Attribution and licensing information for those parts are described in detail in LICENSE.md.

The rest of this project is in the worldwide public domain, released under the CC0 1.0 Universal public domain dedication. Read more in LICENSE.md.

A few restrictions limit the way you can use FEC data. For example, you can't use contributor lists for commercial purposes or to solicit donations. Learn more on FEC.gov.