forked from rubyforgood/homeward-tails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
925 refactor adopter flow (rubyforgood#997)
* Add route, controller, view for embedded google form * Add external form url to organization model * Update after sign in route * Replace temp hard coded form url * Add route for creating a form submission * Add controller to create form submission, update external form view * Remove index, null constraint on adopter applications for adopter foster account. * Add person association, form_submission delegation * Update strong params * Update adopter application model associations, status enum, policy * Add user delegation * Fix applicant? method * Replace adopter application, remove old profile policy reference * Add translation * Update tests * Use service object to create form submissions * Update organizations controller, form to accept external form url * Update adopter applications to replace adopter foster account with form submission * Update seeds * Remove adopter foster account reference from pet, adoptable pets and application reviews controllers * Add external form to dashboard * Fix failing test * Add form instructions * Update registrations controller * Fix conditional for show action * Lint * Make revisions * Update seeds * Update seeds * Update adopter factory
- Loading branch information
1 parent
c536b22
commit 180a937
Showing
32 changed files
with
164 additions
and
56 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
21 changes: 21 additions & 0 deletions
21
app/controllers/organizations/adopter_fosterer/external_form_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,21 @@ | ||
module Organizations | ||
module AdopterFosterer | ||
class ExternalFormController < ApplicationController | ||
layout :form_layout | ||
|
||
def index | ||
authorize! with: ExternalFormPolicy | ||
|
||
@form_url = Current.organization.external_form_url | ||
end | ||
|
||
private | ||
|
||
def form_layout | ||
return "adopter_foster_dashboard" if params[:dashboard] | ||
|
||
"application" | ||
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
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
9 changes: 9 additions & 0 deletions
9
app/policies/organizations/adopter_fosterer/external_form_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,9 @@ | ||
module Organizations | ||
module AdopterFosterer | ||
class ExternalFormPolicy < ApplicationPolicy | ||
def index? | ||
permission?(:view_external_form) | ||
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
15 changes: 15 additions & 0 deletions
15
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="d-flex flex-column align-items-center mb-4"> | ||
<div class="my-4 mx-8"> | ||
<% if params[:dashboard] %> | ||
<p><%= t("organizations.adopter_fosterer.form_instructions.dashboard") %></p> | ||
<% else %> | ||
<p><%= t("organizations.adopter_fosterer.form_instructions.index", organization_name: Current.tenant.name) %></p> | ||
<% end %> | ||
<%= link_to 'View pets', adoptable_pets_path, class: "btn btn-primary float-end" %> | ||
</div> | ||
<iframe id="external-form" | ||
src=<%= @form_url%> | ||
width="90%" | ||
height="645" | ||
>Loading…</iframe> | ||
</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 |
---|---|---|
|
@@ -28,6 +28,10 @@ | |
<div class="form-group"> | ||
<%= form.text_field :email, placeholder: "[email protected]", class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= form.text_field :external_form_url, label: "Adoption Form", placeholder: "https://example.com", class: 'form-control' %> | ||
</div> | ||
</form> | ||
</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
5 changes: 5 additions & 0 deletions
5
db/migrate/20240825155349_add_external_form_url_to_organizations.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,5 @@ | ||
class AddExternalFormUrlToOrganizations < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :organizations, :external_form_url, :text | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20240902111455_change_adopter_foster_account_null_on_adopter_applications.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,6 @@ | ||
class ChangeAdopterFosterAccountNullOnAdopterApplications < ActiveRecord::Migration[7.1] | ||
def change | ||
remove_index :adopter_applications, column: [:adopter_foster_account_id], name: :index_adopter_applications_on_adopter_foster_account_id | ||
change_column_null(:adopter_applications, :adopter_foster_account_id, true) | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
...grate/20240902115121_remove_pet_adopter_foster_account_index_from_adopter_applications.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,5 @@ | ||
class RemovePetAdopterFosterAccountIndexFromAdopterApplications < ActiveRecord::Migration[7.1] | ||
def change | ||
remove_index :adopter_applications, column: [:pet_id, :adopter_foster_account_id], name: :index_adopter_applications_on_account_and_pet | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | |
slug: "alta", | ||
email: "[email protected]", | ||
phone_number: "250 816 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.") | ||
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" | ||
) | ||
|
||
ActsAsTenant.with_tenant(@organization) do | ||
|
@@ -75,7 +76,7 @@ | |
|
||
@user_adopter_one.add_role(:adopter, @organization) | ||
|
||
@adopter_one.create_form_submission! | ||
@adopter_one.form_submissions.create! | ||
|
||
@adopter_two = Person.create!( | ||
email: "[email protected]", | ||
|
@@ -94,7 +95,7 @@ | |
|
||
@user_adopter_two.add_role(:adopter, @organization) | ||
|
||
@adopter_two.create_form_submission! | ||
@adopter_two.form_submissions.create! | ||
|
||
@adopter_three = Person.create!( | ||
email: "[email protected]", | ||
|
@@ -113,7 +114,7 @@ | |
|
||
@user_adopter_three.add_role(:adopter, @organization) | ||
|
||
@adopter_three.create_form_submission! | ||
@adopter_three.form_submissions.create! | ||
|
||
@fosterer_one = Person.create!( | ||
email: "[email protected]", | ||
|
@@ -236,7 +237,7 @@ | |
|
||
match_application = AdopterApplication.create!( | ||
pet_id: Pet.first.id, | ||
form_submission_id: @adopter_one.form_submission.id, | ||
form_submission_id: @adopter_one.form_submissions.first.id, | ||
status: :successful_applicant | ||
) | ||
|
||
|
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 |
---|---|---|
|
@@ -75,7 +75,7 @@ | |
|
||
@user_adopter_one.add_role(:adopter, @organization) | ||
|
||
@adopter_one.create_form_submission! | ||
@adopter_one.form_submissions.create! | ||
|
||
@adopter_two = Person.create!( | ||
email: "[email protected]", | ||
|
@@ -94,7 +94,7 @@ | |
|
||
@user_adopter_two.add_role(:adopter, @organization) | ||
|
||
@adopter_two.create_form_submission! | ||
@adopter_two.form_submissions.create! | ||
|
||
@adopter_three = Person.create!( | ||
email: "[email protected]", | ||
|
@@ -113,7 +113,7 @@ | |
|
||
@user_adopter_three.add_role(:adopter, @organization) | ||
|
||
@adopter_three.create_form_submission! | ||
@adopter_three.form_submissions.create! | ||
|
||
@fosterer_one = Person.create!( | ||
email: "[email protected]", | ||
|
@@ -189,7 +189,7 @@ | |
|
||
match_application = AdopterApplication.create!( | ||
pet_id: Pet.first.id, | ||
form_submission_id: @adopter_one.form_submission.id, | ||
form_submission_id: @adopter_one.form_submissions.first.id, | ||
status: :successful_applicant | ||
) | ||
|
||
|
Oops, something went wrong.