Skip to content

Commit 31b418d

Browse files
refactor: Cleans Questionnaire for MyMLH V3 (#338)
* refactor: Removes "Convert to Admin" on Questionnaire * refactor: Updates MyMLH branding + V3 * fix: Removes tests for convert_to_admin * refactor: Removes remaining "convert_to_admin" calls Co-authored-by: Peter Kos <pkos91@icloud.com>
1 parent 1599fe1 commit 31b418d

File tree

7 files changed

+9
-47
lines changed

7 files changed

+9
-47
lines changed

app/controllers/manage/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Manage::ApplicationController < ApplicationController
22
before_action :logged_in
33
before_action :require_admin_or_limited_admin
4-
before_action :limit_write_access_to_admins, only: ["edit", "update", "new", "create", "destroy", "convert_to_admin", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
4+
before_action :limit_write_access_to_admins, only: ["edit", "update", "new", "create", "destroy", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
55
skip_before_action :verify_authenticity_token, if: :json_request?
66

77
def logged_in

app/controllers/manage/questionnaires_controller.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Manage::QuestionnairesController < Manage::ApplicationController
22
include QuestionnairesControllable
33

4-
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :convert_to_admin, :update_acc_status]
4+
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :update_acc_status]
55

66
respond_to :html, :json
77

@@ -95,13 +95,6 @@ def check_in
9595
redirect_to index_redirect_path
9696
end
9797

98-
def convert_to_admin
99-
user = @questionnaire.user
100-
@questionnaire.destroy
101-
user.update_attributes(role: :admin)
102-
redirect_to edit_manage_user_path(user)
103-
end
104-
10598
def destroy
10699
@questionnaire.destroy
107100
respond_with(:manage, @questionnaire)

app/views/manage/questionnaires/_form.html.haml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
.card-body
1212
- if @questionnaire&.user&.provider == 'mlh'
1313
%h6.card-subtitle.mb-2
14-
%span.badge.badge-info Provided by My MLH
14+
%span.badge.badge-info Provided by MyMLH
1515
= f.simple_fields_for :user, @questionnaire.user do |u|
1616
= u.input :first_name, input_html: { "data-validate" => "presence" }, label: "First Name", autofocus: true
1717
= u.input :last_name, input_html: { "data-validate" => "presence" }, label: "Last Name"
1818
= f.input :email, input_html: { "data-validate" => "presence email", value: @questionnaire.user.try(:email) }, required: true, hint: 'Can be an existing user (without a questionnaire) or a new user. If this is a new user, they will receive a randomly-generated password that they must request a password reset for.'
1919
= f.input :phone, input_html: { "data-validate" => "presence" }
2020
= f.input :date_of_birth, start_year: Date.today.year - 18, end_year: Date.today.year - 90, order: [:month, :day, :year], input_html: { "data-validate" => "presence" }
21-
2221
= f.input :school_id, as: :school_selection, input_html: { "data-validate" => "presence" }
2322
= f.input :level_of_study, input_html: { "data-validate" => "presence" }
2423
= f.input :major, input_html: { "data-validate" => "presence" }
25-
= f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }
2624
= f.input :gender, input_html: { "data-validate" => "presence" }
27-
= f.input :dietary_restrictions, label: "Dietary restrictions"
28-
= f.input :special_needs, label: "Special needs"
2925

3026
.col-xl-6
27+
.card.mb-4
28+
.card-header Special notices
29+
.card-body
30+
= f.input :shirt_size, as: :select, collection: Questionnaire::POSSIBLE_SHIRT_SIZES, include_blank: "(select one...)", input_html: { "data-validate" => "presence" }
31+
= f.input :dietary_restrictions, label: "Dietary restrictions"
32+
= f.input :special_needs, label: "Special needs"
3133
.card.mb-4
3234
.card-header Resume
3335
.card-body

