Skip to content

Commit

Permalink
Merge branch 'main' into 5015-draft-support-nov
Browse files Browse the repository at this point in the history
  • Loading branch information
schoork authored Jan 13, 2024
2 parents fa23a47 + 2828276 commit 8477c29
Show file tree
Hide file tree
Showing 25 changed files with 209 additions and 676 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ gem "pdf-forms" # filling in fund request PDFs with user input
gem "rexml" # pdf-forms needs this to deploy to heroku apparently
gem "pg" # Use postgresql as the database for Active Record
gem "pretender"
gem "puma", "6.4.0" # 6.2.2 fails to install on m1 # Use Puma as the app server
gem "puma", "6.4.2" # 6.2.2 fails to install on m1 # Use Puma as the app server
gem "pundit" # for authorization management - based on user.role field
gem "rack-attack" # for blocking & throttling abusive requests
gem "rack-cors" # for allowing cross-origin resource sharing
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ GEM
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-smtp (0.4.0.1)
net-protocol
nio4r (2.5.9)
nio4r (2.7.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
Expand Down Expand Up @@ -336,7 +336,7 @@ GEM
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
public_suffix (5.0.4)
puma (6.4.0)
puma (6.4.2)
nio4r (~> 2.0)
pundit (2.3.1)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -499,7 +499,7 @@ GEM
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
uniform_notifier (1.16.0)
view_component (3.8.0)
view_component (3.9.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
Expand Down Expand Up @@ -583,7 +583,7 @@ DEPENDENCIES
pretender
pry
pry-byebug
puma (= 6.4.0)
puma (= 6.4.2)
pundit
rack-attack
rack-cors
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
before_action :set_current_user
before_action :set_timeout_duration
before_action :set_current_organization
before_action :set_active_banner
after_action :verify_authorized, except: :index, unless: :devise_controller?
# after_action :verify_policy_scoped, only: :index

Expand All @@ -30,6 +31,13 @@ def after_sign_out_path_for(resource_or_scope)
end
end

def set_active_banner
return nil unless current_organization

@active_banner = current_organization.banners.active.first
@active_banner = nil if session[:dismissed_banner] == @active_banner&.id
end

protected

def handle_short_url(url_list)
Expand Down
16 changes: 11 additions & 5 deletions app/controllers/banners_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class BannersController < ApplicationController
after_action :verify_authorized
after_action :verify_authorized, except: %i[dismiss]
before_action :set_banner, only: %i[edit update destroy dismiss]

def index
authorize :application, :admin_or_supervisor?
Expand All @@ -15,8 +16,11 @@ def new

def edit
authorize :application, :admin_or_supervisor?
end

@banner = current_organization.banners.find(params[:id])
def dismiss
session[:dismissed_banner] = @banner.id
render json: {status: :ok}
end

def create
Expand All @@ -37,8 +41,6 @@ def create
def update
authorize :application, :admin_or_supervisor?

@banner = current_organization.banners.find(params[:id])

Banner.transaction do
deactivate_alternate_active_banner
@banner.update!(banner_params)
Expand All @@ -52,12 +54,16 @@ def update
def destroy
authorize :application, :admin_or_supervisor?

current_organization.banners.find(params[:id]).destroy
@banner.destroy
redirect_to banners_path
end

private

def set_banner
@banner = current_organization.banners.find(params[:id])
end

def banner_params
params.require(:banner).permit(:active, :content, :name).merge(user: current_user)
end
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/volunteer_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class VolunteerDecorator < UserDecorator

def cc_reminder_text
if h.current_user.supervisor?
h.t("volunteers.send_reminder_button.supervisor_checkbox_text")
"Send CC to Supervisor"
elsif h.current_user.casa_admin?
h.t("volunteers.send_reminder_button.admin_checkbox_text")
"Send CC to Supervisor and Admin"
end
end
end
13 changes: 10 additions & 3 deletions app/javascript/controllers/dismiss_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import { Controller } from '@hotwired/stimulus'

export default class extends Controller {
static targets = ['element']
static values = {
url: String
}

dismiss (event) {
event.preventDefault()

const { id } = event.params
document.cookie = `dismiss_${id}=true`
this.elementTarget.classList.add('d-none')
fetch(this.urlValue)
.then(response => response.json())
.then(data => {
if (data.status === 'ok') {
this.elementTarget.classList.add('d-none')
}
})
}
}
28 changes: 13 additions & 15 deletions app/models/case_contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ def volunteer
end

def self.options_for_sorted_by
sorted_by_params.map do |option|
[I18n.t("models.case_contact.options_for_sorted_by.#{option}"), option]
end
sorted_by_params.each.map { |option_pair| option_pair.reverse }
end

def self.case_hash_from_cases(cases)
Expand All @@ -271,18 +269,18 @@ def self.case_hash_from_cases(cases)
end

private_class_method def self.sorted_by_params
%i[
occurred_at_asc
occurred_at_desc
contact_type_asc
contact_type_desc
medium_type_asc
medium_type_desc
want_driving_reimbursement_asc
want_driving_reimbursement_desc
contact_made_asc
contact_made_desc
]
{
occurred_at_asc: "Date of contact (oldest first)",
occurred_at_desc: "Date of contact (newest first)",
contact_type_asc: "Contact type (A-z)",
contact_type_desc: "Contact type (z-A)",
medium_type_asc: "Contact medium (A-z)",
medium_type_desc: "Contact medium (z-A)",
want_driving_reimbursement_asc: "Want driving reimbursement ('no' first)",
want_driving_reimbursement_desc: "Want driving reimbursement ('yes' first)",
contact_made_asc: "Contact made ('no' first)",
contact_made_desc: "Contact made ('yes' first)"
}
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ class EmancipationChecklistReminderNotification < BaseNotification
# Define helper methods to make rendering easier.

def message
t(".message", case_number: params[:casa_case].case_number)
casa_case = params[:casa_case]
"Your case #{casa_case.case_number} is a transition aged youth. " \
"We want to make sure that along the way, we’re preparing our youth for emancipation. " \
"Make sure to check the emancipation checklist."
end

def title
t(".title")
"Emancipation Checklist Reminder"
end

def url
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/mailer/invitation_instructions.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<% else %>
A CASA console admin account has been created for you. Your console account is associated with this email.
If you are ready to get started, please set your password. This is the first step to accessing your new account.
<%= t 'devise.mailer.invitation_instructions.accept_until', due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format') %>
<%= "This invitation will be due in #{I18n.l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')}." %>
<% end %>
<%= link_to "Set your password", accept_invitation_url(@resource, invitation_token: @token) %>
20 changes: 8 additions & 12 deletions app/views/layouts/_banner.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<% banner = current_organization.banners.active.first %>
<% if banner %>
<% cookie_id = "banner_#{banner.id}" %>
<% if !cookies["dismiss_#{cookie_id}"] %>
<div class="bg-secondary-100 text-xl p-5 d-flex" data-controller="dismiss" data-dismiss-target="element">
<div class="">
<%= banner.content %>
</div>
<div class="ms-auto">
<a href="#" data-action="click->dismiss#dismiss" data-dismiss-id-param="<%= cookie_id %>">Dismiss</a>
</div>
<% if @active_banner %>
<div class="bg-secondary-100 text-xl p-5 d-flex" data-controller="dismiss" data-dismiss-target="element" data-dismiss-url-value="<%= dismiss_banner_path(@active_banner) %>">
<div class="">
<%= @active_banner.content %>
</div>
<% end %>
<div class="ms-auto">
<a href="#" data-action="click->dismiss#dismiss">Dismiss</a>
</div>
</div>
<% end %>
8 changes: 4 additions & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title><%= translate('page.meta.title') %></title>
<title>CASA Volunteer Tracking</title>

<meta name="description" content="<%= translate('page.meta.description') %>">
<meta name="description" content="Volunteer activity tracking for CASA volunteers, supervisors, and administrators.">
<meta name="viewport" content="width=device-width,initial-scale=1">

<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= og_tag :title, content: translate('page.meta.title') %>
<%= og_tag :description, content: translate('page.meta.description') %>
<%= og_tag :title, content: "CASA Volunteer Tracking" %>
<%= og_tag :description, content: "Volunteer activity tracking for CASA volunteers, supervisors, and administrators." %>
<%= og_tag :url, content: root_url %>
<%= og_tag :image, content: image_url('login.jpg') %>

Expand Down
6 changes: 0 additions & 6 deletions config/locales/controllers.en.yml

This file was deleted.

87 changes: 0 additions & 87 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,6 @@
# available at https://guides.rubyonrails.org/i18n.html.

en:
hello: "Hello world"
activerecord:
attributes:
learning_hour:
learning_hour_type: "Type of Learning"
pundit:
default: "Sorry, you are not authorized to perform this action."
casa_case_policy:
new?: "Sorry, you are not authorized to create CASA cases."
case_contact_policy:
edit?: "Sorry, you can only edit case contacts that you have logged."
update?: "Sorry, you can only edit case contacts that you have logged."
forms:
casa_admin:
mark_inactive_warning: "WARNING: Marking an admin inactive will make them unable to login. Are you sure you want to do this?"
supervisor:
mark_inactive_warning: "WARNING: Marking a supervisor inactive will make them unable to login. Are you sure you want to do this?"
volunteer:
mark_inactive_warning: "WARNING: Marking a volunteer inactive will make them unable to login. Are you sure you want to do this?"
page:
meta:
title: CASA Volunteer Tracking
description: Volunteer activity tracking for CASA volunteers, supervisors, and administrators.
time:
formats:
day_and_date: "%A, %d-%b-%Y"
Expand All @@ -62,70 +39,6 @@ en:
youth_date_of_birth: "%B %Y"
short_date: "%-m/%d"
edit_profile: "%B %d, %Y at %I:%M %p %Z"
time_on_date: "%-I:%-M %p on %m-%e-%Y"
notifications:
emancipation_checklist_reminder_notification:
title: "Emancipation Checklist Reminder"
message: "Your case %{case_number} is a transition aged youth. We want to make sure that along the way, we’re preparing our youth for emancipation. Make sure to check the emancipation checklist."
followup_resolved_notification:
title: "Followup resolved"
message: "%{created_by_name} resolved a follow up. Click to see more."
followup_notification:
title: "New followup"
message: "%{created_by_name} has flagged a Case Contact that needs follow up."
note: "Note: \"%{note}\""
more_info: "Click to see more."
youth_birthday_notification:
title: "Youth Birthday Notification"
message: "Your youth, case number: %{case_number} has a birthday next month."
button:
delete: Delete
undelete: undelete
edit: Edit
back: Back
submit: Submit
resolve: Resolve Reminder
follow_up: Make Reminder
go_back_to_form: Go Back to Form
continue_submitting: Continue Submitting
close: Close
detail_view: Detail View
common:
yes_text: "Yes"
no_text: "No"
both_text: Both
active: Active
inactive: Inactive
status: Status
day: Day
month: Month
year: Year
none: None
email: Email
name: Name
display_name: Display name
phone_number: Phone number
address: Address
date:
formats:
full: "%B %-d, %Y"
case_contact:
create: Case contact was successfully created.
update: "Case contact created at %{created_at}, was successfully updated."
destroy: Contact is successfully deleted.
restore: Contact is successfully restored.
case_min_validation: At least one case must be selected
thank_you_1: Thanks for all you do!
thank_you_2: Thank you for your hard work!
thank_you_3: Thank you for a job well done!
thank_you_4: Thank you for volunteering!
thank_you_5: Thanks for being a great volunteer!
thank_you_6: One of the greatest gifts you can give is your time!
thank_you_7: Those who can do, do. Those who can do more, volunteer.
thank_you_8: Volunteers do not necessarily have the time, they just have the heart.
communication_preferences:
header: "Communication Preferences"
paragraph: "Tell us how you'd like to receive notifications."
email_me: "Email Me"
text_me: "Text Me"
save_preferences: "Save Preferences"
14 changes: 0 additions & 14 deletions config/locales/models.en.yml

This file was deleted.

Loading

0 comments on commit 8477c29

Please sign in to comment.