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

Fellowships improvements #1157

Merged
merged 2 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 3 deletions network-api/networkapi/fellows/admin.py

This file was deleted.

3 changes: 0 additions & 3 deletions network-api/networkapi/fellows/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions network-api/networkapi/fellows/tests.py

This file was deleted.

12 changes: 6 additions & 6 deletions source/js/fellowships.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import LoadingIndicator from './components/loading-indicator/loading-indicator.j

let pulseApiDomain = ``;
let pulseDomain = ``;
const DIRECOTRY_PAGE_FILTER_OPTIONS = {'program_year': `2017`};
const DIRECTORY_PAGE_FILTER_OPTIONS = {'program_year': `2017`};
const DIRECTORY_PAGE_TYPE_ORDER = [ `science`, `open web`, `tech policy`, `media`];

function getFellows(params, callback) {
Expand All @@ -17,9 +17,7 @@ function getFellows(params, callback) {
let queryString = Object.entries(params).map(pair => pair.map(encodeURIComponent).join(`=`)).join(`&`);
let req = new XMLHttpRequest();

req.addEventListener(`load`, () => {
callback.call(this, JSON.parse(req.response));
});
req.addEventListener(`load`, () => callback(JSON.parse(req.response)));

req.open(`GET`, `https://${pulseApiDomain}/api/pulse/profiles/?${queryString}`);
req.send();
Expand Down Expand Up @@ -60,12 +58,14 @@ function groupFellowsByAttr(attribute, fellows) {
let fellowsGroup = {};

fellows.forEach(fellow => {
let attr = fellow[attribute].toLowerCase();
let attr = fellow[attribute];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i wonder if i should try.. catch here instead

Choose a reason for hiding this comment

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

nah, I think the early return does the trick well


if (!attr) {
return;
}

attr = attr.toLowerCase();

if (!fellowsGroup[attr]) {
fellowsGroup[attr] = [fellow];
} else {
Expand Down Expand Up @@ -98,7 +98,7 @@ function renderFellowsOnDirectoryPage() {
ReactDOM.render(<div className="mx-auto my-5 text-center"><LoadingIndicator /></div>, CONTAINER);

// get fellow info from Pulse
getFellows(DIRECOTRY_PAGE_FILTER_OPTIONS, fellows => {
getFellows(DIRECTORY_PAGE_FILTER_OPTIONS, fellows => {
// render filter bar
let filterBar = <div className="row">
<div className="col-12">
Expand Down