-
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.
revert renaming of adopter applications to custom form submissions
- Loading branch information
1 parent
fb85ab0
commit 2ea43d9
Showing
71 changed files
with
777 additions
and
792 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
57 changes: 57 additions & 0 deletions
57
app/controllers/organizations/adopter_fosterer/adopter_applications_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,57 @@ | ||
class Organizations::AdopterFosterer::AdopterApplicationsController < Organizations::BaseController | ||
before_action :authenticate_user! | ||
before_action :set_application, only: %i[update] | ||
layout "adopter_foster_dashboard" | ||
|
||
def index | ||
authorize! with: AdopterApplicationPolicy | ||
|
||
@applications = authorized_scope(AdopterApplication.where(profile_show: true), with: AdopterApplicationPolicy) | ||
end | ||
|
||
def create | ||
@pet = Pet.find(application_params[:pet_id]) | ||
authorize! context: {pet: @pet}, with: AdopterApplicationPolicy | ||
|
||
@application = AdopterApplication.new(application_params) | ||
|
||
if @application.save | ||
redirect_to adoptable_pet_path(@application.pet), | ||
notice: t(".success", message: MessagesHelper.affirmations.sample) | ||
|
||
# mailer | ||
@org_staff = User.organization_staff(@pet.organization_id) | ||
StaffApplicationNotificationMailer.with(pet: @pet, | ||
organization_staff: @org_staff) | ||
.new_adoption_application.deliver_now | ||
else | ||
redirect_to adoptable_pet_path(@pet), | ||
alert: t(".error") | ||
end | ||
end | ||
|
||
# update :status to 'withdrawn' or :profile_show to false | ||
def update | ||
if @application.update(application_params) | ||
redirect_to adopter_fosterer_adopter_applications_path | ||
else | ||
redirect_to adopter_fosterer_profile_path, alert: t(".error") | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_application | ||
@application = AdopterApplication.find(params[:id]) | ||
authorize! @application, with: AdopterApplicationPolicy | ||
end | ||
|
||
def application_params | ||
params.require(:adopter_application).permit( | ||
:pet_id, | ||
:adopter_foster_account_id, | ||
:status, | ||
:profile_show | ||
) | ||
end | ||
end |
63 changes: 0 additions & 63 deletions
63
app/controllers/organizations/adopter_fosterer/custom_form/submissions_controller.rb
This file was deleted.
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
57 changes: 57 additions & 0 deletions
57
app/controllers/organizations/staff/adoption_application_reviews_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,57 @@ | ||
class Organizations::Staff::AdoptionApplicationReviewsController < Organizations::BaseController | ||
before_action :set_adopter_application, only: %i[edit update] | ||
|
||
include ::Pagy::Backend | ||
|
||
layout "dashboard" | ||
|
||
def index | ||
authorize! AdopterApplication, | ||
context: {organization: Current.organization} | ||
|
||
@q = authorized_scope( | ||
Pet.org_pets_with_apps(current_user.staff_account.organization_id) | ||
).ransack(params[:q]) | ||
@pets_with_applications = @q.result.includes(:adopter_applications) | ||
|
||
# Combining these into a single chained statement does not yield the same result due to how Ransack processes parameters. | ||
if params[:q].present? && params[:q]["adopter_applications_status_eq"].present? | ||
status_filter = params[:q]["adopter_applications_status_eq"] | ||
@pets_with_applications = filter_by_application_status(@pets_with_applications, status_filter) | ||
end | ||
|
||
@pagy, @pets_with_applications = pagy(@pets_with_applications, items: 10) | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
@applications_tab = request.referrer.include?("applications") # Change table display in pets/applications tab | ||
|
||
respond_to do |format| | ||
if @application.update(application_params) | ||
format.html { redirect_to staff_dashboard_index_path } | ||
format.turbo_stream { flash.now[:notice] = t(".success") } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.turbo_stream { flash.now[:alert] = t(".error") } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def application_params | ||
params.require(:adopter_application).permit(:status, :notes, :profile_show) | ||
end | ||
|
||
def set_adopter_application | ||
@application = AdopterApplication.find(params[:id]) | ||
authorize! @application | ||
end | ||
|
||
def filter_by_application_status(pets_relation, status_filter) | ||
pets_relation.joins(:adopter_applications).where(adopter_applications: {status: status_filter}) | ||
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
58 changes: 0 additions & 58 deletions
58
app/controllers/organizations/staff/submission_reviews_controller.rb
This file was deleted.
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
module AdoptionApplicationReviewsHelper | ||
def submission_status_classes(submission) | ||
def application_status_classes(application) | ||
status_classes = {awaiting_review: "text-white bg-dark-primary", | ||
under_review: "text-white bg-dark-info", | ||
adoption_pending: "text-black bg-light-warning", | ||
withdrawn: "text-black bg-gray-200", | ||
successful_applicant: "text-black bg-light-success", | ||
adoption_made: "text-black bg-light-success"} | ||
|
||
status_classes[submission.status.to_sym] | ||
status_classes[application.status.to_sym] | ||
end | ||
end |
4 changes: 2 additions & 2 deletions
4
...s/staff_submission_notification_mailer.rb → .../staff_application_notification_mailer.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
Oops, something went wrong.