Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/erb_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
bundler-cache: true

- name: ERB lint
run: bundle exec erblint --lint-all
run: bundle exec erb_lint --lint-all
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ plugins:
- rubocop-rspec_rails

inherit_gem:
standard: config/base.yml
pundit: config/rubocop-rspec.yml
57 changes: 57 additions & 0 deletions .standard_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,54 @@
---
ignore:
- app/controllers/all_casa_admins/sessions_controller.rb:
- Layout/EmptyLinesAfterModuleInclusion
- Rails/LexicallyScopedActionFilter
- app/controllers/api/v1/base_controller.rb:
- Rails/LexicallyScopedActionFilter
- app/controllers/casa_cases_controller.rb:
- Rails/TimeZone
- Style/EmptyStringInsideInterpolation
- app/controllers/case_contacts/followups_controller.rb:
- Layout/EmptyLineAfterGuardClause
- app/controllers/case_contacts_controller.rb:
- Rails/LexicallyScopedActionFilter
- Style/HashSlice
- app/controllers/checklist_items_controller.rb:
- Rails/TimeZone
- app/controllers/court_dates_controller.rb:
- Rails/TimeZone
- app/controllers/emancipation_checklists_controller.rb:
- Layout/EmptyLinesAfterModuleInclusion
- app/controllers/imports_controller.rb:
- Layout/EmptyLinesAfterModuleInclusion
- app/controllers/other_duties_controller.rb:
- Layout/EmptyLineAfterGuardClause
- app/controllers/placements_controller.rb:
- Rails/LexicallyScopedActionFilter
- app/controllers/reimbursements_controller.rb:
- Rails/TimeZone
- app/controllers/users/sessions_controller.rb:
- Layout/EmptyLinesAfterModuleInclusion
- Rails/LexicallyScopedActionFilter
- app/datatables/volunteer_datatable.rb:
- Rails/CompactBlank
- Style/EmptyStringInsideInterpolation
- app/decorators/casa_case_decorator.rb:
- Layout/EmptyLineAfterGuardClause
- Rails/Date
- app/decorators/case_assignment_decorator.rb:
- Rails/Date
- app/decorators/contact_type_decorator.rb:
- Layout/EmptyLinesAfterModuleInclusion
- app/helpers/banner_helper.rb:
- Rails/TimeZone
- app/helpers/followup_helper.rb:
- Layout/EmptyLineAfterGuardClause
- app/helpers/phone_number_helper.rb:
- Rails/Blank
- Style/RedundantRegexpEscape
- app/helpers/sidebar_helper.rb:
- Layout/EmptyLineAfterGuardClause
- app/mailers/fund_request_mailer.rb:
- Rails/Date
- app/mailers/learning_hours_mailer.rb:
Expand All @@ -46,18 +66,22 @@ ignore:
- app/models/casa_case_emancipation_category.rb:
- Rails/UniqueValidationWithoutIndex
- app/models/casa_org.rb:
- Layout/EmptyLinesAfterModuleInclusion
- Rails/UniqueValidationWithoutIndex
- app/models/case_assignment.rb:
- Rails/UniqueValidationWithoutIndex
- Rails/RedundantPresenceValidationOnBelongsTo
- app/models/case_contact.rb:
- Layout/EmptyLinesAfterModuleInclusion
- Rails/FindEach
- app/models/case_contact_contact_type.rb:
- Rails/UniqueValidationWithoutIndex
- app/models/case_group.rb:
- Rails/UniqueValidationWithoutIndex
- app/models/concerns/CasaCase/validations.rb:
- Rails/TimeZone
- app/models/concerns/api.rb:
- Layout/EmptyLinesAfterModuleInclusion
- app/models/contact_type.rb:
- Rails/UniqueValidationWithoutIndex
- app/models/contact_type_group.rb:
Expand All @@ -82,11 +106,24 @@ ignore:
- Rails/Date
- app/models/volunteer.rb:
- Rails/WhereEquals
- Layout/EmptyLineAfterGuardClause
- app/notifications/delivery_methods/sms.rb:
- Layout/EmptyLinesAfterModuleInclusion
- app/policies/user_policy.rb:
- Layout/EmptyLineAfterGuardClause
- app/services/casa_case_change_service.rb:
- Rails/Pluck
- Layout/EmptyLineAfterGuardClause
- app/services/case_contacts_export_csv_service.rb:
- Layout/EmptyLineAfterGuardClause
- app/services/fdf_inputs_service.rb:
- Layout/EmptyLineAfterGuardClause
- Rails/Blank
- Rails/RootPathnameMethods
- app/services/learning_hours_export_csv_service.rb:
- Layout/EmptyLineAfterGuardClause
- app/services/short_url_service.rb:
- Layout/EmptyLinesAfterModuleInclusion
- app/validators/user_validator.rb:
- Rails/Blank
- config/application.rb:
Expand All @@ -96,6 +133,7 @@ ignore:
- db/migrate/20250507011754_remove_unused_indexes.rb:
- Rails/ReversibleMigration
- db/seeds/db_populator.rb:
- Layout/EmptyLineAfterGuardClause
- Rails/TimeZone
- Rails/FindEach
- Rails/Date
Expand All @@ -108,6 +146,7 @@ ignore:
- lib/mailers/previews/volunteer_mailer_preview.rb:
- Rails/Date
- lib/tasks/case_contact_types_reminder.rb:
- Layout/EmptyLineAfterGuardClause
- Rails/ActiveRecordAliases
- lib/tasks/data_post_processors/contact_topic_populator.rb:
- Rails/FindEach
Expand All @@ -117,10 +156,20 @@ ignore:
- Rails/ApplicationRecord
- lib/tasks/deployment/99991023145114_store_deploy_time.rake:
- Rails/TimeZone
- lib/tasks/example_recurring_task.rb:
- Layout/EmptyLinesAfterModuleInclusion
- lib/tasks/lint_factory_bot.rake:
- Layout/EmptyLineAfterGuardClause
- lib/tasks/no_contact_made_reminder.rb:
- Rails/ActiveRecordAliases
- lib/tasks/supervisor_weekly_digest.rb:
- Rails/TimeZone
- lib/tasks/test_checker.rake:
- Layout/EmptyLineAfterGuardClause
- scripts/import_casa_case_date_of_birth.rb:
- Layout/EmptyLineAfterGuardClause
- spec/controllers/concerns/accessible_spec.rb:
- Layout/EmptyLinesAfterModuleInclusion
- spec/datatables/reimbursement_datatable_spec.rb:
- Rails/TimeZone
- spec/decorators/casa_case_decorator_spec.rb:
Expand Down Expand Up @@ -150,13 +199,21 @@ ignore:
- Performance/Count
- spec/models/case_contact_spec.rb:
- Rails/TimeZone
- spec/models/case_court_report_spec.rb:
- Layout/EmptyLinesAfterModuleInclusion
- spec/models/learning_hours_report_spec.rb:
- Layout/EmptyLineAfterGuardClause
- spec/requests/bulk_court_dates_spec.rb:
- Rails/Date
- spec/requests/casa_cases_spec.rb:
- Rails/Date
- Rails/TimeZone
- spec/requests/case_contact_reports_spec.rb:
- Rails/Date
- spec/requests/case_court_reports_spec.rb:
- Layout/EmptyLinesAfterModuleInclusion
- spec/requests/court_dates_spec.rb:
- Layout/EmptyLinesAfterModuleInclusion
- spec/requests/notifications_spec.rb:
- Rails/Date
- spec/system/casa_cases/edit_spec.rb:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ A CASA (Court Appointed Special Advocate) is a role where a volunteer advocates

