Skip to content

Commit 5011963

Browse files
authored
Merge branch 'main' into 5000-remove-mycoworkers-from-org-user-dropdown
2 parents e1d9891 + 5c1ddf1 commit 5011963

File tree

19 files changed

+150
-63
lines changed

19 files changed

+150
-63
lines changed

app/controllers/donations_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def index
3333
@donations_quantity = @donations.collect(&:total_quantity).sum
3434
@paginated_donations_quantity = @paginated_donations.collect(&:total_quantity).sum
3535
@total_value_all_donations = total_value(@donations)
36+
@paginated_in_kind_value = total_value(@paginated_donations)
3637
@total_money_raised = total_money_raised(@donations)
3738
@storage_locations = @donations.filter_map { |donation| donation.storage_location if !donation.storage_location.discarded_at }.compact.uniq.sort
3839
@selected_storage_location = filter_params[:at_storage_location]

app/controllers/organizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def organization_params
9494
params.require(:organization).permit(
9595
:name, :short_name, :street, :city, :state,
9696
:zipcode, :email, :url, :logo, :intake_location,
97-
:default_storage_location, :default_email_text,
97+
:default_storage_location, :default_email_text, :reminder_email_text,
9898
:invitation_text, :reminder_day, :deadline_day,
9999
:repackage_essentials, :distribute_monthly,
100100
:ndbn_member_id, :enable_child_based_requests,

app/controllers/vendors_controller.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ def reactivate
8888
redirect_to vendors_path, notice: "#{vendor.business_name} has been reactivated."
8989
end
9090

91+
def destroy
92+
vendor = current_organization.vendors.find(params[:id])
93+
vendor.destroy
94+
if vendor.errors.any?
95+
errors = vendor.errors.full_messages.join("\n")
96+
redirect_to vendors_path, error: "#{vendor.business_name} could not be removed. \n#{errors}"
97+
return
98+
end
99+
100+
redirect_to vendors_path, notice: "#{vendor.business_name} has been removed."
101+
end
102+
91103
private
92104

93105
def vendor_params

app/mailers/reminder_deadline_mailer.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ def notify_deadline(partner)
44
@partner = partner
55
@organization = partner.organization
66
@deadline = deadline_date(partner)
7+
reminder_email_text = @organization.reminder_email_text
8+
@reminder_email_text_interpolated = TextInterpolatorService.new(reminder_email_text.body.to_s, {
9+
partner_name: @partner.name
10+
}).call
711

812
mail(to: @partner.email, subject: "#{@organization.name} Deadline Reminder")
913
end

app/models/organization.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def flipper_id
115115
].freeze
116116

117117
has_rich_text :default_email_text
118+
has_rich_text :reminder_email_text
118119

119120
has_one_attached :logo
120121

app/models/vendor.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class Vendor < ApplicationRecord
3535
.group(:id)
3636
}
3737

38+
before_destroy :check_for_purchases, prepend: true
39+
3840
def volume
3941
LineItem.where(
4042
itemizable_type: "Purchase",
@@ -49,4 +51,13 @@ def deactivate!
4951
def reactivate!
5052
update!(active: true)
5153
end
54+
55+
private
56+
57+
def check_for_purchases
58+
return if purchases.empty?
59+
60+
errors.add(:base, "Vendor has purchase items")
61+
throw(:abort)
62+
end
5263
end

app/views/distribution_mailer/partner_mailer.text.erb

Lines changed: 0 additions & 19 deletions
This file was deleted.

app/views/donations/index.html.erb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<th>Money Raised</th>
112112
<th>In Kind Value</th>
113113
<th>Comments</th>
114-
<th>Actions</th>
114+
<th class="text-right">Actions</th>
115115
</tr>
116116
</thead>
117117
<tbody>
@@ -125,14 +125,25 @@
125125
<td></td>
126126
<td class="text-left numeric">
127127
<strong id="donation_quantity">
128-
<%= @donations_quantity %> (Total)
128+
<%= @donations_quantity %>
129+
<br>
130+
(Total)
129131
</strong>
130132
<br>
131-
<%= @paginated_donations_quantity %> (This page)
133+
<%= @paginated_donations_quantity %>
134+
<br>
135+
(This page)
132136
</td>
133137
<td class="text-left numeric"><strong><%= dollar_value(@total_money_raised) %></strong></td>
134-
<td class="text-left numeric"><strong><%= dollar_value(@total_value_all_donations) %></strong></td>
135-
<td></td>
138+
<td class="text-left numeric in-kind">
139+
<strong>
140+
<%= dollar_value(@total_value_all_donations) %> (Total)
141+
</strong>
142+
<br>
143+
<%= dollar_value(@paginated_in_kind_value) %>
144+
<br>
145+
(This page)
146+
</td>
136147
</tr>
137148
</tfoot>
138149
</table>

app/views/organizations/_details.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
<%= @organization.deadline_day.blank? ? 'Not defined' : "The #{@organization.deadline_day.ordinalize} of each month" %>
7777
</p>
7878
</div>
79+
<div class="mb-4">
80+
<h3 class='font-bold'>Additional text for reminder email</h3>
81+
<p>
82+
<%= @organization.reminder_email_text.presence || 'Not defined' %>
83+
</p>
84+
</div>
7985
<div class="mb-4">
8086
<h3 class='font-bold'>Default Intake Location</h3>
8187
<p>

app/views/organizations/edit.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787

8888
<%= render 'shared/deadline_day_fields', f: f %>
8989

90+
<% default_reminder_email_text_hint = "You can use the variable <code>%{partner_name}</code> to include the partner's name in the message." %>
91+
<%= f.input :reminder_email_text, label: "Additional text for reminder email", hint: default_reminder_email_text_hint.html_safe do %>
92+
<%= f.rich_text_area :reminder_email_text, placeholder: 'Enter reminder email content...' %>
93+
<% end %>
94+
9095
<%= f.input :intake_location, :collection => current_organization.storage_locations.active.alphabetized, :label_method => :name, :value_method => :id, :label => "Default Intake Location", :include_blank => true, wrapper: :input_group %>
9196

9297
<%= f.label :partner_form_fields, 'Partner Profile Sections' %>

0 commit comments

Comments
 (0)