diff --git a/fec/fec/settings/base.py b/fec/fec/settings/base.py index 45c5c8aee5..3c4ee5bc63 100644 --- a/fec/fec/settings/base.py +++ b/fec/fec/settings/base.py @@ -62,6 +62,7 @@ 'search', 'home', 'data_loader', + ) MIDDLEWARE_CLASSES = ( @@ -171,6 +172,7 @@ from fec import constants from .env import env +USAJOBS_API_KEY = env.get_credential('USAJOBS_API_KEY') FEC_APP_URL = os.getenv('FEC_APP_URL') FEC_API_URL = os.getenv('FEC_API_URL', 'http://localhost:5000') FEC_API_VERSION = os.getenv('FEC_API_VERSION', 'v1') @@ -217,6 +219,7 @@ 'dsn': os.getenv('SENTRY_DSN'), } + if FEC_CMS_ENVIRONMENT != 'LOCAL': AWS_QUERYSTRING_AUTH = False AWS_ACCESS_KEY_ID = env.get_credential('CMS_AWS_ACCESS_KEY_ID') diff --git a/fec/fec/urls.py b/fec/fec/urls.py index 489cee19f9..7d56d8e2b2 100644 --- a/fec/fec/urls.py +++ b/fec/fec/urls.py @@ -22,7 +22,7 @@ url(r'^documents/', include(wagtaildocs_urls)), url(r'^search/$', search_views.search, name='search'), url(r'^updates/$', home_views.updates), - + url(r'', include(wagtail_urls)), ] diff --git a/fec/home/blocks.py b/fec/home/blocks.py index 523f14781d..5c1fdd54cc 100644 --- a/fec/home/blocks.py +++ b/fec/home/blocks.py @@ -90,6 +90,13 @@ class Meta: admin_text = 'Show current commissioners in a grid. No configuration needed.' template = 'blocks/commissioners.html' +class CareersBlock(blocks.StaticBlock): + """A block that displays the open FEC jobs""" + class Meta: + icon = 'group' + admin_text = 'Show open fec jobs from USAJobs.gov. No configuration needed.' + template = 'blocks/careers.html' + class ResourceBlock(blocks.StructBlock): """A section of a ResourcePage""" title = blocks.CharBlock(required=True) @@ -103,7 +110,8 @@ class ResourceBlock(blocks.StructBlock): ('page', blocks.PageChooserBlock(template='blocks/page-links.html')), ('document_list', blocks.ListBlock(FeedDocumentBlock(), template='blocks/document-list.html', icon='doc-empty')), ('current_commissioners', CurrentCommissionersBlock()), - ('table', TableBlock()), + ('fec_jobs', CareersBlock()), + ('table', TableBlock()) ]) aside = blocks.StreamBlock([ diff --git a/fec/home/migrations/0061_merge_20170210_2230.py b/fec/home/migrations/0061_merge_20170210_2230.py new file mode 100644 index 0000000000..7b2c397031 --- /dev/null +++ b/fec/home/migrations/0061_merge_20170210_2230.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-02-10 22:30 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0060_auto_20170209_2030'), + ('home', '0058_auto_20170210_2136'), + ] + + operations = [ + ] diff --git a/fec/home/templates/blocks/careers.html b/fec/home/templates/blocks/careers.html new file mode 100644 index 0000000000..28c2d89463 --- /dev/null +++ b/fec/home/templates/blocks/careers.html @@ -0,0 +1,4 @@ +{% load wagtailcore_tags %} +{% load open_jobs %} + +{% get_jobs %} \ No newline at end of file diff --git a/fec/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html new file mode 100644 index 0000000000..4991bc23f1 --- /dev/null +++ b/fec/home/templates/partials/jobs.html @@ -0,0 +1,19 @@ +{% load wagtailcore_tags %} +
+
+ +
+
\ No newline at end of file diff --git a/fec/home/templatetags/open_jobs.py b/fec/home/templatetags/open_jobs.py new file mode 100644 index 0000000000..58e095a79d --- /dev/null +++ b/fec/home/templatetags/open_jobs.py @@ -0,0 +1,43 @@ + +from django import template +import requests +from django.conf import settings +from django.conf import os +import dateutil.parser + +register = template.Library() + +@register.inclusion_tag('partials/jobs.html') +def get_jobs(): + url = "https://data.usajobs.gov/api/Search" + + querystring = {"Organization":"LF00","WhoMayApply":"All"} + headers = { + 'authorization-key': settings.USAJOBS_API_KEY, + 'user-agent': "jcarroll@fec.gov", + 'host': "data.usajobs.gov", + 'cache-control': "no-cache", + } + + response = requests.request("GET", url, headers=headers, params=querystring) + + responses=response.json() + + jobData = [] + for i in responses['SearchResult']['SearchResultItems']: + x= {} + x = { + "position_title": i["MatchedObjectDescriptor"]["PositionTitle"] , + "position_id": i["MatchedObjectDescriptor"]["PositionID"], + "position_uri": i ["MatchedObjectDescriptor"]["PositionURI"], + "position_start_date" : dateutil.parser.parse(i['MatchedObjectDescriptor']['PositionStartDate']), + "position_end_date" : dateutil.parser.parse(i['MatchedObjectDescriptor']['PositionEndDate']), + "who_may_apply" : i['MatchedObjectDescriptor']['UserArea']['Details']['WhoMayApply']['Name'], + "job_grade" : i['MatchedObjectDescriptor']['JobGrade'][0]['Code'], + "low_grade" : i['MatchedObjectDescriptor']['UserArea']['Details']['LowGrade'], + "high_grade" : i['MatchedObjectDescriptor']['UserArea']['Details']['HighGrade'] } + jobData.append(x) + + return ({'jobData':jobData}) + + diff --git a/manifest_stage.yml b/manifest_stage.yml index 933985a828..3ee527fbb3 100644 --- a/manifest_stage.yml +++ b/manifest_stage.yml @@ -6,7 +6,7 @@ services: - fec-creds-stage - fec-rds-stage env: - FEC_API_URL: https://fec-stage-api.18f.gov + FEC_API_URL: https://api-stage.open.fec.gov FEC_APP_URL: https://fec-stage-proxy.18f.gov/data FEC_CMS_ENVIRONMENT: stage NEW_RELIC_APP_NAME: beta.fec.gov | cms | stage