Skip to content

Commit

Permalink
Merge pull request #26582 from code-dot-org/dtl_candidate_0929dda5
Browse files Browse the repository at this point in the history
  • Loading branch information
deploy-code-org committed Jan 11, 2019
2 parents 97a5d75 + 0929dda commit 57c0c5b
Show file tree
Hide file tree
Showing 29 changed files with 267 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ export default class Section4LeadingStudents extends LabeledFormComponent {
} else {
requiredFields.push('csdCspCompletedPd');
}

return requiredFields;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -344,19 +344,19 @@ export class DetailViewContents extends React.Component {
'notes_3',
'notes_4',
'notes_5',
'question_1',
'question_2',
'question_3',
'question_4',
'question_5',
'question_6',
'question_7',
'regional_partner_value',
'pd_workshop_id'
];

if (this.props.applicationData.application_type === ApplicationTypes.facilitator) {
stateValues.push('fit_workshop_id');
stateValues.push('question_1');
stateValues.push('question_2');
stateValues.push('question_3');
stateValues.push('question_4');
stateValues.push('question_5');
stateValues.push('question_6');
stateValues.push('question_7');
}

if (this.props.applicationData.application_type === ApplicationTypes.teacher) {
Expand Down
16 changes: 16 additions & 0 deletions apps/src/code-studio/pd/application_dashboard/quick_view_table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ export class QuickViewTable extends React.Component {
transforms: [sortable]
}
});
} else {
columns.push(
{
property: 'meets_criteria',
header: {
label: 'Meets Criteria',
transforms: [sortable]
}
}, {
property: 'total_score',
header: {
label: 'Total Score',
transforms: [sortable]
}
}
);
}

[
Expand Down
6 changes: 2 additions & 4 deletions apps/src/templates/CompletionButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class CompletionButton extends Component {
}
}

export const UnconnectedCompletionButton = CompletionButton;

