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

Teacher application hotfix #20050

Merged
merged 5 commits into from
Jan 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,19 @@ export class DetailViewContents extends React.Component {
};

handleSaveClick = () => {
let stateValues = [
'status',
'locked',
'notes',
'regional_partner_filter',
];

if (this.props.applicationData.application_type === 'Teacher') {
stateValues.push('pd_workshop_id');
}

const data = {
...(_.pick(this.state, [
'status',
'locked',
'notes',
'regional_partner_filter',
'pd_workshop_id'
])),
...(_.pick(this.state, stateValues)),
response_scores: JSON.stringify(this.state.response_scores)
};
$.ajax({
Expand Down
23 changes: 13 additions & 10 deletions dashboard/app/controllers/pd/teacher_application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ class Pd::TeacherApplicationController < ApplicationController

# GET /pd/teacher_application
def new
authorize! :create, Pd::TeacherApplication

@application_data = {
accountEmail: current_user.email,
hashedAccountEmail: current_user.hashed_email
}

if Pd::TeacherApplication.exists?(user: current_user)
render :submitted
end
redirect_to pd_application_teacher_path

# TODO: remove
# authorize! :create, Pd::TeacherApplication
#
# @application_data = {
# accountEmail: current_user.email,
# hashedAccountEmail: current_user.hashed_email
# }
#
# if Pd::TeacherApplication.exists?(user: current_user)
# render :submitted
# end
end

# GET /pd/teacher_application/manage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ class Pd::TeacherApplicationControllerTest < ::ActionController::TestCase
@teacher = create :teacher
end

# Both teachers and students can see the teacher application form.
# Note student accounts will be converted to teacher on create
# (see Pd::TeacherApplication.ensure_user_is_a_teacher).
test_user_gets_response_for :new, user: :teacher
test_user_gets_response_for :new, user: :student
test_redirect_to_sign_in_for :new
test 'redirects to new teacher application' do
sign_in @teacher
get :new
assert_response :redirect
assert_redirected_to '/pd/application/teacher'
end

def self.test_workshop_admin_only(method, action, success_response, params = nil)
test_user_gets_response_for action, user: -> {@teacher}, method: method, params: params, response: :forbidden
Expand Down