Skip to content

Commit 69f3fcd

Browse files
authored
Merge branch 'rubyforgood:main' into 4948-fix-sort-issues-1
2 parents 94b5f3e + 7f5b420 commit 69f3fcd

File tree

74 files changed

+737
-336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+737
-336
lines changed

app/assets/stylesheets/resources/partners.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ div#partner-notes {
4949
padding: 0px 20px;
5050
}
5151

52+
div#info-for-partner {
53+
padding: 0px 20px;
54+
}
55+
5256
div#approve-application-button {
5357
position: fixed;
5458

app/controllers/admin/organizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def destroy
7171

7272
def organization_params
7373
params.require(:organization)
74-
.permit(:name, :street, :city, :state, :zipcode, :email, :url, :logo, :intake_location, :default_email_text, :account_request_id, :reminder_day, :deadline_day,
74+
.permit(:name, :street, :city, :state, :zipcode, :email, :url, :logo, :intake_location, :default_email_text, :account_request_id, :reminder_day, :deadline_day, :bank_is_set_up,
7575
users_attributes: %i(name email organization_admin), account_request_attributes: %i(ndbn_member_id id))
7676
end
7777

app/controllers/audits_controller.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ def edit
2121
end
2222

2323
def finalize
24-
@audit.adjustment = Adjustment.new(organization_id: @audit.organization_id, storage_location_id: @audit.storage_location_id, user_id: current_user.id, comment: 'Created Automatically through the Auditing Process')
25-
@audit.save
26-
2724
AuditEvent.publish(@audit)
2825
@audit.finalized!
2926
redirect_to audit_path(@audit), notice: "Audit is Finalized."

app/controllers/dashboard_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class DashboardController < ApplicationController
33
respond_to :html, :js
44

55
def index
6-
@org_stats = OrganizationStats.new(current_organization, inventory)
6+
@org_is_set_up = current_organization.bank_is_set_up
77
@partners_awaiting_review = current_organization.partners.awaiting_review
88
@outstanding_requests = current_organization
99
.ordered_requests

app/controllers/donations_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ def destroy
127127

128128
def load_form_collections
129129
@storage_locations = current_organization.storage_locations.active.alphabetized
130-
@donation_sites = current_organization.donation_sites.active.alphabetized
131130
@product_drives = current_organization.product_drives.alphabetized
132131
@product_drive_participants = current_organization.product_drive_participants.alphabetized
133132
@manufacturers = current_organization.manufacturers.alphabetized
134133
@items = current_organization.items.active.alphabetized
134+
# Return all active donation sites, or the donation site that was selected for the donation if it's inactive
135+
@donation_sites = current_organization.donation_sites.active.or(DonationSite.where(id: @donation.donation_site_id)).alphabetized
135136
end
136137

137138
def clean_donation_money_raised

app/controllers/organizations_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def update
1919
@organization = current_organization
2020

2121
if OrganizationUpdateService.update(@organization, organization_params)
22-
redirect_to organization_path, notice: "Updated your organization!"
22+
redirect_back(fallback_location: organization_path, notice: "Updated your organization!")
2323
else
2424
flash.now[:error] = @organization.errors.full_messages.join("\n")
2525
render :edit
@@ -102,6 +102,7 @@ def organization_params
102102
:ytd_on_distribution_printout, :one_step_partner_invite,
103103
:hide_value_columns_on_receipt, :hide_package_column_on_receipt,
104104
:signature_for_distribution_pdf, :receive_email_on_requests,
105+
:bank_is_set_up,
105106
:include_in_kind_values_in_exported_files,
106107
partner_form_fields: [],
107108
request_unit_names: []

app/controllers/partners_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def validate_user_role
182182

183183
def partner_params
184184
params.require(:partner).permit(:name, :email, :send_reminders, :quota,
185-
:notes, :partner_group_id, :default_storage_location_id, documents: [])
185+
:notes, :partner_group_id, :default_storage_location_id, :info_for_partner, documents: [])
186186
end
187187

188188
helper_method \

app/controllers/product_drives_controller.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,18 @@ def update
8888
end
8989

9090
def destroy
91-
current_organization.product_drives.find(params[:id]).destroy
91+
product_drive = current_organization.product_drives.find(params[:id])
92+
success = product_drive.destroy
93+
9294
respond_to do |format|
93-
format.html { redirect_to product_drives_url, notice: 'Product drive was successfully destroyed.' }
94-
format.json { head :no_content }
95+
if success
96+
format.html { redirect_to product_drives_url, notice: 'Product drive was successfully destroyed.' }
97+
format.json { head :no_content }
98+
else
99+
error_message = product_drive.errors.full_messages.to_sentence
100+
format.html { redirect_to product_drive_path(product_drive), error: error_message }
101+
format.json { render json: {error: error_message}, status: :unprocessable_entity }
102+
end
95103
end
96104
end
97105

app/controllers/reports_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def activity_graph
3939
@distribution_data = received_distributed_data(helpers.selected_range)
4040
end
4141

42+
def itemized_requests
43+
requests = current_organization.requests.during(helpers.selected_range)
44+
@itemized_request_data = RequestItemizedBreakdownService.call(organization: current_organization, request_ids: requests.pluck(:id))
45+
end
46+
4247
private
4348

4449
def total_purchased_unformatted(range = selected_range)

app/controllers/transfers_controller.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def index
2121

2222
def create
2323
@transfer = current_organization.transfers.new(transfer_params)
24+
@transfer.line_items.combine!
2425

2526
TransferCreateService.call(@transfer)
2627
redirect_to transfers_path, notice: "#{@transfer.line_items.total} items have been transferred from #{@transfer.from.name} to #{@transfer.to.name}!"
@@ -57,6 +58,18 @@ def destroy
5758
redirect_to transfers_path
5859
end
5960

61+
def validate
62+
@transfer = current_organization.transfers.new(transfer_params)
63+
@transfer.line_items.combine!
64+
65+
if @transfer.valid?
66+
body = render_to_string(partial: "transfers/validate_modal", formats: [:html], layout: false)
67+
render json: {valid: true, body: body}
68+
else
69+
render json: {valid: false}, status: :unprocessable_entity
70+
end
71+
end
72+
6073
private
6174

6275
def load_form_collections

0 commit comments

Comments
 (0)