export default connect(state => ({
isProjectLevel: state.pageConstants.isProjectLevel,
isSubmittable: state.pageConstants.isSubmittable,
Expand All @@ -80,7 +82,3 @@ export default connect(state => ({
}))(CompletionButton);

export {styles};

export var __TestInterface__ = {
UnconnectedCompletionButton: CompletionButton
};
55 changes: 26 additions & 29 deletions apps/test/unit/applab/CompletionButtonTest.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
import {assert} from '../../util/configuredChai';
var testUtils = require('../../util/testUtils');
var CompletionButton = require('@cdo/apps/templates/CompletionButton').__TestInterface__.UnconnectedCompletionButton;
import React from 'react';
var ReactTestUtils = require('react-addons-test-utils');
import {expect} from '../../util/configuredChai';
import {mount} from 'enzyme';
import {UnconnectedCompletionButton as CompletionButton} from '@cdo/apps/templates/CompletionButton';

describe('CompletionButton', function () {
testUtils.setExternalGlobals();
describe('CompletionButton', () => {

it('non-project level, can submit, havent', function () {
var component = ReactTestUtils.renderIntoDocument(
it('non-project level, can submit, havent', () => {
const completionButton = mount(
<CompletionButton
isProjectLevel={false}
isSubmittable={true}
isSubmitted={false}
/>
);
var buttons = ReactTestUtils.scryRenderedDOMComponentsWithTag(component, 'button');
assert.equal(buttons.length, 1);
assert.equal(buttons[0].getAttribute('id'), 'submitButton');
assert.equal(buttons[0].textContent, 'Submit');
const button = completionButton.find('button');
expect(button).to.have.length(1);
expect(button.props().id).to.equal('submitButton');
expect(button.text()).to.equal('Submit');
});

it('non-project level, can submit, have', function () {
var component = ReactTestUtils.renderIntoDocument(
it('non-project level, can submit, have', () => {
const completionButton = mount(
<CompletionButton
isProjectLevel={false}
isSubmittable={true}
isSubmitted={true}
/>
);
var buttons = ReactTestUtils.scryRenderedDOMComponentsWithTag(component, 'button');
assert.equal(buttons.length, 1);
assert.equal(buttons[0].getAttribute('id'), 'unsubmitButton');
assert.equal(buttons[0].textContent, 'Unsubmit');
const button = completionButton.find('button');
expect(button).to.have.length(1);
expect(button.props().id).to.equal('unsubmitButton');
expect(button.text()).to.equal('Unsubmit');
});

it('non-project level, cant submit', function () {
var component = ReactTestUtils.renderIntoDocument(
it('non-project level, cant submit', () => {
const completionButton = mount(
<CompletionButton
isProjectLevel={false}
isSubmittable={false}
isSubmitted={false}
/>
);
var buttons = ReactTestUtils.scryRenderedDOMComponentsWithTag(component, 'button');
assert.equal(buttons.length, 1);
assert.equal(buttons[0].getAttribute('id'), 'finishButton');
assert.equal(buttons[0].textContent, 'Finish');
const button = completionButton.find('button');
expect(button).to.have.length(1);
expect(button.props().id).to.equal('finishButton');
expect(button.text()).to.equal('Finish');
});


it('project level (cant submit)', function () {
var component = ReactTestUtils.renderIntoDocument(
it('project level (cant submit)', () => {
const completionButton = mount(
<CompletionButton
isProjectLevel={true}
isSubmittable={false}
isSubmitted={false}
/>
);
var buttons = ReactTestUtils.scryRenderedDOMComponentsWithTag(component, 'button');
assert.equal(buttons.length, 0);
const button = completionButton.find('button');
expect(button).to.have.length(0);
});
});
50 changes: 23 additions & 27 deletions apps/test/unit/templates/CrosshairOverlayTest.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
import {expect} from '../../util/configuredChai';
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import {expect} from '../../util/configuredChai';
import {mount} from 'enzyme';
import CrosshairOverlay, { CROSSHAIR_MARGIN, styles } from '@cdo/apps/templates/CrosshairOverlay';

describe('CrosshairOverlay', () => {
const TEST_APP_WIDTH = 300, TEST_APP_HEIGHT = 200;

function renderAtMousePosition(x, y) {
let renderer = ReactTestUtils.createRenderer();
renderer.render(
const crosshairOverlay = mount(
<CrosshairOverlay
width={TEST_APP_WIDTH}
height={TEST_APP_HEIGHT}
mouseX={x}
mouseY={y}
/>
);
return renderer.getRenderOutput();
return crosshairOverlay;
}

function checkRenderAtMousePosition(x, y) {
expect(renderAtMousePosition(x, y)).to.deep.equal(
<g className="crosshair-overlay">
<line
x1={x}
y1={0}
x2={x}
y2={y - CROSSHAIR_MARGIN}
style={styles.line}
/>
<line
x1={0}
y1={y}
x2={x - CROSSHAIR_MARGIN}
y2={y}
style={styles.line}
/>
</g>
);
const crosshairOverlay = renderAtMousePosition(x,y);
expect(crosshairOverlay.find('g')).to.have.length(1);
expect(crosshairOverlay.find('line')).to.have.length(2);
const firstLine = crosshairOverlay.find('line').first();
expect(firstLine.props().x1).to.equal(x);
expect(firstLine.props().y1).to.equal(0);
expect(firstLine.props().x2).to.equal(x);
expect(firstLine.props().y2).to.equal(y - CROSSHAIR_MARGIN);
expect(firstLine.props().style).to.equal(styles.line);
const secondLine = crosshairOverlay.find('line').last();
expect(secondLine.props().x1).to.equal(0);
expect(secondLine.props().y1).to.equal(y);
expect(secondLine.props().x2).to.equal(x - CROSSHAIR_MARGIN);
expect(secondLine.props().y2).to.equal(y);
expect(secondLine.props().style).to.equal(styles.line);
}

it('renders null if mouse is out of bounds', () => {
expect(renderAtMousePosition(-1, 0)).to.be.null;
expect(renderAtMousePosition(0, -1)).to.be.null;
expect(renderAtMousePosition(TEST_APP_WIDTH + 1, TEST_APP_HEIGHT)).to.be.null;
expect(renderAtMousePosition(TEST_APP_WIDTH, TEST_APP_HEIGHT + 1)).to.be.null;
expect(renderAtMousePosition(-1, 0).html()).to.be.null;
expect(renderAtMousePosition(0, -1).html()).to.be.null;
expect(renderAtMousePosition(TEST_APP_WIDTH + 1, TEST_APP_HEIGHT).html()).to.be.null;
expect(renderAtMousePosition(TEST_APP_WIDTH, TEST_APP_HEIGHT + 1).html()).to.be.null;
});

it('renders lines converging at mouse position if mouse is in bounds', () => {
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/Berksfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ GRAPH
sudo-user (>= 0.0.0)
cdo-secrets (0.1.7)
cdo-users (0.1.20)
cdo-varnish (0.3.207)
cdo-varnish (0.3.208)
apt (>= 0.0.0)
chef-client (4.2.4)
cron (>= 1.2.0)
Expand Down
8 changes: 4 additions & 4 deletions cookbooks/cdo-varnish/libraries/http_cache.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
require_relative 'shared_varnish_constants'

# HTTP Cache configuration.
#
# See cdo-varnish/README.md for more information on the configuration format.
class HttpCache
include SharedVarnishConstants

# Paths for files that are always cached based on their extension.
STATIC_ASSET_EXTENSION_PATHS = %w(css js mp3 jpg png).map {|ext| "/*.#{ext}"}.freeze

Expand Down Expand Up @@ -53,6 +49,10 @@ def self.cached_scripts
CACHED_SCRIPTS_MAP.keys
end

ALLOWED_WEB_REQUEST_HEADERS = %w(
Authorization
)

# HTTP-cache configuration that can be applied both to CDN (e.g. Cloudfront) and origin-local HTTP cache (e.g. Varnish).
# Whenever possible, the application should deliver correct HTTP response headers to direct cache behaviors.
# This hash provides extra application-specific configuration for whitelisting specific request headers and
Expand Down
9 changes: 0 additions & 9 deletions cookbooks/cdo-varnish/libraries/shared_varnish_constants.rb

This file was deleted.

2 changes: 1 addition & 1 deletion cookbooks/cdo-varnish/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
license 'All rights reserved'
description 'Installs/Configures cdo-varnish'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.3.207'
version '0.3.208'

depends 'apt'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class FacilitatorApplicationController < ApplicationController
include Pd::Application::ActiveApplicationModels
include Pd::FacilitatorCommonApplicationConstants
before_action do
@facilitator_program_url = 'https://docs.google.com/document/d/1aX-KH-t6tgjGk2WyvJ7ik7alH4kFTlZ0s1DsrCRBq6U'
@facilitator_program_url = 'https://code.org/files/facilitator/overview-2019-20.pdf'
end

def new
Expand Down
17 changes: 17 additions & 0 deletions dashboard/app/models/pd/application/facilitator1920_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class Facilitator1920Application < FacilitatorApplicationBase

before_save :log_status, if: -> {status_changed?}

after_create :clear_extraneous_answers

#override
def year
YEAR_19_20
Expand Down Expand Up @@ -321,5 +323,20 @@ def all_scores

all_score_hash
end

def clear_extraneous_answers
course_specific_questions_to_remove =
if course == 'csf'
[CSD_SPECIFIC_KEYS, CSP_SPECIFIC_KEYS].flatten.uniq
elsif course == 'csd'
[CSF_SPECIFIC_KEYS, CSP_SPECIFIC_KEYS - CSD_SPECIFIC_KEYS].flatten.uniq
elsif course == 'csp'
[CSF_SPECIFIC_KEYS, CSD_SPECIFIC_KEYS - CSP_SPECIFIC_KEYS].flatten.uniq
end

self.form_data_hash = sanitize_form_data_hash.except(*course_specific_questions_to_remove)

save
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
Applications to join the Facilitator Development Program are no longer being accepted this year.
Please check back again next year to apply.
If you’d like more information about the program, please check out the
= link_to('facilitator development program description', @facilitator_program_url) + '.'
= link_to('facilitator development program description', @facilitator_program_url, target: :_blank) + '.'
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
To get started, you first need to be logged into your Code.org account.
If you’d like more information about the program before you start your application,
please check out the
= link_to('facilitator development program description', @facilitator_program_url) + '.'
= link_to('facilitator development program description', @facilitator_program_url, target: :_blank) + '.'

%div
= link_to "/users/sign_in?user_return_to=#{request.fullpath}" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
to upgrade your account from student to teacher.
If you’d like more information about the program before you start your application,
please check out the
= link_to('facilitator development program description', @facilitator_program_url) + '.'
= link_to('facilitator development program description', @facilitator_program_url, target: :_blank) + '.'
3 changes: 3 additions & 0 deletions dashboard/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class Application < Rails::Application
size: 256.megabytes # max size of entire store
}

# Sprockets file cache limit must be greater than precompiled-asset total to prevent thrashing.
config.assets.cache_limit = 1.gigabyte

# turn off ActionMailer logging to avoid logging email addresses
ActionMailer::Base.logger = nil

Expand Down

0 comments on commit 57c0c5b

Please sign in to comment.