diff --git a/app/controllers/casa_admins_controller.rb b/app/controllers/casa_admins_controller.rb index 515f8fed9b..a1436af255 100644 --- a/app/controllers/casa_admins_controller.rb +++ b/app/controllers/casa_admins_controller.rb @@ -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 diff --git a/app/controllers/supervisors_controller.rb b/app/controllers/supervisors_controller.rb index 6cde7928b3..b4834fce01 100644 --- a/app/controllers/supervisors_controller.rb +++ b/app/controllers/supervisors_controller.rb @@ -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 diff --git a/app/mailers/learning_hours_mailer.rb b/app/mailers/learning_hours_mailer.rb new file mode 100644 index 0000000000..e5ee654d9f --- /dev/null +++ b/app/mailers/learning_hours_mailer.rb @@ -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 + @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 diff --git a/app/models/casa_admin.rb b/app/models/casa_admin.rb index cda73e3160..4bd2021ef9 100644 --- a/app/models/casa_admin.rb +++ b/app/models/casa_admin.rb @@ -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 # diff --git a/app/models/supervisor.rb b/app/models/supervisor.rb index ad49691336..afec012012 100644 --- a/app/models/supervisor.rb +++ b/app/models/supervisor.rb @@ -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 # diff --git a/app/models/user.rb b/app/models/user.rb index bb47cb8ade..041322cbdf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 # diff --git a/app/models/volunteer.rb b/app/models/volunteer.rb index 0dbb3e7bb9..b68b20a862 100644 --- a/app/models/volunteer.rb +++ b/app/models/volunteer.rb @@ -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 # diff --git a/app/values/user_parameters.rb b/app/values/user_parameters.rb index aa7edccd80..a491c52115 100644 --- a/app/values/user_parameters.rb +++ b/app/values/user_parameters.rb @@ -10,6 +10,7 @@ def initialize(params, key = :user) :active, :receive_reimbursement_email, :type, + :monthly_learning_hours_report, address_attributes: [:id, :content] ) diff --git a/app/views/casa_admins/_form.html.erb b/app/views/casa_admins/_form.html.erb index 59fdde9c4c..777575b66a 100644 --- a/app/views/casa_admins/_form.html.erb +++ b/app/views/casa_admins/_form.html.erb @@ -19,6 +19,18 @@
+
|
+
<%= render "/shared/invite_login", resource: @supervisor %>
+ +<%= render "manage_active", user: @supervisor %>
@@ -26,6 +36,7 @@