Skip to content

Commit

Permalink
Merge pull request #19 from fecgov/release/sprint-2
Browse files Browse the repository at this point in the history
Release/sprint 2
  • Loading branch information
toddlees authored Jan 27, 2022
2 parents a565bff + d57b9f7 commit 16e5676
Show file tree
Hide file tree
Showing 37 changed files with 319 additions and 79 deletions.
7 changes: 5 additions & 2 deletions .circleci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ FECFILE_DB_HOST=localhost
FECFILE_DB_USERNAME=postgres
FECFILE_DB_PASSWORD=postgres
FECFILE_DB_NAME=postgres
FECFILE_FEC_WEBSITE_API_KEY=
```
NOTE that the FECFILE_DB_HOST is different here than what you need for your docker-compose configuration.
Notes:
* There is no default FECFILE_FEC_WEBSITE_API_KEY, you must obtain and set this yourself
* The FECFILE_DB_HOST value here is different than what you need for your local docker-compose configuration.

# Using CircleCI local CLI

Expand Down Expand Up @@ -48,4 +51,4 @@ circleci local execute -e FECFILE_DB_HOST=localhost \

## CircleCI configuration
To get CircleCI to run tests, you have to configure the
project in the Circle web applicaiton https://app.circleci.com/
project in the Circle web applicaiton https://app.circleci.com/
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Issue template
about: Issue template for fecfile-web-api
title: ''
labels: ''
assignees: ''

---

### Business Reason ###

As a [role], I will be able to [blank] so that I can [business reason]

### Acceptance Criteria ###

**If** [precedent]
**When** [action]
**Then** [result]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The launcher will run through the following steps
- print running containers.

### docker basic usage.
when running docker-compose you will need to be in the root directory of the project. The reason for this is that docker-compose looks for docker-compose.yml to be in the same directory where it's run
when running docker-compose you will need to be in the root directory of the project. The reason for this is that docker-compose looks for docker-compose.yml to be in the same directory where it's run. You will also need at least 3GB of memory allocated for docker during the build.

# Build the application
` docker-compose build `
Expand Down
6 changes: 4 additions & 2 deletions django-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ ENV PYTHONUNBUFFERED=1

RUN mkdir /opt/nxg_fec
WORKDIR /opt/nxg_fec
ADD . /opt/nxg_fec/
# MacOS has trouble with these installs unless they're pulled out and run with these parameters
RUN pip3 install Cython && pip3 install --no-binary :all: --no-use-pep517 numpy==1.17.2 && pip3 install pandas==0.25.1
ADD requirements.txt /opt/nxg_fec/
RUN pip3 install -r requirements.txt

RUN mv /etc/localtime /etc/localtime.backup && ln -s /usr/share/zoneinfo/EST5EDT /etc/localtime
Expand All @@ -12,4 +14,4 @@ RUN useradd nxgu --no-create-home --home /opt/nxg_fec && chown -R nxgu:nxgu /opt
user nxgu

EXPOSE 8080
ENTRYPOINT ["sh", "-c", "python wait_for_db.py && gunicorn --bind 0.0.0.0:8080 fecfiler.wsgi -w 10 -t 200 --reload"]
ENTRYPOINT ["sh", "-c", "pip3 install -r requirements.txt && python wait_for_db.py && gunicorn --bind 0.0.0.0:8080 fecfiler.wsgi -w 10 -t 200 --reload"]
15 changes: 0 additions & 15 deletions django-backend/Dockerfile-live

This file was deleted.

5 changes: 3 additions & 2 deletions django-backend/fecfiler/core/aggregation_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import datetime
import requests
import fecfiler.settings

# from functools import lru_cache
from django.db import connection
Expand Down Expand Up @@ -911,8 +912,8 @@ def get_election_year(office_sought, election_state, election_district):
election_year_list = []
while True:
ab = requests.get(
"https://api.open.fec.gov/v1/election-dates/?sort=-election_date&api_key=50nTHLLMcu3XSSzLnB0hax2Jg5LFniladU5Yf25j&page={}&per_page=100&sort_hide_null=false&sort_nulls_last=false{}".format(
i, param_string
"https://api.open.fec.gov/v1/election-dates/?sort=-election_date&api_key={}&page={}&per_page=100&sort_hide_null=false&sort_nulls_last=false{}".format(
fecfiler.settings.FECFILE_FEC_WEBSITE_API_KEY, i, param_string
)
)
results = results + ab.json()["results"]
Expand Down
2 changes: 1 addition & 1 deletion django-backend/fecfiler/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class CoreConfig(AppConfig):
name = 'core'
name = 'fecfiler.core'
11 changes: 10 additions & 1 deletion django-backend/fecfiler/core/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from django.test import TestCase
from fecfiler.core.aggregation_helper import get_election_year

# Create your tests here.

class SimpleTest(TestCase):
def setUp(self):
pass

def test_get_election_year(self):
result = get_election_year("H", "NJ", "01")
self.assertGreater(len(result), 0, "did not get expected number of results from get_election_year")
self.assertGreater(result[0], 1776, "Invalid election year - too long ago")
2 changes: 1 addition & 1 deletion django-backend/fecfiler/form_1M/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class Form1MConfig(AppConfig):
name = 'form_1M'
name = 'fecfiler.form_1M'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/forms/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class FormsConfig(AppConfig):
name = 'forms'
name = 'fecfiler.forms'
3 changes: 2 additions & 1 deletion django-backend/fecfiler/forms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ def get_rad_analyst_info(request):
if request.method == 'GET':
try:
if get_comittee_id(request.user.username):
ab = requests.get('https://api.open.fec.gov/v1/rad-analyst/?page=1&per_page=20&api_key=50nTHLLMcu3XSSzLnB0hax2Jg5LFniladU5Yf25j&committee_id=' + get_comittee_id(request.user.username) + '&sort_hide_null=false&sort_null_only=false')
url = 'https://api.open.fec.gov/v1/rad-analyst/?page=1&per_page=20&api_key={}&committee_id='.format(settings.FECFILE_FEC_WEBSITE_API_KEY) + get_comittee_id(request.user.username) + '&sort_hide_null=false&sort_null_only=false'
ab = requests.get(url)
return JsonResponse({"response": ab.json()['results']})
else:
return JsonResponse({"ERROR": "You must be logged in for this operation."})
Expand Down
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_A/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedAConfig(AppConfig):
name = 'sched_A'
name = 'fecfiler.sched_A'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_B/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedBConfig(AppConfig):
name = 'sched_B'
name = 'fecfiler.sched_B'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_C/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedCConfig(AppConfig):
name = 'sched_C'
name = 'fecfiler.sched_C'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_D/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedDConfig(AppConfig):
name = 'sched_D'
name = 'fecfiler.sched_D'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_E/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedEConfig(AppConfig):
name = 'sched_E'
name = 'fecfiler.sched_E'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_F/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedFConfig(AppConfig):
name = 'sched_F'
name = 'fecfiler.sched_F'
11 changes: 10 additions & 1 deletion django-backend/fecfiler/sched_F/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from django.test import TestCase
from fecfiler.sched_F.views import get_election_year

# Create your tests here.

class SimpleTest(TestCase):
def setUp(self):
pass

def test_get_election_year(self):
result = get_election_year("H", "NJ", "01")
self.assertGreater(len(result), 0, "did not get expected number of results from get_election_year")
self.assertGreater(result[0], 1776, "Invalid election year - too long ago")
11 changes: 6 additions & 5 deletions django-backend/fecfiler/sched_F/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,11 +1103,12 @@ def get_election_year(office_sought, election_state, election_district):
results = []
election_year_list = []
while True:
ab = requests.get(
"https://api.open.fec.gov/v1/election-dates/?sort=-election_date&api_key=50nTHLLMcu3XSSzLnB0hax2Jg5LFniladU5Yf25j&page={}&per_page=100&sort_hide_null=false&sort_nulls_last=false{}".format(
i, param_string
)
)
url = ("https://api.open.fec.gov/v1/election-dates/?"
+ "sort=-election_date&api_key={}".format(settings.FECFILE_FEC_WEBSITE_API_KEY)
+ "&page={}".format(i)
+ "&per_page=100&sort_hide_null=false&sort_nulls_last=false{}".format(param_string))

ab = requests.get(url)
results = results + ab.json()["results"]
if (
i == ab.json()["pagination"]["pages"]
Expand Down
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_H/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedHConfig(AppConfig):
name = 'sched_H'
name = 'fecfiler.sched_H'
2 changes: 1 addition & 1 deletion django-backend/fecfiler/sched_L/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SchedLConfig(AppConfig):
name = 'sched_L'
name = 'fecfiler.sched_L'
1 change: 1 addition & 0 deletions django-backend/fecfiler/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '!0)(sp6(&$=_70&+_(zogh24=)@5&smwtuwq@t*v88tn-#m=)z'

FECFILE_FEC_WEBSITE_API_KEY = os.environ.get('FECFILE_FEC_WEBSITE_API_KEY')

ROOT_URLCONF = 'fecfiler.urls'
WSGI_APPLICATION = 'fecfiler.wsgi.application'
Expand Down
12 changes: 6 additions & 6 deletions django-backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ boto==2.49.0
boto3==1.9.40
botocore==1.12.196
certifi==2018.8.24
cffi==1.11.5
cffi==1.15.0
chardet==3.0.4
coreapi==2.3.3
coreschema==0.0.4
Expand All @@ -14,18 +14,18 @@ dateparser==0.7.0
decorator==4.3.0
dj-database-url==0.3.0
dj-static==0.0.6
Django==2.2.13
Django==3.2.11
django-admin-shortcuts==2.0.0
django-appconf==1.0.1
django-appconf==1.0.5
django-bootstrap3==11.0.0
django-compressor==1.6
django-compressor==3.1
django-cors-headers==3.2.1
django-db-file-storage==0.5.3
django-rest-swagger==2.2.0
django-s3-upload==0.2.1
django-storages==1.7.1
django-storages==1.12.3
djangocms-admin-style==1.2.5
djangorestframework==3.9.1
djangorestframework==3.13.1
djangorestframework-jwt==1.11.0
djangorestframework-sso==0.3.2
docutils==0.14
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
# env_file: ../local.env
build:
context: './django-backend'
dockerfile: './Dockerfile-live'
dockerfile: './Dockerfile'
# command: python manage.py runserver 0.0.0.0:8080
image: fecfile-api
container_name: fecfile-api
Expand All @@ -41,7 +41,7 @@ services:
web:
build:
context: './front-end'
dockerfile: './build-scripts/Dockerfile-live'
dockerfile: './build-scripts/Dockerfile'
image: fecfile-web
container_name: fecfile-web
restart: always
Expand Down
3 changes: 3 additions & 0 deletions front-end/angular.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"analytics": "809a4ad6-c308-4c0a-98ae-1e67037818e9"
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions front-end/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# End to End Testing in Protractor

## Setup and Environment

By default, the URL confgiured in protractor.conf.js is http://localhost:4200/ so that it works
out of the box in our CI environment. Most developers will want to modify this using an enviornment
variable:
```shell
export FECFILE_URL=http://localhost/
```
10 changes: 8 additions & 2 deletions front-end/e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

const { SpecReporter } = require('jasmine-spec-reporter');

var baseUrl = 'http://localhost:4200/';
if (process.env.FECFILE_URL) {
baseUrl = process.env.FECFILE_URL
}


exports.config = {
allScriptsTimeout: 11000,
specs: [
Expand All @@ -12,7 +18,7 @@ exports.config = {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
baseUrl: baseUrl,
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
Expand All @@ -25,4 +31,4 @@ exports.config = {
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
};
5 changes: 3 additions & 2 deletions front-end/e2e/src/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ describe('workspace-project App', () => {
page = new AppPage();
});

it('should display welcome message', () => {
page.navigateTo();
xit('should display welcome message', async () => {
await page.navigateTo();

expect(page.getParagraphText()).toEqual('FEC File Online');
});
});
Loading

0 comments on commit 16e5676

Please sign in to comment.