Skip to content

Commit

Permalink
merge origin/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchud committed Nov 8, 2024
1 parent 3ac1bcd commit 032a9ef
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 55 deletions.
10 changes: 6 additions & 4 deletions app/controllers/manage_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def index
end

def show
@submission = Submission.find(params[:id])
@challenge = current_user.challenge_manager_challenges.find(params[:challenge_id])
@phase = @challenge.phases.find(params[:phase_id])
@submission = @phase.submissions.find(params[:id])
end

def update
Expand All @@ -22,9 +24,9 @@ def update
end

def by_challenge_phase
@phase = Phase.where(id: params[:phase_id],
challenge_id: current_user.challenge_manager_challenges.collect(&:id)).first
@submissions = @phase ? @phase.submissions : []
@challenge = current_user.challenge_manager_challenges.find(params[:challenge_id])
@phase = @challenge.phases.find(params[:id])
@submissions = @phase.submissions
end

def submission_params
Expand Down
8 changes: 2 additions & 6 deletions app/helpers/manage_submissions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

module ManageSubmissionsHelper
def eligible_for_evaluation?(submission)
submission.judging_status.in?(%w[qualified selected winner])
end

def selected_to_advance?(submission)
submission.judging_status.in?(%w[selected winner])
end

def assigned_to_user?(user, submission)
submission.challenge_id.in?(user.challenge_manager_challenges.collect(&:id))
def selected_to_advance?(submission)
submission.judging_status.in?(%w[winner])
end
end
4 changes: 2 additions & 2 deletions app/views/manage_submissions/_phases_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
Manage Evaluators
</button>
<% unless phase.submissions.empty? %>
<a href=<%= "/manage_submissions/by_challenge_phase/#{phase.id}" %>>
<%= link_to(challenge_manage_submission_path(challenge, phase)) do %>
<button class="usa-button font-body-2xs text-no-wrap">
View Submissions
</button>
</a>
<% end %>
<% end %>
</div>
</td>
Expand Down
10 changes: 5 additions & 5 deletions app/views/manage_submissions/_submissions_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
Eligible for Evaluation
<span class="text-top">Eligible for Evaluation</span>
</div>
<% else %>
<input type="checkbox" disabled class="display-none mobile-lg:display-block">
Expand All @@ -34,7 +34,7 @@
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
Not Eligible for Evaluation
<span class="text-top">Not Eligible for Evaluation</span>
</div>
<% end %>
</div>
Expand All @@ -49,7 +49,7 @@
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
Selected to Advance
<span class="text-top">Selected to Advance</span>
</div>
<% else %>
<input type="checkbox" disabled class="display-none mobile-lg:display-block">
Expand All @@ -59,13 +59,13 @@
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
Not Selected to Advance
<span class="text-top">Not Selected to Advance</span>
</div>
<% end %>
</div>
</td>
<td data-label="Assigned Evaluators">
No evaluators assigned to this submission.
No evaluators assigned to this submission
</td>
<td>
N/A
Expand Down
16 changes: 0 additions & 16 deletions app/views/manage_submissions/by_challenge_phase.erb

This file was deleted.

10 changes: 10 additions & 0 deletions app/views/manage_submissions/by_challenge_phase.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1><%= challenge_phase_title(@phase.challenge, @phase) %></h1>
<p class="text-normal">View challenge submissions and manage evaluation progress.</p>

<% if @submissions.empty? %>
<div class="text-normal">
<p>This challenge phase does not currently have any submissions.</p>
</div>
<% else %>
<%= render partial: "submissions_table", locals: { submissions: @submissions } %>
<% end %>
14 changes: 4 additions & 10 deletions app/views/manage_submissions/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<% if assigned_to_user?(current_user, @submission) %>
<h1>Submission ID <%= @submission.id %></h1>
<p class="text-normal">View submission information and assign evaluators to evaluate the submission.</p>
<h1>Submission ID <%= @submission.id %></h1>
<p class="text-normal">View submission information and assign evaluators to evaluate the submission.</p>

<%= render partial: "submission_materials", locals: { submission: @submission } %>

<%= render partial: "comment_form", locals: { submission: @submission } %>

