Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
remove volunteer_type
Browse files Browse the repository at this point in the history
  • Loading branch information
CZagrobelny committed Sep 10, 2019
1 parent 93db029 commit 7887b2a
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 58 deletions.
18 changes: 3 additions & 15 deletions app/controllers/admin/users_controller.rb
Expand Up @@ -2,9 +2,6 @@ class Admin::UsersController < AdminController
def index
@filterrific = initialize_filterrific(User,
params[:filterrific],
select_options: {
filter_volunteer_type: volunteer_type_options
},
persistence_id: false)

@filterrific_role = initialize_filterrific(User,
Expand Down Expand Up @@ -61,12 +58,6 @@ def update

private

def volunteer_type_options
User.volunteer_types.keys.map do |volunteer_type|
[volunteer_type.humanize, volunteer_type]
end
end

def role_options
User.roles.keys.map do |role_type|
[role_type.humanize, role_type]
Expand All @@ -83,7 +74,6 @@ def user_params
:last_name,
:email,
:phone,
:volunteer_type,
:role,
:pledge_signed,
:signed_guidelines,
Expand All @@ -99,17 +89,15 @@ def user_params_excluding_role
:last_name,
:email,
:phone,
:volunteer_type,
:pledge_signed,
:signed_guidelines,
:attended_training,
:remote_clinic_lawyer
:remote_clinic_lawyer,
language_ids: [],
)
end

def user_index_scope
scope = current_community.users
scope = scope.for_volunteer_type(params[:volunteer_type]) if params[:volunteer_type].present?
scope
current_community.users
end
end
1 change: 0 additions & 1 deletion app/controllers/invitations_controller.rb
Expand Up @@ -38,7 +38,6 @@ def update_sanitized_params
:password_confirmation,
:remote_clinic_lawyer,
:invitation_token,
:volunteer_type,
:pledge_signed,
language_ids: [])
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/regional_admin/remote_lawyers_controller.rb
Expand Up @@ -55,12 +55,12 @@ def remote_lawyer_params
:last_name,
:email,
:phone,
:volunteer_type,
:role,
:pledge_signed,
:signed_guidelines,
:remote_clinic_lawyer,
friend_ids: []
friend_ids: [],
language_ids: []
)
end
end
1 change: 0 additions & 1 deletion app/controllers/users_controller.rb
Expand Up @@ -27,7 +27,6 @@ def user_params
:last_name,
:email,
:phone,
:volunteer_type,
:pledge_signed,
:remote_clinic_lawyer,
language_ids: [],
Expand Down
8 changes: 1 addition & 7 deletions app/models/user.rb
Expand Up @@ -10,7 +10,6 @@ class User < ApplicationRecord
attr_reader :raw_invitation_token

enum role: %i[volunteer accompaniment_leader admin data_entry]
enum volunteer_type: %i[english_speaking spanish_interpreter lawyer]

validates :first_name, :last_name, :email, :phone, :community_id, presence: true
validates :email, uniqueness: true
Expand All @@ -33,7 +32,7 @@ class User < ApplicationRecord
has_many :reviews
has_many :user_event_attendances, dependent: :destroy




accepts_nested_attributes_for :user_friend_associations, allow_destroy: true
Expand All @@ -45,7 +44,6 @@ class User < ApplicationRecord
filter_first_name
filter_last_name
filter_email
filter_volunteer_type
filter_role
]
)
Expand All @@ -54,10 +52,6 @@ def remote_clinic_friends
friends.where(user_friend_associations: { remote: true })
end

scope :filter_volunteer_type, ->(volunteer_type) {
where(volunteer_type: volunteer_type)
}

scope :filter_role, ->(role) {
where(role: role)
}
Expand Down
6 changes: 2 additions & 4 deletions app/views/admin/users/_list.html.erb
Expand Up @@ -11,8 +11,7 @@
<th>Last Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>Volunteer Type</th>
<th>Admin?</th>
<th>Role</th>
<th>Created At</th>
<th>Actions</th>
</tr>
Expand All @@ -25,8 +24,7 @@
<td><%= user.last_name %></td>
<td><%= user.email %></td>
<td><%= user.phone %></td>
<td><%= user.volunteer_type.try(:titleize) %></td>
<td><%= user.admin? ? 'YES' : 'NO' %></td>
<td><%= user.role.try(:titlecase) %></td>
<td><%= user.created_at.strftime('%m/%d/%y') %></td>
<td>
<div class='btn-group'>
Expand Down
6 changes: 2 additions & 4 deletions app/views/regional_admin/remote_lawyers/index.html.erb
Expand Up @@ -8,8 +8,7 @@
<th>Last Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>Type</th>
<th>Admin?</th>
<th>Role</th>
<th>Created</th>
<th>Actions</th>
</tr>
Expand All @@ -22,8 +21,7 @@
<td><%= lawyer.last_name %></td>
<td><%= lawyer.email %></td>
<td><%= lawyer.phone %></td>
<td><%= lawyer.volunteer_type.try(:titleize) %></td>
<td><%= lawyer.admin? ? 'YES' : 'NO' %></td>
<td><%= lawyer.role.try(:titlecase) %></td>
<td><%= lawyer.created_at.strftime('%m/%d/%y') %></td>

