-
Notifications
You must be signed in to change notification settings - Fork 40
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
Changes from 9 commits
383ff65
6dcfe03
2b8f510
0b0c5f1
20ea464
0d034eb
1c0eea3
218c1e2
fbcb9db
388dca2
2ef91aa
5336bc8
32bec7a
c6c55b9
c02b731
271d313
9982536
3cb9078
fdd9724
8556ce1
bd3294d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ | |
'search', | ||
'home', | ||
'data_loader', | ||
|
||
) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% load wagtailcore_tags %} | ||
{% load open_jobs %} | ||
|
||
{% get_jobs %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% load wagtailcore_tags %} | ||
<section class="slab slab--neutral" style="padding:1rem"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We try to avoid inline styles. Does the default padding on the .slab class not work? |
||
<ul> | ||
{% for j in jobData %} | ||
<li> | ||
<h3><a href="{{ j.PositionURI }}">{{ j.PositionID }} , {{ j.PositionTitle}}</a></h3> | ||
<ul> | ||
<li class='t-sans'><strong>Open Period:</strong> {{ j.PositionStartDate }} - {{ j.PositionEndDate }}</li> | ||
<li class='t-sans'><strong>Who May Apply:</strong> {{ j.WhoMayApply }}</li> | ||
<li class='t-sans'><strong>Grade:</strong> {{ j.JobGrade }} - {{ j.LowGrade }} - {{ j.HighGrade }}</li> | ||
</ul> | ||
</li><br> | ||
{% empty %} | ||
<p>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.")</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{% endfor %} | ||
</ul> | ||
</section> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
from django.shortcuts import render_to_response, redirect | ||
from django import template | ||
|
||
register = template.Library() | ||
|
||
@register.inclusion_tag('partials/jobs.html') | ||
def get_jobs(): | ||
from django.http import HttpResponse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Imports should be at the top of the file. |
||
import requests | ||
import json | ||
from datetime import datetime | ||
import dateutil.parser | ||
url = "https://data.usajobs.gov/api/Search" | ||
|
||
querystring = {"Organization":"PU00","WhoMayApply":"All"} | ||
|
||
headers = { | ||
'authorization-key': "ZQbNd1iLrQ+rPN3Rj2Q9gDy2Qpi/3haXSXGuHbP1SRk=", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this key private? If so, it shouldn't be checked in and should instead be set as a secret env var (and should probably be replaced now if it is supposed to be private). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am waiting to hear back from USAjobs API support regarding a ticket I submitted to resolve this. |
||
'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 = { "PositionTitle": i["MatchedObjectDescriptor"]["PositionTitle"] , | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few small formatting things:
|
||
"PositionID": i["MatchedObjectDescriptor"]["PositionID"], "PositionURI": i ["MatchedObjectDescriptor"]["PositionURI"], | ||
"PositionStartDate" : dateutil.parser.parse(i['MatchedObjectDescriptor']['PositionStartDate']), | ||
"PositionEndDate" : dateutil.parser.parse(i['MatchedObjectDescriptor']['PositionEndDate']), | ||
"WhoMayApply" : i['MatchedObjectDescriptor']['UserArea']['Details']['WhoMayApply']['Name'], | ||
"JobGrade" : i['MatchedObjectDescriptor']['JobGrade'][0]['Code'], | ||
"LowGrade" : i['MatchedObjectDescriptor']['UserArea']['Details']['LowGrade'], | ||
"HighGrade" : i['MatchedObjectDescriptor']['UserArea']['Details']['HighGrade'] } | ||
jobData.append(x) | ||
|
||
return ({'jobData':jobData}) | ||
|
||
|
There was a problem hiding this comment.
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.