-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopter fosterer form answers (#1256)
* remove broadcast as it throws redis missing error in production; add dependent destroy on org * Update associations and add migration to move adopter applications to belong to person * Update AdopterApplication to use Person; update seeds for new associations * refactor models, controllers, views, tests to handle new associations * remove creation of form submission on adopter sign up * implemenet routs, controllers, views and policies for staff to review form submissions and form answers; * lint * appease brakeman * add tests; add form answer header * update tests * lint * remove handling the nil person case, this should fail loudly as it should not occur * remove partial as I am not using it * move empty state text to translation file * fix * update foster links to fosterer data * WIP * Update to show csv_timestamp and import date and show HH MM on the submitted at in case someone submits a form twice in one day, then it is easiser to determine which answers you are looking at * merge main * remove creation of formsubmission on creation of adopter user in seeds * lint * working prototype, needs authorization * add remaining translations * add policy check; add association between FormAnswer and Person * lint * update icons * lint * fix routes * lint * update seeds to both have donate URL and form URL; create form answers partial * policy tests * lint * update messagin on the third party form page * fix spacing
- Loading branch information
1 parent
5f8eaae
commit dbcbeee
Showing
14 changed files
with
220 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
email: "[email protected]", | ||
phone_number: "201 555 8212", | ||
custom_page: CustomPage.new(hero: "Where every paw finds a home", about: "Alta was founded by an incredible group of ladies in April of 2020. Our initial goal was to have both a rescue and a spay/neuter clinic, however, we quickly realized that it would be more efficient to separate into two organizations."), | ||
external_form_url: "https://docs.google.com/forms/d/e/1FAIpQLSf9bI-kboxyQQB5I1W5pt0R25u9pHoXI7o3jQHKu1P4K-61mA/viewform?embedded=true" | ||
external_form_url: "https://docs.google.com/forms/d/e/1FAIpQLSf9bI-kboxyQQB5I1W5pt0R25u9pHoXI7o3jQHKu1P4K-61mA/viewform?embedded=true", | ||
donation_url: "https://wwww.example.com/" | ||
) | ||
|
||
ActsAsTenant.with_tenant(@organization) do | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,9 @@ | |
slug: "baja", | ||
email: "[email protected]", | ||
phone_number: "201 555 8212", | ||
custom_page: CustomPage.new(hero: "hero text", about: "about us text") | ||
custom_page: CustomPage.new(hero: "hero text", about: "about us text"), | ||
external_form_url: "https://docs.google.com/forms/d/e/1FAIpQLSf9bI-kboxyQQB5I1W5pt0R25u9pHoXI7o3jQHKu1P4K-61mA/viewform?embedded=true", | ||
donation_url: "https://wwww.example.com/" | ||
) | ||
|
||
ActsAsTenant.with_tenant(@organization) do | ||
|
Oops, something went wrong.