Skip to content
This repository has been archived by the owner on Nov 6, 2021. It is now read-only.

Commit

Permalink
Add warning notice to Dashboard page and Partner Request page when pa…
Browse files Browse the repository at this point in the history
…rtner is deactivated
  • Loading branch information
EmersonManabuAraki committed Sep 2, 2020
1 parent 8a48376 commit f7dce4f
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def current_partner
def verify_status_in_diaper_base
if current_partner.status_in_diaper_base == "deactivated"
flash[:alert] = 'Your account has been disabled, contact the organization via their email to reactivate'
redirect_to partner_requests_path
end
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Prepares data to be shown to the users for their dashboard.
class DashboardController < ApplicationController
before_action :verify_status_in_diaper_base
respond_to :html, :js

def index
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/family_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class FamilyRequestsController < ApplicationController
before_action :authenticate_user!
before_action :verify_status_in_diaper_base

def new
verify_status_in_diaper_base
@filterrific = initialize_filterrific(
current_partner.children
.order(last_name: :asc)
Expand All @@ -13,7 +13,6 @@ def new
end

def create
verify_status_in_diaper_base
children = current_partner.children.active
children_grouped_by_diaperid = children.group_by(&:item_needed_diaperid)
api_response = DiaperBankClient.send_family_request(
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/partner_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class PartnerRequestsController < ApplicationController
before_action :authenticate_user!
before_action :verify_status_in_diaper_base

def index
@partner = current_partner
@partner_requests = current_partner.partner_requests.order(created_at: :desc) # PartnerRequest.where(partner_id: current_partner.id)
end

def new
verify_status_in_diaper_base
if current_partner.partner_status.casecmp("verified").zero?
@partner_request = PartnerRequest.new
@partner_request.item_requests.build # required to render the empty items form
Expand All @@ -17,7 +17,6 @@ def new
end

def create
verify_status_in_diaper_base
@partner_request = PartnerRequest.new(partner_request_params.merge(partner_id: current_partner.id))
@partner_request.item_requests << create_item_requests
respond_to do |format|
Expand Down
2 changes: 0 additions & 2 deletions spec/features/family_requests_feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@
scenario "it don't create because partner status in diaper base is deactivated" do
partner.update(status_in_diaper_base: "deactivated")
visit partner_requests_path
find_link("Create New Family Diaper Request").click
expect(page).to have_text("Your account has been disabled, contact the organization via their email to reactivate")
expect(current_path).to eq(partner_requests_path)
end
end
end

0 comments on commit f7dce4f

Please sign in to comment.