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

[80] Submission Detail Page #257

Merged
merged 37 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
71a485e
WIP
stonefilipczak Oct 29, 2024
0869211
link from index
stonefilipczak Oct 31, 2024
2db488a
Merge branch 'dev' into 206_view_submissions
stonefilipczak Oct 31, 2024
dd46f8c
tests
stonefilipczak Oct 31, 2024
a328be1
helper methods
stonefilipczak Nov 1, 2024
b76cae6
icons
stonefilipczak Nov 4, 2024
340da9d
Merge remote-tracking branch 'origin/dev' into 206_view_submissions
stepchud Nov 4, 2024
2a651eb
add submission id label on mobile
stonefilipczak Nov 4, 2024
e5fc225
Update app/controllers/manage_submissions_controller.rb
stonefilipczak Nov 5, 2024
cacbaae
Update app/views/manage_submissions/_submissions_table.html.erb
stonefilipczak Nov 5, 2024
c83efc7
Update app/helpers/manage_submissions_helper.rb
stonefilipczak Nov 5, 2024
e9d73f5
scope phase to a user's challenges
stonefilipczak Nov 5, 2024
1580142
move tests into own file
stonefilipczak Nov 5, 2024
b82b779
rubocop
stonefilipczak Nov 5, 2024
a2e7ed7
add closing a tag
stonefilipczak Nov 5, 2024
cde14f4
add margin-right-1 to all icons
stonefilipczak Nov 6, 2024
eaca5b8
testing different states
stonefilipczak Nov 6, 2024
7170729
display booleans as checkboxes on desktop
stonefilipczak Nov 6, 2024
389a1b2
rubocop
stonefilipczak Nov 6, 2024
b4f70a8
set up page
stonefilipczak Nov 6, 2024
89a0e7e
more tests
stonefilipczak Nov 7, 2024
d6247d1
update submission from comment form
stonefilipczak Nov 7, 2024
6ee60fe
comment form
stonefilipczak Nov 7, 2024
3ac1bcd
rubocop
stonefilipczak Nov 7, 2024
032a9ef
merge origin/dev
stepchud Nov 8, 2024
e8a2661
Merge branch 'dev' into 80_submission_detail
stepchud Nov 8, 2024
adcfae4
update evaluation_form routes
stepchud Nov 8, 2024
6d3e79a
update manage_submission routes, DB migration text col
stepchud Nov 9, 2024
1af7ab4
Merge branch 'dev' into 80_submission_detail
stepchud Nov 14, 2024
7644f13
remove manage_ prefixes
stepchud Nov 14, 2024
8de8415
Merge remote-tracking branch 'origin/80_submission_detail' into 80_su…
stepchud Nov 14, 2024
5d5a20b
update session route
stepchud Nov 14, 2024
4b5dd1d
add phases specs
stepchud Nov 14, 2024
20a50ed
adds Submission.by_user(user) scope
stepchud Nov 14, 2024
fc8b85d
gitignore dev files
stepchud Nov 14, 2024
2681b81
revert removed association
stepchud Nov 14, 2024
2bf547e
fix specs, remove comment
stepchud Nov 14, 2024
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
2 changes: 1 addition & 1 deletion app/controllers/evaluation_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def update
respond_to do |format|
if @evaluation_form.update(evaluation_form_params)
format.html do
redirect_to evaluation_forms_confirmation_path, notice: I18n.t("evaluation_form_saved")
redirect_to confirmation_evaluation_form_path(@evaluation_form), notice: I18n.t("evaluation_form_saved")
end
format.json { render :show, status: :ok, location: @evaluation_form }
else
Expand Down
21 changes: 21 additions & 0 deletions app/controllers/manage_phases_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

class ManagePhasesController < ApplicationController
before_action -> { authorize_user('challenge_manager') }
before_action :set_phase, except: [:index]

def index
@challenges = current_user.challenge_manager_challenges
end

def submissions
@submissions = @phase.submissions
end

private

def set_phase
@phase = Phase.where(challenge: current_user.challenge_manager_challenges).find(params[:id])
@challenge = @phase.challenge
end
end
21 changes: 8 additions & 13 deletions app/controllers/manage_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

class ManageSubmissionsController < ApplicationController
before_action -> { authorize_user('challenge_manager') }
def index
@challenges = current_user.challenge_manager_challenges
end
before_action :set_submission, only: [:show, :update]

def show
@submission = Submission.find(params[:id])
end
def show; end

def update
@submission = Submission.find(params[:id])

if @submission.update!(submission_params)
flash.now[:success] = I18n.t("comments_saved")
render :show, submission: @submission
Expand All @@ -21,13 +15,14 @@ def update
end
end

def by_challenge_phase
stepchud marked this conversation as resolved.
Show resolved Hide resolved
@phase = Phase.where(id: params[:phase_id],
challenge_id: current_user.challenge_manager_challenges.collect(&:id)).first
@submissions = @phase ? @phase.submissions : []
end
private

def submission_params
params.require(:submission).permit(:comments)
end