app/views/manage/questionnaires/show.html.haml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
.btn-group{role: "group"}
1212
- if current_user.admin?
1313
= link_to 'Edit', edit_manage_questionnaire_path(@questionnaire), class: 'btn btn-sm btn-outline-secondary'
14-
- if current_user.admin?
15-
.btn-group{role: "group"}
16-
%button.btn.btn-sm.btn-outline-secondary.dropdown-toggle#title-actions{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"}
17-
.fa.fa-cog
18-
.dropdown-menu.dropdown-menu-right{"aria-labelledby" => "title-actions"}
19-
= link_to 'Convert to Admin', convert_to_admin_manage_questionnaire_path(@questionnaire), method: :patch, data: { confirm: "Are you sure? The questionnaire for \"#{@questionnaire.user.full_name}\" will be permanently erased, and \"#{@questionnaire.email}\" will become an admin. This action is irreversible." }, class: 'dropdown-item'
2014

2115
= render 'overview'
2216

config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
resources :questionnaires do
5656
post :datatable, on: :collection
5757
patch :check_in, on: :member
58-
patch :convert_to_admin, on: :member
5958
patch :update_acc_status, on: :member
6059
patch :bulk_apply, on: :collection
6160
end

docs/api-overview.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Example for questionnaire management endpoints:
4141
Prefix Verb URI Pattern Controller#Action
4242
datatable_manage_questionnaires POST /manage/questionnaires/datatable(.:format) manage/questionnaires#datatable
4343
check_in_manage_questionnaire PATCH /manage/questionnaires/:id/check_in(.:format) manage/questionnaires#check_in
44-
convert_to_admin_manage_questionnaire PATCH /manage/questionnaires/:id/convert_to_admin(.:format) manage/questionnaires#convert_to_admin
4544
update_acc_status_manage_questionnaire PATCH /manage/questionnaires/:id/update_acc_status(.:format) manage/questionnaires#update_acc_status
4645
bulk_apply_manage_questionnaires PATCH /manage/questionnaires/bulk_apply(.:format) manage/questionnaires#bulk_apply
4746
manage_questionnaires GET /manage/questionnaires(.:format) manage/questionnaires#index

test/controllers/manage/questionnaires_controller_test.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
5050
assert_redirected_to new_user_session_path
5151
end
5252

53-
should "not allow convert questionnaire's user to an admin" do
54-
patch :convert_to_admin, params: { id: @questionnaire }
55-
assert_response :redirect
56-
assert_redirected_to new_user_session_path
57-
end
58-
5953
should "not allow access to manage_questionnaires#destroy" do
6054
patch :destroy, params: { id: @questionnaire }
6155
assert_response :redirect
@@ -123,12 +117,6 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
123117
assert_redirected_to root_path
124118
end
125119

126-
should "not allow convert questionnaire's user to an admin" do
127-
patch :convert_to_admin, params: { id: @questionnaire }
128-
assert_response :redirect
129-
assert_redirected_to root_path
130-
end
131-
132120
should "not allow access to manage_questionnaires#destroy" do
133121
patch :destroy, params: { id: @questionnaire }
134122
assert_response :redirect
@@ -194,12 +182,6 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
194182
assert_redirected_to manage_questionnaires_path
195183
end
196184

197-
should "not allow convert questionnaire's user to an admin" do
198-
patch :convert_to_admin, params: { id: @questionnaire }
199-
assert_response :redirect
200-
assert_redirected_to manage_questionnaires_path
201-
end
202-
203185
should "not allow access to manage_questionnaires#destroy" do
204186
patch :destroy, params: { id: @questionnaire }
205187
assert_response :redirect
@@ -299,13 +281,6 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
299281
assert_redirected_to manage_questionnaire_path(assigns(:questionnaire))
300282
end
301283

302-
should "convert questionnaire's user to an admin" do
303-
patch :convert_to_admin, params: { id: @questionnaire }
304-
assert assigns(:questionnaire).user.admin?
305-
assert_nil assigns(:questionnaire).user.reload.questionnaire
306-
assert_redirected_to edit_manage_user_path(assigns(:questionnaire).user)
307-
end
308-
309284
should "destroy questionnaire" do
310285
assert_difference("Questionnaire.count", -1) do
311286
delete :destroy, params: { id: @questionnaire }

0 commit comments

Comments
 (0)