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

Conversation

johnnyporkchops
Copy link
Contributor

@johnnyporkchops johnnyporkchops commented Feb 3, 2017

This block allows one to add a list of all open FEC jobs in the Resource Page template using a streamfield static block. To be used in creating the /about/careers page. The list is real-time and will always be up to date upon page load. Below is a screenshot of careers page made with the Resource Page template and this new block.

In the final page, It shows current openings if there are any, otherwise in shows "check back later" language. (The query is currently querying the PeaceCorps ("Organization":"PU00") for demo purposes since we have no open jobs, will switch to FEC (LF00) in production.

Files:
home/templatetags/open_jobs.py
home/templates/block/careers.html
home/templates/partials/jobs.html
home/blocks.py

This uses home/templatetags/open_jobs.py to register an inclusion for jobs.html partial and query the USAJobs API

A block definition for CareersBlock is added to the streamfield definition for ResourceBlock that is available in the editing interface on Resource Page template. (The best part is I could add this without having to alter any models or makemigrations :-)

add_jobs

Related issues:
https://github.com/18F/fec-cms/issues/769
https://github.com/18F/fec-cms/issues/678

Similar PR:
https://github.com/18F/fec-cms/pull/735

Below is a screenshot of careers page made using this new streamfield block inside Resource Page template:

careers_page

@codecov-io
Copy link

codecov-io commented Feb 3, 2017

Codecov Report

❗ No coverage uploaded for pull request base (release/public-beta-20170216@ee94384). Click here to learn what that means.
The diff coverage is 37.93%.

@@                       Coverage Diff                       @@
##             release/public-beta-20170216     #799   +/-   ##
===============================================================
  Coverage                                ?   63.11%           
===============================================================
  Files                                   ?      124           
  Lines                                   ?     2700           
  Branches                                ?      208           
===============================================================
  Hits                                    ?     1704           
  Misses                                  ?      988           
  Partials                                ?        8
Impacted Files Coverage Δ
fec/fec/urls.py 58.82% <ø> (ø)
fec/home/templatetags/open_jobs.py 0% <ø> (ø)
fec/fec/settings/base.py 79.24% <100%> (ø)
fec/home/blocks.py 100% <100%> (ø)
fec/home/migrations/0061_merge_20170210_2230.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee94384...bd3294d. Read the comment docs.

Copy link

@noahmanger noahmanger left a comment

Choose a reason for hiding this comment

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

Works great. Just caught a few small things. Nice work!

@@ -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.

@@ -0,0 +1,17 @@
{% load wagtailcore_tags %}
<section class="slab slab--neutral" style="padding:1rem">

Choose a reason for hiding this comment

The 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>
</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>

Choose a reason for hiding this comment

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

<p> should be outside the <ul>


@register.inclusion_tag('partials/jobs.html')
def get_jobs():
from django.http import HttpResponse

Choose a reason for hiding this comment

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

Imports should be at the top of the file.

querystring = {"Organization":"PU00","WhoMayApply":"All"}

headers = {
'authorization-key': "ZQbNd1iLrQ+rPN3Rj2Q9gDy2Qpi/3haXSXGuHbP1SRk=",

Choose a reason for hiding this comment

The 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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@noahmanger noahmanger self-assigned this Feb 9, 2017
@johnnyporkchops
Copy link
Contributor Author

The USAJobs API key has been deactivated and removed from checked-in code. A new key will be set as an environmental variable using "create-user-provided-service (cups)" on the next push.
Other requested edits have been made.

The previous two hotfixes seem to have gotten in the way of this latest migration, so this changeset fixes them and sets things straight again.
@noahmanger
Copy link

Cool. You'll just need to also add the env var lookup to base.py (like https://github.com/18F/fec-cms/pull/755/files#diff-5593e913baa39c1a426336cbe3e0af6dR189)

make staging use the umbrella
@noahmanger
Copy link

@johnnyporkchops do you know if you'll be able to finish this up today? I'd like to get it merged in if possible.

@johnnyporkchops
Copy link
Contributor Author

Yes, I will update shortly

@johnnyporkchops
Copy link
Contributor Author

--@ccostino added the API Key as a sensitive env var to CF using UUPS. I have referenced it in fec/settings/base.py and as a variable in home/templatetags/open_jobs.py.

--There are no open FEC jobs, so it will show the alt language. If we want see a job list for presentation/testing purposes, one could temporarily change line #14 in open_jobs.py to read "Organization":"HS" (homeland security has open jobs)(FEC is LF00)

Please let me know of any changes, I will make them ASAP

@johnnyporkchops
Copy link
Contributor Author

Let me know if I can also build the about/careers page when this is merged in.

@noahmanger noahmanger changed the base branch from develop to release/public-beta-20170216 February 15, 2017 01:07
<li>
<h3><a href="{{ j.PositionURI }}">{{ j.PositionID }} , {{ j.PositionTitle}}</a></h3>
<ul class="u-padding--bottom">
<li class='t-sans'><strong>Open Period:</strong> {{ j.PositionStartDate }} - {{ j.PositionEndDate }}</li>

Choose a reason for hiding this comment

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

Super small thing, but prefer double quotes for attributes in HTML. Also, you can just put .t-sans on the parent element, I believe.

jobData = []
for i in responses['SearchResult']['SearchResultItems']:
x= {}
x = { "PositionTitle": i["MatchedObjectDescriptor"]["PositionTitle"] ,

Choose a reason for hiding this comment

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

A few small formatting things:

  • Each item should be on a new line (PositionURI is on the same line as PositionID)
  • Key names should be lower case and use underscores instead of camelCase

@noahmanger
Copy link

Looking great. Just had a few small code style comments.

@noahmanger noahmanger merged commit 92d646f into release/public-beta-20170216 Feb 15, 2017
@noahmanger noahmanger deleted the feature/usa-jobs-templatetag branch February 15, 2017 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants