-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-new-pet-tooltip
- Loading branch information
Showing
42 changed files
with
607 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Organizations | ||
class ActivationsController < Organizations::BaseController | ||
def update | ||
@user = User.find(params[:user_id]) | ||
|
||
authorize! @user, with: ActivationsPolicy | ||
|
||
if @user.deactivated_at | ||
@user.activate | ||
else | ||
@user.deactivate | ||
end | ||
|
||
respond_to do |format| | ||
success = @user.deactivated_at.nil? ? | ||
t(".activated", staff: @user.full_name) : | ||
t(".deactivated", staff: @user.full_name) | ||
format.html { redirect_to staff_staff_index_path, notice: success } | ||
format.turbo_stream { flash.now[:notice] = success } | ||
end | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
app/controllers/organizations/adopter_fosterer/form_answers_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Organizations | ||
module AdopterFosterer | ||
class FormAnswersController < Organizations::BaseController | ||
layout "adopter_foster_dashboard" | ||
|
||
before_action :context_authorize! | ||
before_action :set_latest_form_submission | ||
|
||
def index | ||
@form_answers = authorized_scope(@latest_form_submission.form_answers) | ||
end | ||
|
||
private | ||
|
||
def context_authorize! | ||
authorize! with: Organizations::AdopterFosterer::FormAnswerPolicy | ||
end | ||
|
||
def set_latest_form_submission | ||
@latest_form_submission = current_user.person.latest_form_submission | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Organizations | ||
class ActivationsPolicy < ApplicationPolicy | ||
pre_check :verify_organization! | ||
pre_check :verify_active_staff! | ||
|
||
def update? | ||
return false if record.id == user.id | ||
|
||
record_role = record.roles.first.name | ||
|
||
if %w[super_admin admin].include?(record_role) | ||
permission?(:activate_staff) | ||
else | ||
permission?(:activate_foster) && permission?(:activate_adopter) | ||
end | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/policies/organizations/adopter_fosterer/form_answer_policy.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Organizations | ||
module AdopterFosterer | ||
class FormAnswerPolicy < ApplicationPolicy | ||
relation_scope do |relation| | ||
relation.joins(form_submission: :person).where(form_submissions: {person_id: user.person.id}) | ||
end | ||
|
||
def index? | ||
permission?(:view_form_answers) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= turbo_stream.replace "flash", partial: "layouts/shared/flash_messages" %> |
11 changes: 9 additions & 2 deletions
11
app/views/organizations/adopter_fosterer/external_form/index.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/views/organizations/adopter_fosterer/form_answers/index.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= render DashboardPageComponent.new do |c| %> | ||
<% c.with_header_title { t('.header') } %> | ||
<% c.with_body do %> | ||
|
||
<p><%= t('.description') %> <%= link_to t("general.here"), adopter_fosterer_external_form_index_path(dashboard: true) %>.</p> | ||
|
||
<div class="justify-content-md-between mb-4 mb-xl-0 gx-3"> | ||
<div class="row"> | ||
<% if @form_answers.present? %> | ||
<h4><%= t(".submitted_on", date: @latest_form_submission.csv_timestamp.strftime("%Y-%m-%d"), time: @latest_form_submission.csv_timestamp.strftime("%H:%M")) %></h4> | ||
|
||
<%= render partial: "organizations/shared/form_answers", collection: @form_answers, as: :form_answer %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="justify-content-md-between mb-2 gx-3"> | ||
<div class="card"> | ||
<div id="<%= dom_id form_answer %>"class="card-body d-flex flex-sm-row flex-column justify-content-between border-bottom"> | ||
<div class="d-flex align-items-center"> | ||
<div> | ||
<strong class="fs-4" >Q: <%= form_answer.question_snapshot %></strong> | ||
<p class="mb-0">A: <%= form_answer.value %> </p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/views/organizations/staff/external_form_upload/_upload_results.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<turbo-frame id="results"> | ||
<% if import.success? %> | ||
<div class="alert alert-success"> | ||
<h5 class="alert-heading" role="alert"><%= t('.success_heading') %></h5> | ||
<p><%= t('.submissions_added', count: import.count) %></p> | ||
</div> | ||
<% else %> | ||
<div class="alert alert-danger"> | ||
<h5 class="alert-heading" role="alert"><%= t('.error_heading', count: import.errors.count) %></h5> | ||
<p><%= t('.submissions_added', count: import.count) %></p> | ||
<%= t('.review_errors', count: import.count) %> | ||
<ul> | ||
<% import.errors.each do |error| %> | ||
<li> | ||
<%= t('.row', number: error[0], message: error[1].message) %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,5 @@ | ||
<%= turbo_frame_tag :form_answers do %> | ||
<h4>Form Answers (<%= @form_submission.csv_timestamp.strftime("%Y-%m-%d") %> at <%= @form_submission.csv_timestamp.strftime("%H:%M") %>)</h4> | ||
|
||
<% @form_answers.each do |form_answer| %> | ||
<div class="justify-content-md-between mb-2 gx-3"> | ||
<div class="card"> | ||
<div id="<%= dom_id form_answer %>"class="card-body d-flex flex-sm-row flex-column justify-content-between border-bottom"> | ||
<div class="d-flex align-items-center"> | ||
<div> | ||
<strong class="fs-4" >Q: <%= form_answer.question_snapshot %></strong> | ||
<p class="mb-0">A: <%= form_answer.value %> </p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= render partial: "organizations/shared/form_answers", collection: @form_answers, as: :form_answer %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.