<td>
Expand Down
22 changes: 11 additions & 11 deletions db/seeds.rb
Expand Up @@ -33,51 +33,51 @@
primary: true)

# NY Regional admin
ny_regional_admin = User.create!(first_name: 'NY Regional', last_name: 'Admin', email: 'ny_regional_admin@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 2, pledge_signed: true)
ny_regional_admin = User.create!(first_name: 'NY Regional', last_name: 'Admin', email: 'ny_regional_admin@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 2, pledge_signed: true)
ny_regional_admin.user_regions.create!(region_id: ny_region.id)

## NYC Users

#Accompaniment Leader User
User.create!(first_name: 'NYC Accompaniment', last_name: 'Leader', email: 'nyc_accompaniment_leader@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 1, pledge_signed: true)
User.create!(first_name: 'NYC Accompaniment', last_name: 'Leader', email: 'nyc_accompaniment_leader@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 1, pledge_signed: true)

#Volunteer User
User.create!(first_name: 'NYC Community', last_name: 'Volunteer', email: 'nyc_volunteer@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 0, pledge_signed: true)
User.create!(first_name: 'NYC Community', last_name: 'Volunteer', email: 'nyc_volunteer@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 0, pledge_signed: true)

#Admin User
User.create!(first_name: 'NYC Community', last_name: 'Admin', email: 'nyc_admin@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 2, pledge_signed: true)
User.create!(first_name: 'NYC Community', last_name: 'Admin', email: 'nyc_admin@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 2, pledge_signed: true)

#Remote Clinic Lawyer
User.create!(first_name: 'Remote Clinic', last_name: 'Lawyer', email: 'remote_clinic_lawyer@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 2, role: 0, pledge_signed: true, remote_clinic_lawyer: true)
User.create!(first_name: 'Remote Clinic', last_name: 'Lawyer', email: 'remote_clinic_lawyer@example.com', community_id: nyc_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 0, pledge_signed: true, remote_clinic_lawyer: true)

#Some additional NYC volunteer users
20.times do |index|
Timecop.travel(index.days.ago)
User.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.safe_email, community_id: nyc_community.id, phone: Faker::PhoneNumber.phone_number, password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 0, pledge_signed: true)
User.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.safe_email, community_id: nyc_community.id, phone: Faker::PhoneNumber.phone_number, password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 0, pledge_signed: true)
end
Timecop.return

10.times do |index|
Timecop.travel(index.days.ago)
User.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.safe_email, community_id: nyc_community.id, phone: Faker::PhoneNumber.phone_number, password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 2, role: 0, pledge_signed: true, remote_clinic_lawyer: false)
User.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.safe_email, community_id: nyc_community.id, phone: Faker::PhoneNumber.phone_number, password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 0, pledge_signed: true, remote_clinic_lawyer: false)
end
Timecop.return
## Long Island Users

#Accompaniment Leader User
User.create!(first_name: 'LI Accompaniment', last_name: 'Leader', email: 'li_accompaniment_leader@example.com', community_id: long_island_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 1, pledge_signed: true)
User.create!(first_name: 'LI Accompaniment', last_name: 'Leader', email: 'li_accompaniment_leader@example.com', community_id: long_island_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 1, pledge_signed: true)

#Volunteer User
User.create!(first_name: 'LI Community', last_name: 'Volunteer', email: 'li_volunteer@example.com', community_id: long_island_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 0, pledge_signed: true)
User.create!(first_name: 'LI Community', last_name: 'Volunteer', email: 'li_volunteer@example.com', community_id: long_island_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 0, pledge_signed: true)

#Admin User
User.create!(first_name: 'LI Community', last_name: 'Admin', email: 'li_admin@example.com', community_id: long_island_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 2, pledge_signed: true)
User.create!(first_name: 'LI Community', last_name: 'Admin', email: 'li_admin@example.com', community_id: long_island_community.id, phone: '888 888 8888', password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 2, pledge_signed: true)


#Some additional Long Island volunteer users
30.times do |index|
Timecop.travel(index.days.ago)
User.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.safe_email, community_id: long_island_community.id, phone: Faker::PhoneNumber.phone_number, password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, volunteer_type: 1, role: 0, pledge_signed: true)
User.create!(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.safe_email, community_id: long_island_community.id, phone: Faker::PhoneNumber.phone_number, password: 'Password1234', password_confirmation: 'Password1234', invitation_accepted_at: Time.now, role: 0, pledge_signed: true)
end
Timecop.return

Expand Down
2 changes: 0 additions & 2 deletions spec/factories/user_factory.rb
Expand Up @@ -4,7 +4,6 @@
last_name { Faker::Name.last_name }
email { Faker::Internet.unique.safe_email }
phone { Faker::PhoneNumber.phone_number }
volunteer_type { 1 }
password { (Faker::Food.fruits + Faker::PhoneNumber.area_code.to_s + Faker::Food.spice).delete(' ') }
password_confirmation { password }
invitation_accepted_at { Time.now }
Expand Down Expand Up @@ -40,7 +39,6 @@
last_name { nil }
email { Faker::Internet.unique.safe_email }
phone { nil }
volunteer_type { nil }
password { nil }
password_confirmation { nil }
invitation_accepted_at { nil }
Expand Down
1 change: 0 additions & 1 deletion spec/features/invite_a_new_user_spec.rb
Expand Up @@ -55,7 +55,6 @@
fill_in 'First Name', with: Faker::Name.first_name
fill_in 'Last Name', with: Faker::Name.last_name
fill_in 'Phone', with: '876 765 4455'
select 'English Speaking', :from => 'Type'
fill_in 'Password', with: 'Password1234'
fill_in 'Password Confirmation', with: 'Password1234'
check 'user_pledge_signed'
Expand Down
15 changes: 6 additions & 9 deletions spec/models/mailers/review_mailer_spec.rb
Expand Up @@ -4,9 +4,8 @@

describe 'review_needed_email(draft)' do
let(:draft) { create :draft, status: :in_review }
let(:user) { create :user, volunteer_type: "lawyer" }
let(:non_remote_clinic_user) { create :user, volunteer_type: "spanish_interpreter",
role: "volunteer" }
let(:user) { create :user }
let(:non_remote_clinic_user) { create :user, role: "volunteer" }


subject(:mail) { ReviewMailer.review_needed_email(draft)}
Expand Down Expand Up @@ -41,10 +40,8 @@

describe 'lawyer_assignment_needed_email(draft)' do
let(:draft) { create :draft, status: :in_review }
let(:admin_user) { create :user, volunteer_type: "spanish_interpreter",
role: "admin" }
let(:non_admin_user) { create :user, volunteer_type: "spanish_interpreter",
role: "volunteer" }
let(:admin_user) { create :user, role: "admin" }
let(:non_admin_user) { create :user, role: "volunteer" }

subject(:mail) { ReviewMailer.lawyer_assignment_needed_email(draft)}

Expand Down Expand Up @@ -83,7 +80,7 @@
let(:draft) { create :draft, status: :changes_requested, friend: friend }
let(:review) { create :review, draft: draft }
let(:friend) { create :friend, community: community, region: region }
let!(:volunteer) { create :user, volunteer_type: 'english_speaking', community: community }
let!(:volunteer) { create :user, community: community }
let!(:community_admin) { create :user, :community_admin, community: community }
let!(:regional_admin) { create :user, :regional_admin, community: community }

Expand Down Expand Up @@ -119,7 +116,7 @@
let(:region) { community.region }
let(:application) { create :application, friend: friend }
let(:friend) { create :friend, community: community, region: region }
let!(:volunteer) { create :user, volunteer_type: 'english_speaking', community: community }
let!(:volunteer) { create :user, community: community }
let!(:community_admin) { create :user, :community_admin, community: community }
let!(:regional_admin) { create :user, :regional_admin, community: community }

Expand Down
2 changes: 1 addition & 1 deletion spec/services/notifications_spec.rb
Expand Up @@ -5,7 +5,7 @@
describe '.draft_for_review(draft: draft)' do
context 'the friend has a lawyer' do
let(:draft) { create :draft, status: :in_review }
let(:user) { create :user, volunteer_type: "lawyer" }
let(:user) { create :user }


context 'the friend has a remote lawyer' do
Expand Down

0 comments on commit 7887b2a

Please sign in to comment.