We are very happy to have you! CASA and Ruby for Good are committed to welcoming new contributors of all skill levels.

Find issues to work on [here](https://github.com/rubyforgood/casa/issues?q=is%3Aissue+is%3Aopen+no%3Aassignee) on the issue board. Issues on the [project's](https://github.com/rubyforgood/casa/projects/1) TODO column are another way to browse issues. Check to see that no one is assigned to the issue. Then comment on it to claim the issue. Commenting on an issue doesn't automatically get the issue assigned so double check the comments on an issue to see that no one is requesting assignment.
Find issues to work on [here](https://github.com/rubyforgood/casa/issues?q=is%3Aissue+is%3Aopen+no%3Aassignee) on the issue board. Issues on the [project's](https://github.com/rubyforgood/casa/projects/1) TODO column are another way to browse issues. Check to see that no one is assigned to the issue. Then comment on it to claim the issue. Commenting on an issue doesn't automatically get the issue assigned so double check the comments on an issue to see that no one is requesting assignment.

Pull requests which are not for an issue but which improve the codebase are also welcome! Feel free to make GitHub issues for bugs and improvements. A maintainer will be keeping an eye on issues and PRs every day or three.

### Communication and Collaboration

We highly recommend that you join us in [slack](https:https://join.slack.com/t/rubyforgood/shared_invite/zt-35218k86r-vlIiWqig54c9t~_LkGpQ7Q) in the #casa channel so you can get fast help for any questions you may have.

Check out [our google calendar](https://bit.ly/casacal) to see when office hours and stakeholder meetings are.
Check out [our google calendar](https://bit.ly/casacal) to see when office hours and stakeholder meetings are.

You can also open an issue or comment on an issue on GitHub and a maintainer will reply to you.

Expand Down Expand Up @@ -189,7 +189,7 @@ Test coverage is run by simplecov on all builds and aggregated by CodeClimate
Run `bin/lint` to run all linters and fix issues. This will run:

1. `bundle exec standardrb --fix` auto-fix Ruby linting issues [more linter info](https://github.com/testdouble/standard)
1. `bundle exec erblint --lint-all --autocorrect` [ERB linter](https://github.com/Shopify/erb-lint)
1. `bundle exec erb_lint --lint-all --autocorrect` [ERB linter](https://github.com/Shopify/erb-lint)
1. `npm run lint:fix` to run the [JS linter](https://standardjs.com/index.html) and fix issues
1. `rake factory_bot:lint` if you have been editing factories and want to find factories and traits which produce invalid objects

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/casa_org_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CasaOrgController < ApplicationController
before_action :set_sent_emails, only: %i[edit update]
before_action :set_contact_topics, only: %i[edit update]
before_action :set_custom_org_links, only: %i[edit update]
before_action :set_placement_types, only: %i[edit update]
before_action :require_organization!
after_action :verify_authorized
before_action :set_active_storage_url_options, only: %i[edit update]
Expand Down Expand Up @@ -95,6 +96,10 @@ def set_custom_org_links
@custom_org_links = @casa_org.custom_org_links
end

def set_placement_types
@placement_types = @casa_org.placement_types
end

def set_active_storage_url_options
ActiveStorage::Current.url_options = {host: request.base_url}
end
Expand Down
47 changes: 47 additions & 0 deletions app/controllers/placement_types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class PlacementTypesController < ApplicationController
before_action :set_placement_type, only: %i[edit update]
after_action :verify_authorized
after_action :verify_policy_scoped

def new
@placement_type = policy_scope(PlacementType).new(casa_org: current_organization)
authorize @placement_type
end

def create
@placement_type = policy_scope(PlacementType).new(placement_type_params)
authorize @placement_type

if @placement_type.save
redirect_to edit_casa_org_path(current_organization), notice: "Placement Type was successfully created."
else
render :new, status: :unprocessable_entity
end
end

def edit
authorize @placement_type
end

def update
authorize @placement_type

if @placement_type.update(placement_type_params)
redirect_to edit_casa_org_path(current_organization), notice: "Placement Type was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end

private

def set_placement_type
@placement_type = policy_scope(PlacementType).find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to edit_casa_org_path
end

def placement_type_params
params.require(:placement_type).permit(:name).merge(casa_org: current_organization)
end
end
22 changes: 22 additions & 0 deletions app/policies/placement_type_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class PlacementTypePolicy < ApplicationPolicy
class Scope < ApplicationPolicy::Scope
def resolve
case user
when CasaAdmin
scope.where(casa_org: @user.casa_org)
when Volunteer, Supervisor
scope.none
else
scope.none
end
end
end

def edit?
is_admin_same_org?
end

alias_method :new?, :edit?
alias_method :create?, :edit?
alias_method :update?, :edit?
end
49 changes: 49 additions & 0 deletions app/views/casa_org/_placement_types.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<div class="row">
<div class="col-lg-12">
<div class="card-style mb-30">
<div class="row align-items-center">
<div class="col-md-6">
<h3>Placement Types</h3>
</div>
<div class="col-md-6">
<div class="breadcrumb-wrapper">
<span class="ml-5">
<%= link_to new_placement_type_path, class: "btn-sm main-btn primary-btn btn-hover" do %>
<i class="lni lni-plus mr-10"></i>
New Placement Type
<% end %>
</span>
</div>
</div>
</div>
<div class="table-wrapper table-responsive">
<table class="table striped-table" id="placement-types-table">
<thead>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% placement_types.each do |placement_type| %>
<tr id="placement_type-<%= placement_type.id %>">
<td scope="row" class="min-width">
<%= placement_type.name %>
</td>
<td>
<%= link_to edit_placement_type_path(placement_type) do %>
<div class="action">
<button class="text-danger">
<i class="lni lni-pencil-alt"></i> Edit
</button>
</div>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
15 changes: 15 additions & 0 deletions app/views/casa_org/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,18 @@
<div class="tables-wrapper">
<%= render "contact_topics" %>
</div>

<div class="title-wrapper pt-30">
<div class="row align-items-center">
<div class="col-md-6">
<div class="title mb-30">
<h2 id="placement-types">
Manage Case Placement Types
</h2>
</div>
</div>
</div>
</div>
<div class="tables-wrapper">
<%= render "placement_types", placement_types: @placement_types %>
</div>
3 changes: 2 additions & 1 deletion app/views/layouts/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
{ title: "Contact Types", icon: "user", path: edit_casa_org_path(current_organization, anchor: 'contact-types'), render_check: policy(:application).modify_organization? },
{ title: "Court Details", icon: "library", path: edit_casa_org_path(current_organization, anchor: 'court-details'), render_check: policy(:application).modify_organization? },
{ title: "Learning Hours", icon: "timer", path: edit_casa_org_path(current_organization, anchor: 'learning-hours'), render_check: policy(:application).modify_organization? },
{ title: "Case Contact Topics", icon: "comments", path: edit_casa_org_path(current_organization, anchor: 'case-contact-topics'), render_check: policy(:application).modify_organization? }
{ title: "Case Contact Topics", icon: "comments", path: edit_casa_org_path(current_organization, anchor: 'case-contact-topics'), render_check: policy(:application).modify_organization? },
{ title: "Placement Types", icon: "comments", path: edit_casa_org_path(current_organization, anchor: 'placement-types'), render_check: policy(:application).modify_organization? }
]) %>
<% end %>
<% if current_organization.custom_org_links.any?(&:active) %>
Expand Down
18 changes: 18 additions & 0 deletions app/views/placement_types/_fields.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="input-style-1">
<%= form.label :placement_started_at, "Placement Started At" %>
<%= form.date_field :placement_started_at,
value: placement.placement_started_at&.to_date || Time.zone.now,
class: "form-control" %>
</div>
<div class="select-style-1">
<%= form.label :placement_type_id, "Placement Type" %>
<div class="select-position">
<%= form.collection_select(
:placement_type_id,
PlacementType.for_organization(current_organization).order_alphabetically,
:id, :name,
{include_hidden: false, include_blank: "-Select Placement Type-"},
{class: "form-control"}
) %>
</div>
</div>
Loading