# User access enforced through their assigned challenge_manager_challenges
def set_submission
@submission = Submission.where(challenge: current_user.challenge_manager_challenges).find(params[:id])
end
end
2 changes: 1 addition & 1 deletion app/helpers/dashboard_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def dashboard_cards_by_role
challenge_manager: [
{ image_path: 'emoji_events', href: Rails.configuration.phx_interop[:phx_uri],
alt: 'challenges', title: 'Challenges', subtitle: 'Create and manage challenges.' },
{ image_path: 'star_half', href: 'manage_submissions',
{ image_path: 'star_half', href: 'manage_phases',
alt: 'submissions and evaluations', title: 'Submissions & Evaluations', subtitle:
'Manage submissions, evaluations, and evaluators.' },
{ image_path: 'check_circle_outline', href: 'evaluation_forms',
Expand Down
11 changes: 0 additions & 11 deletions app/helpers/manage_submissions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# frozen_string_literal: true

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
stepchud marked this conversation as resolved.
Show resolved Hide resolved

def assigned_to_user?(user, submission)
stepchud marked this conversation as resolved.
Show resolved Hide resolved
submission.challenge_id.in?(user.challenge_manager_challenges.collect(&:id))
end
end
8 changes: 8 additions & 0 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ class Submission < ApplicationRecord

# Validations
validates :title, presence: true

def eligible_for_evaluation?
selected? or winner?
end

def selected_to_advance?
winner?
end
end
2 changes: 1 addition & 1 deletion app/views/layouts/_utility_menu.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= utility_menu_link('grid_view', dashboard_path, 'dashboard', 'Dashboard') %>
<% if current_user.role == "challenge_manager" %>
<%= utility_menu_link('emoji_events', Rails.configuration.phx_interop[:phx_uri], 'challenges', 'Challenges') %>
<%= utility_menu_link('star_half', manage_submissions_path, 'Manage Submissions and Evaluations', 'Submissions & Evaluations') %>
<%= utility_menu_link('star_half', manage_phases_path, 'Manage Submissions and Evaluations', 'Submissions & Evaluations') %>
<%= utility_menu_link('check_circle_outline', evaluation_forms_path, 'Evaluation Forms', 'Evaluation Forms') %>
<% end %>
<% if current_user.role == "evaluator" %>
Expand Down
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(submissions_manage_phase_path(phase)) do %>
<button class="usa-button font-body-2xs text-no-wrap">
View Submissions
</button>
</a>
<% end %>
<% end %>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
</th>
<td data-label="Eligible for Evaluation">
<div class="display-flex flex-align-center">
<% if eligible_for_evaluation?(submission) %>
<% if submission.eligible_for_evaluation? %>
<input type="checkbox" disabled checked class="display-none mobile-lg:display-block">
<div class="mobile-lg:display-none">
<%= image_tag(
"images/usa-icons/verified.svg",
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,22 +34,22 @@
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>
</td>
<td data-label="Selected to Advance">
<div class="display-flex flex-align-center">
<% if selected_to_advance?(submission) %>
<% if submission.selected_to_advance? %>
<input type="checkbox" disabled checked class="display-none mobile-lg:display-block">
<div class="mobile-lg:display-none">
<%= image_tag(
"images/usa-icons/star.svg",
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
stepchud marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
10 changes: 10 additions & 0 deletions app/views/manage_phases/submissions.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 %>
6 changes: 3 additions & 3 deletions app/views/manage_submissions/_comment_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_with(model: submission, url: manage_submission_path(submission), class: "width-mobile-lg") do |form| %>
<%= form_with(model: @submission, url: manage_submission_path(@submission), class: "width-mobile-lg") do |form| %>
<div class="usa-form-group">
<%= form.label :comments, class: "usa-label" %>
<%= form.text_area :comments, class: "usa-textarea", default: submission.comments %>
<%= form.label :comments, "Comments and notes:", class: "usa-label" %>
<%= form.text_area :comments, class: "usa-textarea", default: @submission.comments %>
</div>
<button type="submit" name="commit" class="usa-button font-body-2xs text-no-wrap margin-y-2">
Save
Expand Down
16 changes: 0 additions & 16 deletions app/views/manage_submissions/by_challenge_phase.erb
stepchud marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

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" %>
<%= render partial: "comment_form" %>
15 changes: 11 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
get '/dashboard', to: "dashboard#index"

resources :evaluations, only: [:index]
get '/evaluation_forms/confirmation', to: 'evaluation_forms#confirmation'
resources :evaluation_forms
post '/evaluation_forms/clone', to: 'evaluation_forms#create_from_existing'
resources :evaluation_forms do
member do
get 'confirmation'
post 'clone'
end
end
resources :manage_phases, only: [:index] do
member do
get :submissions
end
end
stepchud marked this conversation as resolved.
Show resolved Hide resolved
resources :manage_submissions, only: [:index, :show, :update]
get '/manage_submissions/by_challenge_phase/:phase_id', to: 'manage_submissions#by_challenge_phase'

# 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
2 changes: 1 addition & 1 deletion db/migrate/20241107161811_add_comments_to_submissions.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddCommentsToSubmissions < ActiveRecord::Migration[7.2]
def change
add_column :submissions, :comments, :string, null: true
add_column :submissions, :comments, :text, limit: 3000, null: true
end
end
4 changes: 2 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ CREATE TABLE public.oban_jobs (
attempted_by text[],
discarded_at timestamp without time zone,
priority integer DEFAULT 0 NOT NULL,
tags character varying(255)[] DEFAULT ARRAY[]::character varying[],
tags text[] DEFAULT ARRAY[]::text[],
meta jsonb DEFAULT '{}'::jsonb,
cancelled_at timestamp without time zone,
CONSTRAINT attempt_range CHECK (((attempt >= 0) AND (attempt <= max_attempts))),
Expand Down Expand Up @@ -1034,7 +1034,7 @@ CREATE TABLE public.submissions (
description_delta text,
brief_description_delta text,
pdf_reference character varying(255),
comments character varying
comments text
);


Expand Down
Loading
Loading