From 383ff658de74398a064e72d46e19b038254baeba Mon Sep 17 00:00:00 2001 From: john carroll Date: Sat, 28 Jan 2017 23:29:06 -0500 Subject: [PATCH 01/16] committing usajobs app and base/settings.py to register app --- fec/fec/settings/base.py | 3 ++ fec/fec/urls.py | 2 + fec/usajobs/__init__.py | 0 fec/usajobs/templates/fec_jobs_list.html | 1 + fec/usajobs/templates/jobs.html | 38 +++++++++++++++++ fec/usajobs/views.py | 53 ++++++++++++++++++++++++ 6 files changed, 97 insertions(+) create mode 100644 fec/usajobs/__init__.py create mode 100644 fec/usajobs/templates/fec_jobs_list.html create mode 100644 fec/usajobs/templates/jobs.html create mode 100644 fec/usajobs/views.py diff --git a/fec/fec/settings/base.py b/fec/fec/settings/base.py index 8aa31ed804..fd8dd82f7f 100644 --- a/fec/fec/settings/base.py +++ b/fec/fec/settings/base.py @@ -61,6 +61,9 @@ 'search', 'home', 'data_loader', + 'usajobs', + + ) MIDDLEWARE_CLASSES = ( diff --git a/fec/fec/urls.py b/fec/fec/urls.py index 489cee19f9..80ab667f08 100644 --- a/fec/fec/urls.py +++ b/fec/fec/urls.py @@ -9,6 +9,7 @@ from home import views as home_views from search import views as search_views +from usajobs import views as usajobs_views urlpatterns = [ @@ -22,6 +23,7 @@ url(r'^documents/', include(wagtaildocs_urls)), url(r'^search/$', search_views.search, name='search'), url(r'^updates/$', home_views.updates), + url(r'^jobs/$', usajobs_views.get_jobs, name='jobs'), url(r'', include(wagtail_urls)), ] diff --git a/fec/usajobs/__init__.py b/fec/usajobs/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fec/usajobs/templates/fec_jobs_list.html b/fec/usajobs/templates/fec_jobs_list.html new file mode 100644 index 0000000000..acfa595708 --- /dev/null +++ b/fec/usajobs/templates/fec_jobs_list.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/fec/usajobs/templates/jobs.html b/fec/usajobs/templates/jobs.html new file mode 100644 index 0000000000..c7461a0b33 --- /dev/null +++ b/fec/usajobs/templates/jobs.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% load wagtailcore_tags %} +{% block body_class %}template-{{ self.get_verbose_name | slugify }}{% endblock %} + +{% block content %} + +{% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style='secondary' %} + +
+
+
+

{{ self.title }}

+
+
+ {{ self.body }} + {% include "fec_jobs_list.html" %} +
+ {% if self.sidebar %} + + {% endif %} +
+
+ +{% include 'partials/disclaimer.html' %} + +{% endblock %} diff --git a/fec/usajobs/views.py b/fec/usajobs/views.py new file mode 100644 index 0000000000..8739cc4a67 --- /dev/null +++ b/fec/usajobs/views.py @@ -0,0 +1,53 @@ +from django.shortcuts import render +def get_jobs(request): + from django.http import HttpResponse + 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=", + '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() + + + + with open('usajobs/templates/fec_jobs_list.html', 'w') as joblist: + + + if responses['SearchResult']['SearchResultItems']: + joblist.write("") + + else: + joblist.write("There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.") + + return render(request, 'jobs.html') + #jobtable.close + + #return HttpResponse(jobtable) + From 6dcfe039d2f3292a8732761c6cacdfca66e7774f Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 31 Jan 2017 17:55:02 -0500 Subject: [PATCH 02/16] usajobs/templates/fec_jobs_list.html --- fec/fec/urls.py | 4 +- fec/home/templates/home/careers.html | 57 ++++++++++++++++++++++++ fec/home/templates/partials/jobs.html | 15 +++++++ fec/home/templatetags/open_jobs.py | 44 ++++++++++++++++++ fec/usajobs/templates/fec_jobs_list.html | 1 - 5 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 fec/home/templates/home/careers.html create mode 100644 fec/home/templates/partials/jobs.html create mode 100644 fec/home/templatetags/open_jobs.py delete mode 100644 fec/usajobs/templates/fec_jobs_list.html diff --git a/fec/fec/urls.py b/fec/fec/urls.py index 80ab667f08..cc12bd803d 100644 --- a/fec/fec/urls.py +++ b/fec/fec/urls.py @@ -23,7 +23,9 @@ url(r'^documents/', include(wagtaildocs_urls)), url(r'^search/$', search_views.search, name='search'), url(r'^updates/$', home_views.updates), - url(r'^jobs/$', usajobs_views.get_jobs, name='jobs'), + url(r'^jobs/$', usajobs_views.get_jobs), + url(r'^careers/$', TemplateView.as_view(template_name='home/careers.html')), + url(r'', include(wagtail_urls)), ] diff --git a/fec/home/templates/home/careers.html b/fec/home/templates/home/careers.html new file mode 100644 index 0000000000..128c784e6b --- /dev/null +++ b/fec/home/templates/home/careers.html @@ -0,0 +1,57 @@ +{% extends "long_page.html" %} +{% load wagtailcore_tags %} +{% load staticfiles %} +{% load open_jobs %} +{% load wagtailcore_tags %} +{% block title %}{{ self.title }}{% endblock %} +{% block body_class %}template-{{ self.get_verbose_name | slugify }}{% endblock %} + +{% block breadcrumbs %} + {% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style=self.breadcrumb_style %} +{% endblock %} + +{% block intro %} +
+
{{ self.intro }}
+
+{% endblock %} + +{% block sections %} + + {{ self.sections }} + {% get_jobs %} +{% endblock %} + +{% if self.citations %} +{% block citations %} +
+ {% for citation in self.citations %} + {% for block in citation.value %} +
+