<% else %>
<p class="text-normal">You are not assigned to manage this submission.</p>
<% end %>
<%= render partial: "submission_materials", locals: { submission: @submission } %>
<%= render partial: "comment_form", locals: { submission: @submission } %>
10 changes: 8 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
get '/evaluation_forms/confirmation', to: 'evaluation_forms#confirmation'
resources :evaluation_forms
post '/evaluation_forms/clone', to: 'evaluation_forms#create_from_existing'
resources :manage_submissions, only: [:index, :show, :update]
get '/manage_submissions/by_challenge_phase/:phase_id', to: 'manage_submissions#by_challenge_phase'
resources :manage_submissions, only: [:index]
resources :challenges, only: [] do
resources :manage_submissions, only: [:show, :update] do
member do
get 'by_challenge_phase'
end
end
end

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
Expand Down
16 changes: 7 additions & 9 deletions spec/requests/manage_submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
challenge = create_challenge(user: challenge_user, title: "Boston Tea Party Cleanup")
phase = create_phase(challenge_id: challenge.id)

get "/manage_submissions/by_challenge_phase/#{phase.id}"
get by_challenge_phase_challenge_manage_submission_path(challenge, phase)
expect(response.body).to include("Boston Tea Party Cleanup")

expect(response.body).to include("This challenge phase does not currently have any submissions.")
Expand All @@ -72,7 +72,7 @@
phase = create_phase(challenge_id: challenge.id)
submission = create(:submission, challenge: challenge)

get "/manage_submissions/by_challenge_phase/#{phase.id}"
get by_challenge_phase_challenge_manage_submission_path(challenge, phase)
expect(response.body).to include("Boston Tea Party Cleanup")
expect(response.body).to include(submission.id.to_s)
end
Expand All @@ -81,17 +81,16 @@
challenge = create_challenge(title: "Star Spangled Banister")
phase = create_phase(challenge_id: challenge.id)

get "/manage_submissions/by_challenge_phase/#{phase.id}"
expect(response.body).not_to include("Star Spangled Banister")
expect(response.body).to include("You are not assigned to this challenge.")
get by_challenge_phase_challenge_manage_submission_path(challenge, phase)
expect(response).to have_http_status(:not_found)
end

it "renders a details page for an individual submission" do
challenge = create_challenge(user: challenge_user)
phase = create_phase(challenge_id: challenge.id)
submission = create(:submission, challenge: phase.challenge, brief_description: "This submission has legs.")

get manage_submission_path(submission)
get challenge_manage_submission_path(challenge, submission, phase_id: phase.id)
expect(response.body).to include(submission.id.to_s)
expect(response.body).to include(submission.brief_description)
end
Expand All @@ -101,9 +100,8 @@
phase = create_phase(challenge_id: challenge.id)
submission = create(:submission, challenge: phase.challenge, brief_description: "This submission has teeth.")

get manage_submission_path(submission)
expect(response.body).not_to include(submission.brief_description)
expect(response.body).to include("You are not assigned to manage this submission.")
get challenge_manage_submission_path(challenge, submission, phase_id: phase.id)
expect(response).to have_http_status(:not_found)
end
end

Expand Down
4 changes: 3 additions & 1 deletion spec/system/manage_submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
it "manage submissions index page is accessible with one challenge" do
challenge = create_challenge(user: user, title: "Boston Tea Party Cleanup")
create_phase(challenge_id: challenge.id)

visit manage_submissions_path
expect(user.role).to eq("challenge_manager")
expect(page).to have_content("Boston Tea Party Cleanup")
Expand All @@ -30,7 +31,8 @@
it "manage submissions by challenge phase page is accessible with one challenge" do
challenge = create_challenge(user: user, title: "Boston Tea Party Cleanup")
phase = create_phase(challenge_id: challenge.id)
visit "/manage_submissions/by_challenge_phase/#{phase.id}"

visit by_challenge_phase_challenge_manage_submission_path(challenge, phase)
expect(user.role).to eq("challenge_manager")
expect(page).to have_content("Boston Tea Party Cleanup")
expect(page).to(be_axe_clean)
Expand Down

0 comments on commit 032a9ef

Please sign in to comment.