Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CareersBlock for Resource Page template sections streamblock(USAJobs API) #799

Merged
merged 21 commits into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
383ff65
committing usajobs app and base/settings.py to register app
johnnyporkchops Jan 29, 2017
6dcfe03
usajobs/templates/fec_jobs_list.html
johnnyporkchops Jan 31, 2017
2b8f510
deleted unused files
johnnyporkchops Jan 31, 2017
0b0c5f1
removed unused app on INSATALLED APPS in base.py
johnnyporkchops Jan 31, 2017
20ea464
removed unused url definition and import statement
johnnyporkchops Jan 31, 2017
0d034eb
Merge remote-tracking branch 'origin' into feature/usa-jobs-templatetag
johnnyporkchops Feb 2, 2017
1c0eea3
added careers blocks and templatetag
johnnyporkchops Feb 3, 2017
218c1e2
restored fec/urls.py to match original on dev
johnnyporkchops Feb 3, 2017
fbcb9db
updated open_jobs.py, needed Positio URI variable
johnnyporkchops Feb 3, 2017
388dca2
make staging use the umbrella
LindsayYoung Feb 9, 2017
2ef91aa
removed API key did other requested edits
johnnyporkchops Feb 10, 2017
5336bc8
Fixes migrations in CMS develop branch
ccostino Feb 10, 2017
32bec7a
Merge pull request #807 from 18F/feature/new-api-url
Feb 11, 2017
c6c55b9
Merge pull request #811 from 18F/bug/fix-table-migration
Feb 14, 2017
c02b731
set API key as sensitive env var using UUPS in CF
johnnyporkchops Feb 14, 2017
271d313
Merge branch 'develop' into feature/usa-jobs-templatetag
johnnyporkchops Feb 14, 2017
9982536
padding to bottom of job entries
johnnyporkchops Feb 15, 2017
3cb9078
Merge branch 'feature/usa-jobs-templatetag' of github.com:18F/fec-cms…
johnnyporkchops Feb 15, 2017
fdd9724
fixed UL nesting...again
johnnyporkchops Feb 15, 2017
8556ce1
requested edits to Python
johnnyporkchops Feb 15, 2017
bd3294d
missed on lowercase change
johnnyporkchops Feb 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fec/fec/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'search',
'home',
'data_loader',

)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
url(r'^documents/', include(wagtaildocs_urls)),
url(r'^search/$', search_views.search, name='search'),
url(r'^updates/$', home_views.updates),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to add a preference to your text editor to strip out extraneous whitespace like this. Not a big deal, but will result in fewer false diffs.

url(r'', include(wagtail_urls)),
]

Expand Down
10 changes: 9 additions & 1 deletion fec/home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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([
Expand Down
16 changes: 16 additions & 0 deletions fec/home/migrations/0061_merge_20170210_2230.py
Original file line number Diff line number Diff line change
@@ -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 = [
]
4 changes: 4 additions & 0 deletions fec/home/templates/blocks/careers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% load wagtailcore_tags %}
{% load open_jobs %}

{% get_jobs %}
19 changes: 19 additions & 0 deletions fec/home/templates/partials/jobs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% load wagtailcore_tags %}
<section class="slab slab--neutral slab--inline" >
<div class="container">
<ul>
{% for j in jobData %}
<li>
<h3><a href="{{ j.position_uri }}">{{ j.position_id }} , {{ j.position_title}}</a></h3>
<ul class="u-padding--bottom">
<li class='t-sans'><strong>Open Period:</strong> {{ j.position_start_date }} - {{ j.position_end_date }}</li>
<li class='t-sans'><strong>Who May Apply:</strong> {{ j.who_may_apply }}</li>
<li class='t-sans'><strong>Grade:</strong> {{ j.job_grade }} - {{ j.low_grade }} - {{ j.high_grade }}</li>
</ul>
</li>
{% empty %}
<li class='t-sans'>There are currently no open positions available. Please check back on this page or Job Announcements on <a href='https://www.usajobs.gov/' title='USAJobs website'>USAJOBs</a> for the latest FEC Vacancy Announcements.")</li>
{% endfor %}
</ul>
</div>
</section>
43 changes: 43 additions & 0 deletions fec/home/templatetags/open_jobs.py
Original file line number Diff line number Diff line change
@@ -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': "[email protected]",
'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})


2 changes: 1 addition & 1 deletion manifest_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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