Date: Sat, 9 May 2020 09:21:04 -0700
Subject: [PATCH 31/58] removed unused routes and views, updated controllers
with more authentication
---
app/controllers/application_controller.rb | 1 -
app/controllers/assignments_controller.rb | 25 --------------
app/controllers/case_notes_controller.rb | 28 ---------------
app/controllers/pages_controller.rb | 28 ++++++++-------
app/controllers/paperworks_controller.rb | 29 ----------------
app/controllers/participants_controller.rb | 7 ++--
.../personal_questionnaires_controller.rb | 34 -------------------
.../professional_questionnaires_controller.rb | 29 ----------------
.../studio_assessments_controller.rb | 24 -------------
app/policies/action_item_policy.rb | 13 -------
app/policies/assignment_policy.rb | 15 --------
app/policies/case_note_policy.rb | 3 +-
app/policies/paperwork_policy.rb | 15 +++++---
app/policies/participant_policy.rb | 10 ++----
app/policies/questionnaire_policy.rb | 9 +++--
app/policies/staff_policy.rb | 8 +----
app/policies/studio_assessment_policy.rb | 2 +-
app/views/assignments/edit.html.erb | 30 ----------------
app/views/assignments/new.html.erb | 5 ---
app/views/assignments/show.html.erb | 21 ------------
app/views/case_notes/edit.html.erb | 23 -------------
app/views/case_notes/index.html.erb | 26 --------------
app/views/case_notes/new.html.erb | 14 --------
app/views/case_notes/show.html.erb | 22 ------------
app/views/paperworks/edit.html.erb | 23 -------------
app/views/paperworks/index.html.erb | 27 ---------------
app/views/paperworks/show.html.erb | 18 ----------
.../personal_questionnaires/index.html.erb | 2 --
.../index.html.erb | 1 -
29 files changed, 40 insertions(+), 452 deletions(-)
delete mode 100644 app/views/assignments/edit.html.erb
delete mode 100644 app/views/assignments/new.html.erb
delete mode 100644 app/views/assignments/show.html.erb
delete mode 100644 app/views/case_notes/edit.html.erb
delete mode 100644 app/views/case_notes/index.html.erb
delete mode 100644 app/views/case_notes/new.html.erb
delete mode 100644 app/views/case_notes/show.html.erb
delete mode 100644 app/views/paperworks/edit.html.erb
delete mode 100644 app/views/paperworks/index.html.erb
delete mode 100644 app/views/paperworks/show.html.erb
delete mode 100644 app/views/personal_questionnaires/index.html.erb
delete mode 100644 app/views/professional_questionnaires/index.html.erb
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 8661f1cb..52649375 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -21,7 +21,6 @@ def set_raven_context
provider: current_user.provider,
uid: current_user.uid,
user_type: current_user.user_type,
- admin: current_user.admin
)
end
end
diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb
index b49c09b8..b28b0dfe 100644
--- a/app/controllers/assignments_controller.rb
+++ b/app/controllers/assignments_controller.rb
@@ -1,5 +1,4 @@
class AssignmentsController < ApplicationController
- before_action :set_action_item, only:[:show, :edit]
def index
@assignments = authorize Assignment.all
@user = current_user
@@ -16,30 +15,6 @@ def index
"id" => p.id}
@participants_list.push(d)
end
- skip_policy_scope
end
- def new
- @assignment = authorize Assignment.new
- end
-
- def edit
- authorize @assignment
- @staffs = Staff.all
- @all_users = User.all
- end
-
- def show
- authorize @assignment
- end
-
- private
-
- def set_action_item
- @assignment = Assignment.find(params[:id])
- rescue ActiveRecord::RecordNotFound => exception
- Raven.extra_context(assignment: params[:id])
- Raven.capture_exception(exception)
- redirect_to assignments_path
- end
end
diff --git a/app/controllers/case_notes_controller.rb b/app/controllers/case_notes_controller.rb
index 026e0070..71aeb9b8 100644
--- a/app/controllers/case_notes_controller.rb
+++ b/app/controllers/case_notes_controller.rb
@@ -1,31 +1,3 @@
class CaseNotesController < ApplicationController
- before_action :set_case_note, only: [:show, :edit]
-
- def index
- @case_notes = authorize CaseNote.all
- skip_policy_scope
- end
-
- def new
- @case_note = authorize CaseNote.new
- @participants = Participant.all
- end
-
- def edit
- @participants = Participant.all
- end
-
- def show
- end
-
- private
-
- def set_case_note
- @case_note = authorize CaseNote.find(params[:id])
- rescue ActiveRecord::RecordNotFound => exception
- Raven.extra_context(case_note_id: params[:id])
- Raven.capture_exception(exception)
- redirect_to case_notes_path
- end
end
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 56872c48..da79b695 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -1,15 +1,16 @@
class PagesController < ApplicationController
def dashboard
- path = case current_user.user_type
+ @user = current_user
+
+ path = case @user.user_type
when 'staff'
- @user = current_user
- @participants = Participant.all
+ @participants = authorize Participant.all
@participants_list = []
@participants.each do |p|
if p.personal_questionnaire.nil?
PersonalQuestionnaire.create("participant_id": p.id)
end
- d = {"name" => p.full_name,
+ d = {"name" => p.full_name,
"status" => p.status,
"id" => p.id,
"case_notes_count" => p.case_notes.length,
@@ -24,24 +25,25 @@ def dashboard
authorize Staff
dashboard_staffs_path
when 'participant'
- @user = current_user
@participant = @user.participant
- @paperworks = @user.participant.paperworks
- @case_notes = @user.participant.case_notes.where(visible: true)
+ @paperworks = policy_scope(Paperwork)
+ @case_notes = policy_scope(CaseNote)
+ @studio_assessments = policy_scope(StudioAssessment)
if @participant.personal_questionnaire.nil?
- @personal_questionnaire = PersonalQuestionnaire.create("participant_id": @participant.id)
+ personal_q = PersonalQuestionnaire.create("participant_id": @participant.id)
else
- @personal_questionnaire = @participant.personal_questionnaire
+ personal_q = authorize @participant.personal_questionnaire, policy_class: QuestionnairePolicy
end
+ @personal_questionnaire = PersonalQuestionnaireSerializer.new(personal_q)
+
if @participant.professional_questionnaire.nil?
- @professional_questionnaire = ProfessionalQuestionnaire.create("participant_id": @participant.id)
+ professional_q = ProfessionalQuestionnaire.create("participant_id": @participant.id)
else
- @professional_questionnaire = @participant.professional_questionnaire
+ professional_q = authorize @participant.professional_questionnaire, policy_class: QuestionnairePolicy
end
-
- @studio_assessments = @participant.studio_assessments
+ @professional_questionnaire = ProfessionalQuestionnairesSerializer.new(professional_q)
authorize Participant
dashboard_participants_path
diff --git a/app/controllers/paperworks_controller.rb b/app/controllers/paperworks_controller.rb
index d1f44fff..c8579823 100644
--- a/app/controllers/paperworks_controller.rb
+++ b/app/controllers/paperworks_controller.rb
@@ -1,31 +1,2 @@
class PaperworksController < ApplicationController
- before_action :set_paperwork, only: [:show, :edit]
-
- def index
- @paperworks = authorize Paperwork.all
- @user = current_user
- skip_policy_scope
- end
-
- def show
- end
-
- def new
- @paperwork = authorize Paperwork.new
- @participants = Participant.all
- end
-
- def edit
- @participants = Participant.all
- end
-
- private
-
- def set_paperwork
- @paperwork = authorize Paperwork.find(params[:id])
- rescue ActiveRecord::RecordNotFound => exception
- Raven.extra_context(paperework_id: params[:id])
- Raven.capture_exception(exception)
- redirect_to paperworks_path
- end
end
diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb
index 4f768aeb..e3925a74 100644
--- a/app/controllers/participants_controller.rb
+++ b/app/controllers/participants_controller.rb
@@ -2,9 +2,11 @@ class ParticipantsController < ApplicationController
before_action :set_participant, only: [:show]
def show
+ # TODO CHECK IF CORRECT
@participant = authorize Participant.find(params[:id])
- @paperworks = @participant.paperworks
- @case_notes = @participant.case_notes
+ @paperworks = authorize @participant.paperworks
+ @case_notes = authorize @participant.case_notes
+ @studio_assessments = authorize @participant.studio_assessments
if @participant.personal_questionnaire.nil?
personal_q = PersonalQuestionnaire.create("participant_id": @participant.id)
@@ -21,7 +23,6 @@ def show
end
@professional_questionnaire = ProfessionalQuestionnairesSerializer.new(professional_q)
- @studio_assessments = @participant.studio_assessments
end
def dashboard
diff --git a/app/controllers/personal_questionnaires_controller.rb b/app/controllers/personal_questionnaires_controller.rb
index d9474794..8e89d250 100644
--- a/app/controllers/personal_questionnaires_controller.rb
+++ b/app/controllers/personal_questionnaires_controller.rb
@@ -1,36 +1,2 @@
class PersonalQuestionnairesController < ApplicationController
- before_action :set_personal_questionnaire, only: [:show, :edit]
-
- def index
- skip_policy_scope
- @questionnaires = PersonalQuestionnaire.all
- @questionnaireFields = PersonalQuestionnaire.column_names
- @user = current_user
- end
-
- def show
- end
-
- def new
- @questionnaire = authorize PersonalQuestionnaire.new, policy_class: QuestionnairePolicy
- @participants = Participant.all
- end
-
- def edit
- end
-
- def user_not_authorized
- flash[:alert] = "You are not authorized to perform this action."
- redirect_to(request.referrer || root_path)
- end
-
- private
-
- def set_personal_questionnaire
- @questionnaire = authorize PersonalQuestionnaire.find(params[:id]), policy_class: QuestionnairePolicy
- rescue ActiveRecord::RecordNotFound => exception
- Raven.extra_context(personal_questionnaire_id: params[:id])
- Raven.capture_exception(exception)
- redirect_to personal_questionnaires_path
- end
end
diff --git a/app/controllers/professional_questionnaires_controller.rb b/app/controllers/professional_questionnaires_controller.rb
index f9c4afb8..b5d1d373 100644
--- a/app/controllers/professional_questionnaires_controller.rb
+++ b/app/controllers/professional_questionnaires_controller.rb
@@ -1,31 +1,2 @@
class ProfessionalQuestionnairesController < ApplicationController
- before_action :set_professional_questionnaire, only: [:show, :edit]
-
- def index
- @questionnaires = authorize ProfessionalQuestionnaire.all
- @questionnaireFields = ProfessionalQuestionnaire.column_names
- @user = current_user
- end
-
- def show
- end
-
- def new
- @questionnaire = authorize ProfessionalQuestionnaire.new, policy_class: QuestionnairePolicy
- @participants = Participant.all
- end
-
- def edit
- end
-
- private
-
- def set_professional_questionnaire
- @questionnaire = authorize ProfessionalQuestionnaire.find(params[:id]), policy_class: QuestionnairePolicy
- rescue ActiveRecord::RecordNotFound => exception
- Raven.extra_context(professional_questionnaire_id: params[:id])
- Raven.capture_exception(exception)
- redirect_to professional_questionnaires_path
- end
-
end
\ No newline at end of file
diff --git a/app/controllers/studio_assessments_controller.rb b/app/controllers/studio_assessments_controller.rb
index 59a25b7d..e8b485ef 100644
--- a/app/controllers/studio_assessments_controller.rb
+++ b/app/controllers/studio_assessments_controller.rb
@@ -1,10 +1,7 @@
class StudioAssessmentsController < ApplicationController
- before_action :set_studio_assessment, only: [:show, :edit]
-
# GET /studio_assessments
# GET /studio_assessments.json
def index
- skip_policy_scope
@studio_assessments = authorize StudioAssessment.all
@studio_list = []
@studio_assessments.each do |s|
@@ -26,25 +23,4 @@ def index
end
end
-
- # GET /studio_assessments/1
- # GET /studio_assessments/1.json
- def show
- authorize @studio_assessment
- end
-
- # GET /studio_assessments/new
- def new
- @studio_assessment = authorize StudioAssessment.new
- @participants = Participant.all
- end
-
- private
- def set_studio_assessment
- @studio_assessment = authorize StudioAssessment.find(params[:id])
- rescue ActiveRecord::RecordNotFound => exception
- Raven.extra_context(studio_assessment_id: params[:id])
- Raven.capture_exception(exception)
- redirect_to studio_assessments_path
- end
end
diff --git a/app/policies/action_item_policy.rb b/app/policies/action_item_policy.rb
index 4f5c0241..1790ec08 100644
--- a/app/policies/action_item_policy.rb
+++ b/app/policies/action_item_policy.rb
@@ -15,19 +15,6 @@ def show?
staff?
end
-
- class Scope < Scope
-# The first argument is a user. In your controller, Pundit will call the current_user method
-# to retrieve what to send into this argument.
-# The second argument is a scope of some kind on which to perform some kind of query.
-# It will usually be an ActiveRecord class or a ActiveRecord::Relation.
- def resolve
- if user.staff?
- scope.all
- end
- end
- end
-
private
def staff?
diff --git a/app/policies/assignment_policy.rb b/app/policies/assignment_policy.rb
index 67263fa7..a0ac8f68 100644
--- a/app/policies/assignment_policy.rb
+++ b/app/policies/assignment_policy.rb
@@ -19,21 +19,6 @@ def index?
staff?
end
-
- class Scope < Scope
-# The first argument is a user. In your controller, Pundit will call the current_user method
-# to retrieve what to send into this argument.
-# The second argument is a scope of some kind on which to perform some kind of query.
-# It will usually be an ActiveRecord class or a ActiveRecord::Relation.
- def resolve
- if user.staff?
- scope.all
- else
- scope.where([participant_id: user.id])
- end
- end
- end
-
private
def staff?
diff --git a/app/policies/case_note_policy.rb b/app/policies/case_note_policy.rb
index 662f9d7d..f7ab32c9 100644
--- a/app/policies/case_note_policy.rb
+++ b/app/policies/case_note_policy.rb
@@ -36,13 +36,12 @@ def resolve
if user.staff?
scope.all
else
- scope.where([participant_id: user.participant.id, visible: true])
+ scope.where(participant_id: user.participant.id, visible: true)
end
end
end
private
-
def staff?
user.present? && user.staff?
end
diff --git a/app/policies/paperwork_policy.rb b/app/policies/paperwork_policy.rb
index 65127d3d..4c2e47fb 100644
--- a/app/policies/paperwork_policy.rb
+++ b/app/policies/paperwork_policy.rb
@@ -1,14 +1,14 @@
class PaperworkPolicy < ApplicationPolicy
def index?
- user.staff?
+ staff?
end
def create?
- user.staff?
+ staff?
end
def destroy?
- user.staff?
+ staff?
end
def viewed?
@@ -20,11 +20,11 @@ def complete?
end
def show?
- user.staff? || (user.participant? && user.participant.id == resource.participant_id)
+ staff? || (user.participant? && user.participant.id == resource.participant_id)
end
def update?
- user.staff?
+ staff?
end
class Scope < Scope
@@ -40,4 +40,9 @@ def resolve
end
end
end
+
+ private
+ def staff?
+ user.present? && user.staff?
+ end
end
diff --git a/app/policies/participant_policy.rb b/app/policies/participant_policy.rb
index 6d870a8e..e4d70750 100644
--- a/app/policies/participant_policy.rb
+++ b/app/policies/participant_policy.rb
@@ -1,12 +1,6 @@
class ParticipantPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope.all
- end
- end
-
def show?
- user.staff?
+ user.present? && user.staff?
end
def dashboard?
@@ -14,6 +8,6 @@ def dashboard?
end
def statuses?
- user.staff?
+ user.present? && user.staff?
end
end
diff --git a/app/policies/questionnaire_policy.rb b/app/policies/questionnaire_policy.rb
index aee54285..9425ac1b 100644
--- a/app/policies/questionnaire_policy.rb
+++ b/app/policies/questionnaire_policy.rb
@@ -1,8 +1,12 @@
class QuestionnairePolicy < ApplicationPolicy
# this will work with personal questionnaires and professional questionnaires, but must be called with
# authorize questionnaire otherwise will not be automatically called
+ def dashboard?
+ !resource or staff? or (user.participant? && user.participant.id == resource.participant_id)
+ end
+
def create?
- user.present? && user.staff?
+ staff?
end
def show?
@@ -20,9 +24,8 @@ def update?
def destroy?
staff?
end
-
+
private
-
def staff?
user.present? && user.staff?
end
diff --git a/app/policies/staff_policy.rb b/app/policies/staff_policy.rb
index 4971e8d7..c21fd7ef 100644
--- a/app/policies/staff_policy.rb
+++ b/app/policies/staff_policy.rb
@@ -1,11 +1,5 @@
class StaffPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope.all
- end
- end
-
def dashboard?
- user.staff?
+ user.present? && user.staff?
end
end
diff --git a/app/policies/studio_assessment_policy.rb b/app/policies/studio_assessment_policy.rb
index 9cd09708..cddb7998 100644
--- a/app/policies/studio_assessment_policy.rb
+++ b/app/policies/studio_assessment_policy.rb
@@ -1,4 +1,4 @@
-class StudioAssessmentPolicy < ApplicationPolicy
+class StudioAssessmentPolicy < ApplicationPolicy
def index?
staff?
end
diff --git a/app/views/assignments/edit.html.erb b/app/views/assignments/edit.html.erb
deleted file mode 100644
index 1c9478db..00000000
--- a/app/views/assignments/edit.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-Editing Assignment
-
-<%= form_with(model: @assignment, url: api_assignment_path, local: true) do |form| %>
-
- <%= form.label :title %>
- <%= form.text_field :cond_assignment_title %>
-
-
- <%= form.label :description %>
- <%= form.text_field :cond_assignment_description %>
-
-
- Assigned to:
- <%= form.collection_select :participant_id, @all_users, :id, :first_name, prompt: true %>
-
-
- Assigned by:
- <%= form.collection_select :staff_id, @staffs, :id, :first_name, prompt: true %>
-
-
- <%= form.label :completed %>
- <%= form.check_box :completed %>
-
-
- <%= form.submit %>
-
-<% end %>
-
-<%= link_to 'Show', @assignment %> |
-<%= link_to 'Back', assignments_path %>
diff --git a/app/views/assignments/new.html.erb b/app/views/assignments/new.html.erb
deleted file mode 100644
index 0ffed097..00000000
--- a/app/views/assignments/new.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-New Assignment
-
-<%= render 'form', assignment: @assignment %>
-
-<%= link_to 'Back', assignments_path %>
diff --git a/app/views/assignments/show.html.erb b/app/views/assignments/show.html.erb
deleted file mode 100644
index c2a70f35..00000000
--- a/app/views/assignments/show.html.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-
- Title:
- <%= @assignment.cond_assignment_title %>
-
-
-
- Description:
- <%= @assignment.cond_assignment_description %>
-
-
- Assigned by:
- <%= @assignment.staff.cond_full_name %>
-
-
- Assigned to:
- <%= @assignment.participant.full_name %>
-
-
-
-<%= link_to 'Edit', edit_assignment_path(@assignment) %>
-<%= link_to 'Back', assignments_path %>
diff --git a/app/views/case_notes/edit.html.erb b/app/views/case_notes/edit.html.erb
deleted file mode 100644
index f7d7e043..00000000
--- a/app/views/case_notes/edit.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-
Edit Case Note
-<%= form_with(model: @case_note, url: api_case_note_path, local: true) do |form| %>
-
- <%= form.label :title %>
- <%= form.text_field :title %>
-
-
- <%= form.label :description %>
- <%= form.text_field :description %>
-
-
- Participant:
- <%= form.collection_select :participant_id, @participants, :id, :first_name, prompt: true %>
-
-
- <%= form.label :visible %>
- <%= form.check_box :visible %>
-
-
- <%= form.submit %>
-
-<% end %>
-<%= link_to 'Back', case_notes_path %>
\ No newline at end of file
diff --git a/app/views/case_notes/index.html.erb b/app/views/case_notes/index.html.erb
deleted file mode 100644
index 9aad859c..00000000
--- a/app/views/case_notes/index.html.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-All Case Notes
-
-
- Title |
- Description |
- Participant First |
- Participant Last |
- Visible |
- |
-
-
- <% @case_notes.each do |case_note| %>
-
- <%= case_note.title %> |
- <%= case_note.description %> |
- <%= case_note.participant.first_name %> |
- <%= case_note.participant.last_name %> |
- <%= case_note.visible %> |
- <%= link_to 'Show', case_note_path(case_note) %> |
- <%= link_to 'Edit', edit_case_note_path(case_note) %> |
- <%= link_to 'Delete', api_case_note_path(case_note),
- method: :delete,
- data: { confirm: 'Are you sure?' } %> |
-
- <% end %>
-
diff --git a/app/views/case_notes/new.html.erb b/app/views/case_notes/new.html.erb
deleted file mode 100644
index d924cd04..00000000
--- a/app/views/case_notes/new.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-New Case Notes
-<%= form_with scope: :case_note, url: api_case_notes_path, local: true do |form| %>
- Title:
- <%= form.text_field :title %>
- Description:
- <%= form.text_field :description %>
- Participant:
- <%= form.collection_select :participant_id, @participants, :id, :first_name, prompt: true %>
-
- Visible:
- <%= form.check_box :agree %>
-
- <%= form.submit "Submit" %>
-<% end %>
\ No newline at end of file
diff --git a/app/views/case_notes/show.html.erb b/app/views/case_notes/show.html.erb
deleted file mode 100644
index 24dd9896..00000000
--- a/app/views/case_notes/show.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-<%= link_to 'Edit', edit_case_note_path(@case_note) %>
-<%= link_to 'Delete', api_case_note_path(@case_note),
- method: :delete,
- data: { confirm: 'Are you sure?' } %>
-
- Title:
- <%= @case_note.title %>
-
-
- Description:
- <%= @case_note.description %>
-
-
- Participant:
- <%= @case_note.participant.first_name %>
-
-
- Visible:
- <%= @case_note.visible %>
-
-
- <%= link_to 'Back', case_notes_path%>
\ No newline at end of file
diff --git a/app/views/paperworks/edit.html.erb b/app/views/paperworks/edit.html.erb
deleted file mode 100644
index bd4ffa6b..00000000
--- a/app/views/paperworks/edit.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-
Edit Paperwork
-<%= form_with(model: @paperwork, url: api_paperwork_path, local: true) do |form| %>
-
- <%= form.label :title %>
- <%= form.text_field :title %>
-
-
- <%= form.label :link %>
- <%= form.text_field :link %>
-
-
- Participant:
- <%= form.collection_select :participant_id, @participants, :id, :first_name, prompt: true %>
-
-
- <%= form.label :agree %>
- <%= form.check_box :agree %>
-
-
- <%= form.submit %>
-
-<% end %>
-<%= link_to 'Back', paperworks_path %>
\ No newline at end of file
diff --git a/app/views/paperworks/index.html.erb b/app/views/paperworks/index.html.erb
deleted file mode 100644
index 86c24e1b..00000000
--- a/app/views/paperworks/index.html.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-All Paperworks
-
-
-
- Title |
- Link |
- Participant First |
- Participant Last |
- Agree |
- |
-
-
- <% @paperworks.each do |paperwork| %>
-
- <%= paperwork.title %> |
- <%= paperwork.link %> |
- <%= paperwork.participant.first_name %> |
- <%= paperwork.participant.last_name %> |
- <%= paperwork.agree %> |
- <%= link_to 'Show', paperwork_path(paperwork) %> |
- <%= link_to 'Edit', edit_paperwork_path(paperwork) %> |
- <%= link_to 'Delete', api_paperwork_path(paperwork),
- method: :delete,
- data: { confirm: 'Are you sure?' } %> |
-
- <% end %>
-
diff --git a/app/views/paperworks/show.html.erb b/app/views/paperworks/show.html.erb
deleted file mode 100644
index 1e416492..00000000
--- a/app/views/paperworks/show.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-<%= link_to 'Edit', edit_paperwork_path(@paperwork) %>
-<%= link_to 'Delete', api_paperwork_path(@paperwork),
- method: :delete,
- data: { confirm: 'Are you sure?' } %>
-
- Title:
- <%= @paperwork.title %>
-
-
- Link:
- <%= @paperwork.link %>
-
-
- Agree:
- <%= @paperwork.agree %>
-
-
- <%= link_to 'Back', paperworks_path%>
\ No newline at end of file
diff --git a/app/views/personal_questionnaires/index.html.erb b/app/views/personal_questionnaires/index.html.erb
deleted file mode 100644
index bbb179bc..00000000
--- a/app/views/personal_questionnaires/index.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<%= react_component("QuestionnaireForm", {questionnaireType: "Personal", fields: @questionnaireFields}) %>
-
diff --git a/app/views/professional_questionnaires/index.html.erb b/app/views/professional_questionnaires/index.html.erb
deleted file mode 100644
index 67b85228..00000000
--- a/app/views/professional_questionnaires/index.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= react_component("QuestionnaireForm", {questionnaireType: "Professional", fields: @questionnaireFields}) %>
From 867ba52083cc68110e73c76c00c827ab54753098 Mon Sep 17 00:00:00 2001
From: didvi
Date: Sat, 9 May 2020 09:51:52 -0700
Subject: [PATCH 32/58] changed login message and fixed dashboard pundit
---
app/controllers/pages_controller.rb | 2 +-
config/locales/devise.en.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index da79b695..d50509e1 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -4,7 +4,7 @@ def dashboard
path = case @user.user_type
when 'staff'
- @participants = authorize Participant.all
+ @participants = Participant.all
@participants_list = []
@participants.each do |p|
if p.personal_questionnaire.nil?
diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml
index ca3d6199..a467065d 100644
--- a/config/locales/devise.en.yml
+++ b/config/locales/devise.en.yml
@@ -14,7 +14,7 @@ en:
last_attempt: "You have one more attempt before your account is locked."
not_found_in_database: "Invalid %{authentication_keys} or password."
timeout: "Your session expired. Please sign in again to continue."
- unauthenticated: "You need to sign in or sign up before continuing."
+ unauthenticated: "You need to sign in or contact a staff member to create an account for you."
unconfirmed: "You have to confirm your email address before continuing."
mailer:
confirmation_instructions:
From f8dc45a97a94608b93b554ebc5c94154bba8bec1 Mon Sep 17 00:00:00 2001
From: didvi
Date: Sat, 9 May 2020 09:52:23 -0700
Subject: [PATCH 33/58] fixed valid phone bug in questionnaire
---
.../components/QuestionnaireForm/index.js | 21 +++++++------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/app/javascript/components/QuestionnaireForm/index.js b/app/javascript/components/QuestionnaireForm/index.js
index ea94ad48..86cc35fc 100644
--- a/app/javascript/components/QuestionnaireForm/index.js
+++ b/app/javascript/components/QuestionnaireForm/index.js
@@ -39,9 +39,9 @@ class QuestionnaireForm extends React.Component {
questionnaire[k] = this.props.questionnaire[k];
}
});
- questionnaire.validPhone = true;
this.setState({
questionnaire,
+ validPhone: true,
});
}
@@ -88,26 +88,21 @@ class QuestionnaireForm extends React.Component {
const isValid = regex.test(value);
if (isValid || value === '') {
this.setState(s => ({
+ validPhone: true,
questionnaire: {
...s.questionnaire,
- validPhone: true,
+ [id]: value,
},
}));
} else {
this.setState(s => ({
+ validPhone: false,
questionnaire: {
...s.questionnaire,
- validPhone: false,
+ [id]: value,
},
}));
}
-
- this.setState(s => ({
- questionnaire: {
- ...s.questionnaire,
- [id]: value,
- },
- }));
}
handleRadioChange(e, fieldName, newValue) {
@@ -300,11 +295,9 @@ class QuestionnaireForm extends React.Component {
this.handlePhoneChange(e)}
- error={!this.state.questionnaire.validPhone}
+ error={!this.state.validPhone}
helperText={
- !this.state.questionnaire.validPhone
- ? 'Please enter a valid phone number.'
- : ''
+ !this.state.validPhone ? 'Please enter a valid phone number.' : ''
}
variant="outlined"
id={fieldName}
From 36b907473b1626587b029c3d7635a7d861f24797 Mon Sep 17 00:00:00 2001
From: didvi
Date: Sat, 9 May 2020 12:07:58 -0700
Subject: [PATCH 34/58] allow questionnaires to be marked complete when
optional categories are unfilled
---
app/controllers/pages_controller.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 56872c48..f64a4265 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -64,6 +64,10 @@ def completed(p)
end
p.personal_questionnaire.attributes.each do |a, v|
+ if a == 'emergency_contact_2_name' || a == 'emergency_contact_2_phone_number' || a ==
+ 'emergency_contact_2_relationship'
+ next
+ end
if !v
return false
end
From 42e548f1e0d8078c968fd0fe5ca306a549e65076 Mon Sep 17 00:00:00 2001
From: Julian Kung
Date: Sun, 10 May 2020 20:23:46 -0700
Subject: [PATCH 35/58] Can exit submit modal on error
---
.../components/ActionItemCreationPage/index.js | 11 +++++++++++
.../components/ActionItemSearchParticipants/index.js | 2 +-
app/javascript/components/LoadModal/index.js | 4 +++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/app/javascript/components/ActionItemCreationPage/index.js b/app/javascript/components/ActionItemCreationPage/index.js
index 4bec762c..6a697ab5 100644
--- a/app/javascript/components/ActionItemCreationPage/index.js
+++ b/app/javascript/components/ActionItemCreationPage/index.js
@@ -58,12 +58,18 @@ class ActionItemCreationPage extends React.Component {
this.handleOpenModal = this.handleOpenModal.bind(this);
this.editActionItem = this.editActionItem.bind(this);
this.reloadPage = this.reloadPage.bind(this);
+ this.handleExitSubmitModal = this.handleExitSubmitModal.bind(this);
}
reloadPage() {
window.location.href = '/assignments';
}
+ // Only passed to LoadModal if submissionStatus == 'error'
+ handleExitSubmitModal() {
+ this.setState({ submissionStatus: null });
+ }
+
checkActionItemsEqual(actionItem1, actionItem2) {
return (
actionItem1.title === actionItem2.title &&
@@ -589,6 +595,11 @@ class ActionItemCreationPage extends React.Component {
? this.reloadPage
: this.handleSubmit
}
+ handleClose={
+ this.state.submissionStatus === 'error'
+ ? this.handleExitSubmitModal
+ : null
+ }
/>
{
let titleText;
let buttonText;
@@ -58,6 +58,7 @@ function LoadModal({ classes, open, status, handleClick }) {
open={open}
fullWidth
classes={{ paper: classes.modalStyle }}
+ onClose={handleClose}
onExited={() =>
// Avoid blurring document.body on IE9 since it blurs the entire window
document.activeElement !== document.body
@@ -112,5 +113,6 @@ LoadModal.propTypes = {
status: PropTypes.string,
open: PropTypes.bool.isRequired,
handleClick: PropTypes.func.isRequired,
+ handleClose: PropTypes.func,
};
export default withStyles(styles)(LoadModal);
From 6e637152f29bed46a52efee1836481216b8b09d4 Mon Sep 17 00:00:00 2001
From: Calvin Chen
Date: Sun, 10 May 2020 22:22:16 -0700
Subject: [PATCH 36/58] Fixing error with dueDates
---
app/javascript/components/ActionItemModal/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/javascript/components/ActionItemModal/index.js b/app/javascript/components/ActionItemModal/index.js
index d354064a..cacd7fc9 100644
--- a/app/javascript/components/ActionItemModal/index.js
+++ b/app/javascript/components/ActionItemModal/index.js
@@ -219,7 +219,7 @@ class ActionItemModal extends React.Component {
Due Date
Date: Sun, 10 May 2020 23:01:09 -0700
Subject: [PATCH 37/58] Fixing errors with dueDate + isTemplate on
newAssignment creation
---
.../components/ActionItemCard/index.js | 4 -
.../components/ActionItemModal/index.js | 19 -
.../components/AssignmentList/index.js | 10 +-
.../StudioAssessmentQuestion/index.js | 1 -
yarn.lock | 1016 +++++++----------
5 files changed, 437 insertions(+), 613 deletions(-)
diff --git a/app/javascript/components/ActionItemCard/index.js b/app/javascript/components/ActionItemCard/index.js
index 3010562d..df675fb0 100644
--- a/app/javascript/components/ActionItemCard/index.js
+++ b/app/javascript/components/ActionItemCard/index.js
@@ -163,12 +163,8 @@ ActionItemCard.propTypes = {
dueDate: PropTypes.string,
handleIconClick: PropTypes.func,
removeActionItem: PropTypes.func,
-<<<<<<< HEAD
- lastEntry: PropTypes.bool,
renderEditOverMore: PropTypes.bool,
formatDate: PropTypes.func,
-=======
addBorderBottom: PropTypes.bool,
->>>>>>> julian/delete-edit
};
export default withStyles(styles)(ActionItemCard);
diff --git a/app/javascript/components/ActionItemModal/index.js b/app/javascript/components/ActionItemModal/index.js
index c1ab24b4..61734bf0 100644
--- a/app/javascript/components/ActionItemModal/index.js
+++ b/app/javascript/components/ActionItemModal/index.js
@@ -106,23 +106,6 @@ class ActionItemModal extends React.Component {
);
});
- const addToTemplatesCheckbox = (
-
- {
- const newValue = { target: { value: e.target.checked } };
- this.handleChange('addToTemplates')(newValue);
- }}
- />
-
- ADD TO COMMON ASSIGNMENTS
-
-
- );
-
return (