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

Learning emails 4534 #5196

Merged
merged 17 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion app/controllers/casa_admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def set_admin
end

def update_casa_admin_params
CasaAdminParameters.new(params).with_only(:email, :display_name, :phone_number)
CasaAdminParameters.new(params).with_only(:email, :display_name, :phone_number, :monthly_learning_hours_report)
end

def learning_hours_checked?
ActiveModel::Type::Boolean.new.cast(params[:monthly_learning_hours_report])
end
end
14 changes: 13 additions & 1 deletion app/controllers/supervisors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,19 @@ def supervisor_values
end

def supervisor_params
params.require(:supervisor).permit(:display_name, :email, :old_emails, :phone_number, :active, :receive_reimbursement_email, volunteer_ids: [], supervisor_volunteer_ids: [])
params.require(:supervisor)
.permit(
:display_name,
:email,
:old_emails,
:phone_number,
:active,
:monthly_learning_hours_report,
:receive_reimbursement_email,
:monthly_learning_hours_report,
volunteer_ids: [],
supervisor_volunteer_ids: []
)
end

def update_supervisor_params
Expand Down
17 changes: 17 additions & 0 deletions app/mailers/learning_hours_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class LearningHoursMailer < ApplicationMailer
def learning_hours_report_email(user)
# user is either an Admin or Supervisor, this mailer is invoked through the rake task :monthly_learning_hours_report.rake
@user = user
littleforest marked this conversation as resolved.
Show resolved Hide resolved
@casa_org = @user.casa_org

# Generate the learning hours CSV for the current month
start_date = Date.today.beginning_of_month
end_date = Date.today.end_of_month
learning_hours = LearningHour.where(user: @casa_org.users, occurred_at: start_date..end_date)
csv_data = LearningHoursExportCsvService.new(learning_hours).perform

attachments["learning-hours-report-#{Date.today}.csv"] = csv_data

mail(to: @user.email, subject: "Learning Hours Report for #{end_date.strftime("%B, %Y")}.")
end
end
67 changes: 34 additions & 33 deletions app/models/casa_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,40 @@ def change_to_supervisor!
#
# Table name: users
#
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# monthly_learning_hours_report :boolean default(FALSE), not null
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
#
# Indexes
#
Expand Down
67 changes: 34 additions & 33 deletions app/models/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,40 @@ def recently_unassigned_volunteers
#
# Table name: users
#
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# monthly_learning_hours_report :boolean default(FALSE), not null
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
#
# Indexes
#
Expand Down
67 changes: 34 additions & 33 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,40 @@ def normalize_phone_number
#
# Table name: users
#
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# monthly_learning_hours_report :boolean default(FALSE), not null
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
#
# Indexes
#
Expand Down
67 changes: 34 additions & 33 deletions app/models/volunteer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,39 +140,40 @@ def cases_where_contact_made_in_days(num_days = CONTACT_MADE_IN_DAYS_NUM)
#
# Table name: users
#
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
# id :bigint not null, primary key
# active :boolean default(TRUE)
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# display_name :string default(""), not null
# email :string default(""), not null
# encrypted_password :string default(""), not null
# invitation_accepted_at :datetime
# invitation_created_at :datetime
# invitation_limit :integer
# invitation_sent_at :datetime
# invitation_token :string
# invitations_count :integer default(0)
# invited_by_type :string
# last_sign_in_at :datetime
# last_sign_in_ip :string
# monthly_learning_hours_report :boolean default(FALSE), not null
# old_emails :string default([]), is an Array
# phone_number :string default("")
# receive_email_notifications :boolean default(TRUE)
# receive_reimbursement_email :boolean default(FALSE)
# receive_sms_notifications :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# sign_in_count :integer default(0), not null
# type :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
# casa_org_id :bigint not null
# invited_by_id :bigint
#
# Indexes
#
Expand Down
1 change: 1 addition & 0 deletions app/values/user_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def initialize(params, key = :user)
:active,
:receive_reimbursement_email,
:type,
:monthly_learning_hours_report,
address_attributes: [:id, :content]
)

Expand Down
12 changes: 12 additions & 0 deletions app/views/casa_admins/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
<div class="mb-30">
<%= render "/shared/invite_login", resource: casa_admin %>
</div>

<div>
<% if current_user.casa_admin? %>
<div class="form-group">
<%= form.label :monthly_learning_hours_report, "Receive Monthly Learning Hours Report" %>
<%= form.check_box :monthly_learning_hours_report %>
</div>
<% end %>
</div>

<br>

<% if casa_admin.persisted? %>
<div class="mb-20 col">
<% if casa_admin.active? %>
Expand Down
Loading