{{ block.label }}

+ {{ block.content }} + +
+ {% endfor %} + {% endfor %} +
+{% endblock %} +{% endif %} + +{% block related_topics %} +{% for block in self.related_topics %} + {% with topics=block.value %} + {% for topic in topics %} + + {% endfor %} + {% endwith %} +{% endfor %} +{% endblock %} diff --git a/fec/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html new file mode 100644 index 0000000000..362178251d --- /dev/null +++ b/fec/home/templates/partials/jobs.html @@ -0,0 +1,15 @@ +{% 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..e8f3f6f014 --- /dev/null +++ b/fec/home/templatetags/open_jobs.py @@ -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 + 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=", + '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 = { "PositionTitle": i["MatchedObjectDescriptor"]["PositionTitle"] , + "PositionID": i["MatchedObjectDescriptor"]["PositionID"], + "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}) + + diff --git a/fec/usajobs/templates/fec_jobs_list.html b/fec/usajobs/templates/fec_jobs_list.html deleted file mode 100644 index acfa595708..0000000000 --- a/fec/usajobs/templates/fec_jobs_list.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 2b8f510c4ff399e5652dcc867c130ad573a6a8e7 Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 31 Jan 2017 17:56:50 -0500 Subject: [PATCH 03/16] deleted unused files --- fec/usajobs/__init__.py | 0 fec/usajobs/templates/jobs.html | 38 ----------------------- fec/usajobs/views.py | 53 --------------------------------- 3 files changed, 91 deletions(-) delete mode 100644 fec/usajobs/__init__.py delete mode 100644 fec/usajobs/templates/jobs.html delete mode 100644 fec/usajobs/views.py diff --git a/fec/usajobs/__init__.py b/fec/usajobs/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/fec/usajobs/templates/jobs.html b/fec/usajobs/templates/jobs.html deleted file mode 100644 index c7461a0b33..0000000000 --- a/fec/usajobs/templates/jobs.html +++ /dev/null @@ -1,38 +0,0 @@ -{% extends "base.html" %} -{% load wagtailcore_tags %} -{% block body_class %}template-{{ self.get_verbose_name | slugify }}{% endblock %} - -{% block content %} - -{% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style='secondary' %} - -
-
-
-

{{ self.title }}

-
-
- {{ self.body }} - {% include "fec_jobs_list.html" %} -
- {% if self.sidebar %} - - {% endif %} -
-
- -{% include 'partials/disclaimer.html' %} - -{% endblock %} diff --git a/fec/usajobs/views.py b/fec/usajobs/views.py deleted file mode 100644 index 8739cc4a67..0000000000 --- a/fec/usajobs/views.py +++ /dev/null @@ -1,53 +0,0 @@ -from django.shortcuts import render -def get_jobs(request): - from django.http import HttpResponse - 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=", - '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() - - - - with open('usajobs/templates/fec_jobs_list.html', 'w') as joblist: - - - if responses['SearchResult']['SearchResultItems']: - joblist.write("
    ") - for i in responses['SearchResult']['SearchResultItems']: - start_date = dateutil.parser.parse(i['MatchedObjectDescriptor']['PositionStartDate']) - end_date = dateutil.parser.parse(i['MatchedObjectDescriptor']['PositionEndDate']) - joblist.write("
  • ") - joblist.write("

    " + i['MatchedObjectDescriptor']['PositionID'] + ", " + i['MatchedObjectDescriptor']['PositionTitle'] + "

    ") - joblist.write("
      ") - joblist.write("
    • Open Period: "+ start_date.strftime('%b %d, %Y')+ " - " + end_date.strftime('%b %d, %Y')+ "
    • ") - joblist.write("
    • Who May Apply: "+ i['MatchedObjectDescriptor']['UserArea']['Details']['WhoMayApply']['Name'] + "
    • ") - joblist.write("
    • Grade: "+ i['MatchedObjectDescriptor']['JobGrade'][0]['Code'] + "-" + i['MatchedObjectDescriptor']['UserArea']['Details']['LowGrade']+ " - " + i['MatchedObjectDescriptor']['UserArea']['Details']['HighGrade'] + "
    • ") - joblist.write("
    ") - joblist.write("

  • ") - - joblist.write("
") - - else: - joblist.write("There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.") - - return render(request, 'jobs.html') - #jobtable.close - - #return HttpResponse(jobtable) - From 0b0c5f1c8d68a02013d73bc57c37c6a800467dae Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 31 Jan 2017 18:00:44 -0500 Subject: [PATCH 04/16] removed unused app on INSATALLED APPS in base.py --- fec/fec/settings/base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fec/fec/settings/base.py b/fec/fec/settings/base.py index fd8dd82f7f..45daf19d38 100644 --- a/fec/fec/settings/base.py +++ b/fec/fec/settings/base.py @@ -61,9 +61,7 @@ 'search', 'home', 'data_loader', - 'usajobs', - - + ) MIDDLEWARE_CLASSES = ( From 20ea4646157c4a8f7742070144babaadd2bb46d5 Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 31 Jan 2017 18:04:51 -0500 Subject: [PATCH 05/16] removed unused url definition and import statement --- fec/fec/urls.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/fec/fec/urls.py b/fec/fec/urls.py index cc12bd803d..31859faeea 100644 --- a/fec/fec/urls.py +++ b/fec/fec/urls.py @@ -9,7 +9,6 @@ from home import views as home_views from search import views as search_views -from usajobs import views as usajobs_views urlpatterns = [ @@ -23,7 +22,6 @@ url(r'^documents/', include(wagtaildocs_urls)), url(r'^search/$', search_views.search, name='search'), url(r'^updates/$', home_views.updates), - url(r'^jobs/$', usajobs_views.get_jobs), url(r'^careers/$', TemplateView.as_view(template_name='home/careers.html')), From 1c0eea33f195fa8288825610761ac9fed31de390 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 3 Feb 2017 00:56:00 -0500 Subject: [PATCH 06/16] added careers blocks and templatetag --- fec/home/blocks.py | 10 ++++- fec/home/templates/blocks/careers.html | 4 ++ fec/home/templates/home/careers.html | 57 -------------------------- fec/home/templates/partials/jobs.html | 4 +- 4 files changed, 16 insertions(+), 59 deletions(-) create mode 100644 fec/home/templates/blocks/careers.html delete mode 100644 fec/home/templates/home/careers.html diff --git a/fec/home/blocks.py b/fec/home/blocks.py index 176a1836f8..424ef85eaa 100644 --- a/fec/home/blocks.py +++ b/fec/home/blocks.py @@ -89,6 +89,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) @@ -101,7 +108,8 @@ class ResourceBlock(blocks.StructBlock): ('external_button', ExternalButtonBlock()), ('page', blocks.PageChooserBlock(template='blocks/page-links.html')), ('document_list', blocks.ListBlock(FeedDocumentBlock(), template='blocks/document-list.html', icon='doc-empty')), - ('current_commissioners', CurrentCommissionersBlock()) + ('current_commissioners', CurrentCommissionersBlock()), + ('fec_jobs', CareersBlock()) ]) aside = blocks.StreamBlock([ diff --git a/fec/home/templates/blocks/careers.html b/fec/home/templates/blocks/careers.html new file mode 100644 index 0000000000..ab24a62060 --- /dev/null +++ b/fec/home/templates/blocks/careers.html @@ -0,0 +1,4 @@ +{% load wagtailcore_tags %} +{% load open_jobs %} + +{% get_jobs %} diff --git a/fec/home/templates/home/careers.html b/fec/home/templates/home/careers.html deleted file mode 100644 index 128c784e6b..0000000000 --- a/fec/home/templates/home/careers.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends "long_page.html" %} -{% load wagtailcore_tags %} -{% load staticfiles %} -{% load open_jobs %} -{% load wagtailcore_tags %} -{% block title %}{{ self.title }}{% endblock %} -{% block body_class %}template-{{ self.get_verbose_name | slugify }}{% endblock %} - -{% block breadcrumbs %} - {% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style=self.breadcrumb_style %} -{% endblock %} - -{% block intro %} -
-
{{ self.intro }}
-
-{% endblock %} - -{% block sections %} - - {{ self.sections }} - {% get_jobs %} -{% endblock %} - -{% if self.citations %} -{% block citations %} -
- {% for citation in self.citations %} - {% for block in citation.value %} -
-

