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 28 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
26 changes: 20 additions & 6 deletions app/controllers/manage_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@

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

def show; end

def update
if @submission.update!(submission_params)
flash.now[:success] = I18n.t("comments_saved")
render :show, submission: @submission
else
render :show, status: :unprocessable_entity, submission: @submission
end
end

private

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

def show
@challenge = current_user.challenge_manager_challenges.find(params[:challenge_id])
@phase = @challenge.phases.find(params[:id])
@submissions = @phase.submissions
# 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
7 changes: 0 additions & 7 deletions app/helpers/manage_submissions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# frozen_string_literal: true

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

def selected_to_advance?(submission)
submission.judging_status.in?(%w[winner])
end
end
11 changes: 10 additions & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Submission < ApplicationRecord
belongs_to :submitter, class_name: 'User'
belongs_to :challenge
belongs_to :phase
belongs_to :manager, class_name: 'User'
# I don't think we need this belongs_to anymore?
# belongs_to :manager, class_name: 'User'
has_many :evaluator_submission_assignments, dependent: :destroy
has_many :evaluators, through: :evaluator_submission_assignments, class_name: "User"

Expand All @@ -22,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,7 +39,7 @@
Manage Evaluators
</button>
<% unless phase.submissions.empty? %>
<%= link_to(challenge_manage_submission_path(challenge, phase)) do %>
<%= link_to(submissions_manage_phase_path(phase)) do %>
<button class="usa-button font-body-2xs text-no-wrap">
View Submissions
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</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(
Expand All @@ -41,7 +41,7 @@
</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(
Expand Down Expand Up @@ -72,9 +72,11 @@
</td>
<td>
<div class="display-flex flex-no-wrap grid-row grid-gap-1">
<button class="usa-button font-body-2xs text-no-wrap">
View Submission
</button>
<%= link_to manage_submission_path(submission) do %>
<button class="usa-button font-body-2xs text-no-wrap">
View Submission
</button>
<% end %>
</div>
</td>
</tr>
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 %>
9 changes: 9 additions & 0 deletions app/views/manage_submissions/_comment_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= form_with(model: @submission, url: manage_submission_path(@submission), class: "width-mobile-lg") do |form| %>
<div class="usa-form-group">
<%= 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
</button>
<% end %>
23 changes: 23 additions & 0 deletions app/views/manage_submissions/_submission_materials.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h3>Brief Description:</h3>
<p class="text-normal"><%= @submission.brief_description %></p>

<h3>Description:</h3>
<p class="text-normal"><%= @submission.description %></p>

<h3>External URL:</h3>
<a href=<%= @submission.external_url %>><%= @submission.external_url %></a>

<h3>Status:</h3>
<p class="text-normal"><%= @submission.status.capitalize %></p>

<h3>Submitter:</h3>
<p class="text-normal"><%= @submission.submitter.email %></p>

<h3>Last Updated Date:</h3>
<p class="text-normal"><%= @submission.updated_at %></p>

<h3>Submission ID:</h3>
<p class="text-normal"><%= @submission.id %></p>

<h3>Title:</h3>
<p class="text-normal"><%= @submission.title %></p>
13 changes: 4 additions & 9 deletions app/views/manage_submissions/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<h1><%= challenge_phase_title(@phase.challenge, @phase) %></h1>
<p class="text-normal">View challenge submissions and manage evaluation progress.</p>
<h1>Submission ID <%= @submission.id %></h1>
<p class="text-normal">View submission information and assign evaluators to evaluate the submission.</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 %>
<%= render partial: "submission_materials" %>
<%= render partial: "comment_form" %>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ en:
already_logged_in_notice: "You are already logged in."
evaluation_form_destroyed: "Evaluation form was successfully destroyed."
evaluation_form_saved: "Evaluation form was saved successfully."
comments_saved: "Comments saved succesfully."
login_error: "There was an issue with logging in. Please try again."
please_try_again: "Please try again."
session_expired_alert: "Your session has expired. Please log in again."
Expand Down
17 changes: 11 additions & 6 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +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 :manage_submissions, only: [:index]
resources :challenges, only: [] do
resources :manage_submissions, only: [:show]
resources :evaluation_forms do
member do
get 'confirmation'
post 'clone'
end
end
resources :manage_phases, only: [:index] do
member do
get :submissions
end
end
resources :manage_submissions, only: [:index, :show, :update]

# 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
5 changes: 5 additions & 0 deletions db/migrate/20241107161811_add_comments_to_submissions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCommentsToSubmissions < ActiveRecord::Migration[7.2]
def change
add_column :submissions, :comments, :text, limit: 3000, null: true
end
end
4 changes: 3 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,8 @@ CREATE TABLE public.submissions (
review_verified boolean,
description_delta text,
brief_description_delta text,
pdf_reference character varying(255)
pdf_reference character varying(255),
comments text
);


Expand Down Expand Up @@ -2255,6 +2256,7 @@ ALTER TABLE ONLY public.winners
SET search_path TO "$user", public;

INSERT INTO "schema_migrations" (version) VALUES
(20241107161811),
(20241023195356),
(20241018150049),
(20241017172408),
Expand Down
4 changes: 3 additions & 1 deletion spec/factories/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
association :challenge
association :phase
association :submitter, factory: :user
association :manager, factory: :user
# don't think we need this anymore?
# association :manager, factory: :user

title { Faker::Lorem.sentence }
status { "draft" }
end
end
Loading
Loading