{{ block.label }}

- {{ block.content }} - -
- {% endfor %} - {% endfor %} -
-{% endblock %} -{% endif %} - -{% block related_topics %} -{% for block in self.related_topics %} - {% with topics=block.value %} - {% for topic in topics %} - - {% endfor %} - {% endwith %} -{% endfor %} -{% endblock %} diff --git a/fec/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html index 362178251d..a06659e446 100644 --- a/fec/home/templates/partials/jobs.html +++ b/fec/home/templates/partials/jobs.html @@ -1,4 +1,5 @@ {% load wagtailcore_tags %} +
    {% for j in jobData %}
  • @@ -12,4 +13,5 @@

    {{ j.PositionID }} , {{ j.PositionTitle}}< {% empty %}

    There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.")

    {% endfor %} -

\ No newline at end of file + +
\ No newline at end of file From 218c1e2475574adc6f01cbf87fedb5cfb590c6fe Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 3 Feb 2017 00:59:38 -0500 Subject: [PATCH 07/16] restored fec/urls.py to match original on dev --- fec/fec/urls.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/fec/fec/urls.py b/fec/fec/urls.py index 31859faeea..7d56d8e2b2 100644 --- a/fec/fec/urls.py +++ b/fec/fec/urls.py @@ -22,9 +22,7 @@ url(r'^documents/', include(wagtaildocs_urls)), url(r'^search/$', search_views.search, name='search'), url(r'^updates/$', home_views.updates), - url(r'^careers/$', TemplateView.as_view(template_name='home/careers.html')), - url(r'', include(wagtail_urls)), ] From fbcb9db92cdbf6d3bc8e114c7898fe9e7c9a0cc2 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 3 Feb 2017 12:27:12 -0500 Subject: [PATCH 08/16] updated open_jobs.py, needed Positio URI variable --- fec/home/templatetags/open_jobs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fec/home/templatetags/open_jobs.py b/fec/home/templatetags/open_jobs.py index e8f3f6f014..c0cf2f8456 100644 --- a/fec/home/templatetags/open_jobs.py +++ b/fec/home/templatetags/open_jobs.py @@ -30,7 +30,7 @@ def get_jobs(): for i in responses['SearchResult']['SearchResultItems']: x= {} x = { "PositionTitle": i["MatchedObjectDescriptor"]["PositionTitle"] , - "PositionID": i["MatchedObjectDescriptor"]["PositionID"], + "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'], From 388dca2bf932e454e9ab94aaa8f7f60122c9d0d5 Mon Sep 17 00:00:00 2001 From: Lindsay Young Date: Thu, 9 Feb 2017 15:48:12 -0500 Subject: [PATCH 09/16] make staging use the umbrella in prep for pen testing --- manifest_stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2ef91aac4788a7bd1bd7d4701338a90eb91e7cc4 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 10 Feb 2017 17:20:10 -0500 Subject: [PATCH 10/16] removed API key did other requested edits --- fec/home/templates/blocks/careers.html | 2 +- fec/home/templates/partials/jobs.html | 26 ++++++++++++++------------ fec/home/templatetags/open_jobs.py | 14 +++++++------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/fec/home/templates/blocks/careers.html b/fec/home/templates/blocks/careers.html index ab24a62060..28c2d89463 100644 --- a/fec/home/templates/blocks/careers.html +++ b/fec/home/templates/blocks/careers.html @@ -1,4 +1,4 @@ {% load wagtailcore_tags %} {% load open_jobs %} -{% get_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 index a06659e446..62a67600e2 100644 --- a/fec/home/templates/partials/jobs.html +++ b/fec/home/templates/partials/jobs.html @@ -1,17 +1,19 @@ {% load wagtailcore_tags %} -
-
    -{% for j in jobData %} -
  • -

    {{ j.PositionID }} , {{ j.PositionTitle}}

    +
    +
    + {% for j in jobData %}
      -
    • Open Period: {{ j.PositionStartDate }} - {{ j.PositionEndDate }}
    • -
    • Who May Apply: {{ j.WhoMayApply }}
    • -
    • Grade: {{ j.JobGrade }} - {{ j.LowGrade }} - {{ j.HighGrade }}
    • +
    • +

      {{ j.PositionID }} , {{ j.PositionTitle}}

      +
        +
      • Open Period: {{ j.PositionStartDate }} - {{ j.PositionEndDate }}
      • +
      • Who May Apply: {{ j.WhoMayApply }}
      • +
      • Grade: {{ j.JobGrade }} - {{ j.LowGrade }} - {{ j.HighGrade }}
      • +
      +
    -

  • {% empty %} -

    There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.")

    -{% endfor %} -
+

There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.")

+ {% endfor %} +
\ No newline at end of file diff --git a/fec/home/templatetags/open_jobs.py b/fec/home/templatetags/open_jobs.py index c0cf2f8456..447f565fba 100644 --- a/fec/home/templatetags/open_jobs.py +++ b/fec/home/templatetags/open_jobs.py @@ -1,22 +1,22 @@ -from django.shortcuts import render_to_response, redirect from django import template +#from django.http import HttpResponse +import requests +#import json +#from datetime import datetime +import dateutil.parser register = template.Library() @register.inclusion_tag('partials/jobs.html') def get_jobs(): - from django.http import HttpResponse - 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=", + 'authorization-key': "#", 'user-agent': "jcarroll@fec.gov", 'host': "data.usajobs.gov", 'cache-control': "no-cache", From 5336bc8134c0bd2025d6c60cc0bd1542926ba649 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 10 Feb 2017 17:33:22 -0500 Subject: [PATCH 11/16] Fixes migrations in CMS develop branch 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. --- fec/home/migrations/0061_merge_20170210_2230.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 fec/home/migrations/0061_merge_20170210_2230.py 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 = [ + ] From c02b731d4f1cdc3c2933a4c6f83a2a780fa7570e Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 14 Feb 2017 17:43:00 -0500 Subject: [PATCH 12/16] set API key as sensitive env var using UUPS in CF --- fec/fec/settings/base.py | 2 ++ fec/home/templates/partials/jobs.html | 2 +- fec/home/templatetags/open_jobs.py | 11 ++++------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fec/fec/settings/base.py b/fec/fec/settings/base.py index 0fa9cd2cde..3c4ee5bc63 100644 --- a/fec/fec/settings/base.py +++ b/fec/fec/settings/base.py @@ -172,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') @@ -218,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/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html index 62a67600e2..72558a0587 100644 --- a/fec/home/templates/partials/jobs.html +++ b/fec/home/templates/partials/jobs.html @@ -9,7 +9,7 @@

{{ j.PositionID }} , {{ j.PositionTitle}}<
  • Open Period: {{ j.PositionStartDate }} - {{ j.PositionEndDate }}
  • Who May Apply: {{ j.WhoMayApply }}
  • Grade: {{ j.JobGrade }} - {{ j.LowGrade }} - {{ j.HighGrade }}
  • - +
    {% empty %} diff --git a/fec/home/templatetags/open_jobs.py b/fec/home/templatetags/open_jobs.py index 447f565fba..5c10633c56 100644 --- a/fec/home/templatetags/open_jobs.py +++ b/fec/home/templatetags/open_jobs.py @@ -1,22 +1,19 @@ from django import template -#from django.http import HttpResponse import requests -#import json -#from datetime import datetime +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":"PU00","WhoMayApply":"All"} - + querystring = {"Organization":"LF00","WhoMayApply":"All"} headers = { - 'authorization-key': "#", + 'authorization-key': settings.USAJOBS_API_KEY, 'user-agent': "jcarroll@fec.gov", 'host': "data.usajobs.gov", 'cache-control': "no-cache", From 9982536f8f6d7352bbbf8b749aa7293fab51f7b8 Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 14 Feb 2017 19:28:15 -0500 Subject: [PATCH 13/16] padding to bottom of job entries --- fec/home/templates/partials/jobs.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fec/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html index 72558a0587..a64de12aff 100644 --- a/fec/home/templates/partials/jobs.html +++ b/fec/home/templates/partials/jobs.html @@ -1,19 +1,19 @@ {% load wagtailcore_tags %}
    +
      {% for j in jobData %} -
      • {{ j.PositionID }} , {{ j.PositionTitle}}

        -
          +
          • Open Period: {{ j.PositionStartDate }} - {{ j.PositionEndDate }}
          • Who May Apply: {{ j.WhoMayApply }}
          • Grade: {{ j.JobGrade }} - {{ j.LowGrade }} - {{ j.HighGrade }}
          • -

          +
      • -
      {% empty %} -

      There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.")

      +
    • There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.")
    • +
    {% endfor %}
    \ No newline at end of file From fdd9724857a511d36b454f8cced964bcf1c0b269 Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 14 Feb 2017 19:48:59 -0500 Subject: [PATCH 14/16] fixed UL nesting...again --- fec/home/templates/partials/jobs.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fec/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html index a64de12aff..c5cb48767a 100644 --- a/fec/home/templates/partials/jobs.html +++ b/fec/home/templates/partials/jobs.html @@ -13,7 +13,7 @@

    {{ j.PositionID }} , {{ j.PositionTitle}}< {% empty %}
  • There are currently no open positions available. Please check back on this page or Job Announcements on USAJOBs for the latest FEC Vacancy Announcements.")
  • - {% endfor %} + \ No newline at end of file From 8556ce1eba1b2a2ace8e7fa5052235492d8ea9e6 Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 14 Feb 2017 20:38:01 -0500 Subject: [PATCH 15/16] requested edits to Python --- fec/home/templates/partials/jobs.html | 8 ++++---- fec/home/templatetags/open_jobs.py | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fec/home/templates/partials/jobs.html b/fec/home/templates/partials/jobs.html index c5cb48767a..4991bc23f1 100644 --- a/fec/home/templates/partials/jobs.html +++ b/fec/home/templates/partials/jobs.html @@ -4,11 +4,11 @@
      {% for j in jobData %}
    • -

      {{ j.PositionID }} , {{ j.PositionTitle}}

      +

      {{ j.position_id }} , {{ j.position_title}}

        -
      • Open Period: {{ j.PositionStartDate }} - {{ j.PositionEndDate }}
      • -
      • Who May Apply: {{ j.WhoMayApply }}
      • -
      • Grade: {{ j.JobGrade }} - {{ j.LowGrade }} - {{ j.HighGrade }}
      • +
      • Open Period: {{ j.position_start_date }} - {{ j.position_end_date }}
      • +
      • Who May Apply: {{ j.who_may_apply }}
      • +
      • Grade: {{ j.job_grade }} - {{ j.low_grade }} - {{ j.high_grade }}
    • {% empty %} diff --git a/fec/home/templatetags/open_jobs.py b/fec/home/templatetags/open_jobs.py index 5c10633c56..208ed83a51 100644 --- a/fec/home/templatetags/open_jobs.py +++ b/fec/home/templatetags/open_jobs.py @@ -26,14 +26,16 @@ def get_jobs(): jobData = [] for i in responses['SearchResult']['SearchResultItems']: x= {} - x = { "PositionTitle": i["MatchedObjectDescriptor"]["PositionTitle"] , - "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'] } + 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}) From bd3294ddbeffc219c558ea1dd7c3a1fb8734f1aa Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 14 Feb 2017 20:39:53 -0500 Subject: [PATCH 16/16] missed on lowercase change --- fec/home/templatetags/open_jobs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fec/home/templatetags/open_jobs.py b/fec/home/templatetags/open_jobs.py index 208ed83a51..58e095a79d 100644 --- a/fec/home/templatetags/open_jobs.py +++ b/fec/home/templatetags/open_jobs.py @@ -32,7 +32,7 @@ def get_jobs(): "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'], + "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'] }