Skip to content

Commit 3e6fd8b

Browse files
Merge branch 'main' into 3845-friendly-message-on-invalid-token
2 parents e6ae00b + 69c4891 commit 3e6fd8b

File tree

82 files changed

+840
-761
lines changed

Some content is hidden

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

82 files changed

+840
-761
lines changed
Lines changed: 35 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,56 @@
1-
html, body {
2-
background-color: white;
3-
height: calc(100vw - 3em);
4-
position: relative;
5-
}
1+
@import 'bootstrap';
62

73
.hero {
8-
&-background {
9-
background: linear-gradient(135deg, #3023AE , #C86DD7);
10-
width: 100%;
11-
color: white;
12-
height: 660px;
13-
@media (max-width: 1200px) {
14-
height: 590px;
15-
}
16-
@media (max-width: 992px) {
17-
height: auto;
18-
}
19-
@media (max-width: 768px) {
20-
height: auto;
21-
}
22-
@media (max-width: 576px) {
23-
height: auto;
24-
}
25-
}
26-
&-image {
27-
flex-basis: 1400px;
28-
@media (max-width: 576px) {
29-
margin-bottom: 20px;
30-
}
31-
@media (max-width: 768px) {
32-
margin-bottom: 20px;
33-
}
34-
}
35-
&-copy {
36-
z-index: 1;
37-
@media (max-width: 768px) {
38-
text-align: center;
39-
}
40-
@media (max-width: 576px) {
41-
text-align: center;
42-
}
43-
}
44-
}
45-
46-
.navbar-brand {
47-
margin-right: none !important;
4+
background: linear-gradient(135deg, #3023AE, #C86DD7);
485

49-
@media (max-width: 568px) {
6+
nav {
507
h2 {
51-
font-size: 0.8em;
8+
@media (max-width: 567px) {
9+
font-size: 1.125rem;
10+
}
5211
}
53-
}
54-
}
55-
56-
.navbar-light .navbar-toggler {
57-
border: none;
58-
margin-top: 13px;
59-
}
60-
61-
button:focus {
62-
outline: none !important;
63-
outline: none !important;
64-
}
65-
66-
button:hover, button:focus, .button:hover, .button:focus {
67-
background-color: rgba(255, 255, 255, 0) !important;
68-
}
69-
70-
.btn-primary {
71-
background-color: #55af59 !important;
72-
border-color: #55af59 !important;
73-
}
74-
75-
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active {
76-
background-color: #55af59 !important;
77-
border-color: #55af59 !important;
78-
}
7912

80-
.text {
13+
button span {
14+
font-size: 1.25rem;
8115

82-
&-header {
83-
color: #454F5B;
84-
}
85-
&-body-color {
86-
color: #919EAB !important;
87-
line-height: 2em;
16+
@media (max-width: 567px) {
17+
font-size: 1rem;
18+
}
8819
}
89-
&-testimonials {
90-
color: white;
91-
line-height: 1.5em;
92-
font-size: 14px;
20+
}
9321

94-
}
22+
.hero-subcontainer {
23+
height:60vh;
24+
min-height: 500px
25+
}
9526
}
9627

97-
.description-container {
98-
margin-top: 120px;
99-
@media (max-width: 576px) {
100-
margin-top: 80px;
101-
}
28+
.container-fluid {
29+
max-width: 1280px;
10230
}
10331

104-
.bottom-cta {
105-
margin-top: 80px;
106-
margin-bottom: 80px;
107-
@media (max-width: 576px) {
108-
margin-top: 50px;
109-
margin-bottom: 50px;
110-
}
32+
.btn-success {
33+
background-color: #55af59 !important;
34+
border-color: #55af59 !important;
11135
}
11236

113-
.app-images {
114-
width: 400px;
115-
height: 400px;
116-
&-block {
117-
flex-basis: 340px;
118-
}
37+
.btn-success:hover,
38+
.btn-success:focus,
39+
.btn-success:active,
40+
.btn-success.active {
41+
background-color: #408e44 !important;
42+
border-color: #408e44 !important;
11943
}
12044

121-
.green-bkg {
122-
background: linear-gradient(45deg, #1AD1BD , #02A98C);
123-
height: auto;
45+
.app-images {
46+
height: 400px;
47+
width: 100%;
12448
}
12549

126-
.quote {
127-
&-block {
128-
flex-basis: 400px;
129-
}
130-
&-image {
131-
flex-basis: 600px;
132-
}
133-
}
50+
#testimonials {
51+
background-color: rgb(22, 163, 74);
13452

135-
.footer-content {
136-
background-color: #C4CDD5;
137-
padding-top: 150px;
138-
padding-bottom: 150px;
53+
.quote-image {
54+
width: 300px;
55+
}
13956
}

app/controllers/admin/partners_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Admin::PartnersController < AdminController
22
def index
3-
@partners = Partner.all.includes(:organization)
3+
@partners = Partner.all.includes(:organization).order("LOWER(name)")
44
end
55

66
def show

app/controllers/donation_sites_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def create
2626
render action: :new
2727
end
2828
end
29-
format.js { render partial: "shared/table_row_prepend", object: @donation_site }
3029
end
3130
end
3231

app/controllers/items_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def create
4444
@base_items = BaseItem.without_kit.alphabetized
4545
# Define a @item to be used in the `new` action to be rendered with
4646
# the provided parameters. This is required to render the page again
47-
# with the error + the invalid parameters
47+
# with the error + the invalid parameters.
48+
@item_categories = current_organization.item_categories.order('name ASC') # Load categories here
4849
@item = current_organization.items.new(item_params)
4950
flash.now[:error] = result.error.record.errors.full_messages.to_sentence
5051
render action: :new

app/controllers/partners/requests_controller.rb

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module Partners
22
class RequestsController < BaseController
3+
skip_before_action :require_partner, only: [:new, :create, :validate]
4+
before_action :require_partner_or_org_admin, only: [:new, :create, :validate]
5+
layout :layout
6+
37
protect_from_forgery with: :exception
48

59
def index
@@ -21,15 +25,20 @@ def show
2125
def create
2226
create_service = Partners::RequestCreateService.new(
2327
request_type: "quantity",
24-
partner_user_id: current_user.id,
28+
partner_id: partner.id,
29+
user_id: current_user.id,
2530
comments: partner_request_params[:comments],
2631
item_requests_attributes: partner_request_params[:item_requests_attributes]&.values || []
2732
)
2833

2934
create_service.call
3035
if create_service.errors.none?
3136
flash[:success] = 'Request was successfully created.'
32-
redirect_to partners_request_path(create_service.partner_request.id)
37+
if current_partner
38+
redirect_to partners_request_path(create_service.partner_request.id)
39+
else
40+
redirect_to request_path(create_service.partner_request.id)
41+
end
3342
else
3443
@partner_request = create_service.partner_request
3544
@errors = create_service.errors
@@ -45,15 +54,16 @@ def create
4554
def validate
4655
create_service = Partners::RequestCreateService.new(
4756
request_type: "quantity",
48-
partner_user_id: current_user.id,
57+
partner_id: partner.id,
58+
user_id: current_user.id,
4959
comments: partner_request_params[:comments],
5060
item_requests_attributes: partner_request_params[:item_requests_attributes]&.values || []
5161
).initialize_only
5262

5363
if create_service.errors.none?
5464
@partner_request = create_service.partner_request
5565
@total_items = @partner_request.total_items
56-
@quota_exceeded = current_partner.quota_exceeded?(@total_items)
66+
@quota_exceeded = partner.quota_exceeded?(@total_items)
5767
body = render_to_string(template: 'partners/requests/validate', formats: [:html], layout: false)
5868
render json: {valid: true, body: body}
5969
else
@@ -68,13 +78,42 @@ def partner_request_params
6878
end
6979

7080
def fetch_items
71-
@requestable_items = PartnerFetchRequestableItemsService.new(partner_id: current_partner.id).call
81+
@requestable_items = PartnerFetchRequestableItemsService.new(partner_id: partner.id).call
7282
if Flipper.enabled?(:enable_packs)
7383
# hash of (item ID => hash of (request unit name => request unit plural name))
7484
@item_units = Item.where(id: @requestable_items.to_h.values).to_h do |i|
7585
[i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }]
7686
end
7787
end
7888
end
89+
90+
def require_partner_or_org_admin
91+
return if current_partner
92+
93+
partner_id = params.permit(:partner_id)[:partner_id]
94+
return redirect_invalid_user if partner_id.blank?
95+
96+
partner = Partner.find(partner_id)
97+
if current_user.has_role?(Role::ORG_ADMIN, current_organization) && current_organization == partner&.organization
98+
@partner = partner
99+
else
100+
redirect_invalid_user
101+
end
102+
end
103+
104+
def redirect_invalid_user
105+
respond_to do |format|
106+
format.html { redirect_to dashboard_path, flash: {error: "Logged in user is not set up as a 'partner'."} }
107+
format.json { render body: nil, status: :forbidden }
108+
end
109+
end
110+
111+
def partner
112+
@partner ||= current_partner
113+
end
114+
115+
def layout
116+
@layout ||= current_partner ? "partners/application" : "application"
117+
end
79118
end
80119
end

app/controllers/requests_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def index
1212
@paginated_requests = @requests.includes(:partner).page(params[:page])
1313
@calculate_product_totals = RequestsTotalItemsService.new(requests: @requests).calculate
1414
@items = current_organization.items.alphabetized.select(:id, :name)
15-
@partners = current_organization.partners.alphabetized.select(:id, :name)
15+
@partners = current_organization.partners.alphabetized.select(:id, :name, :status)
1616
@statuses = Request.statuses.transform_keys(&:humanize)
1717
@partner_users = User.where(id: @paginated_requests.map(&:partner_user_id)).select(:id, :name, :email)
1818
@request_types = Request.request_types.transform_keys(&:humanize)

app/mailers/distribution_mailer.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def partner_mailer(current_organization, distribution, subject, distribution_cha
1111
@partner = distribution.partner
1212
@distribution = distribution
1313
@comment = distribution.comment
14-
requestee_email = distribution.request ? distribution.request.user_email : @partner.email
14+
requester_email = distribution.request ? distribution.request.requester.email : @partner.email
1515

1616
delivery_method = @distribution.delivery? ? 'delivered' : 'picked up'
1717
@default_email_text = current_organization.default_email_text
@@ -35,17 +35,17 @@ def partner_mailer(current_organization, distribution, subject, distribution_cha
3535
cc.compact!
3636
cc.uniq!
3737

38-
mail(to: requestee_email, cc: cc, subject: "#{subject} from #{current_organization.name}")
38+
mail(to: requester_email, cc: cc, subject: "#{subject} from #{current_organization.name}")
3939
end
4040

4141
def reminder_email(distribution_id)
4242
distribution = Distribution.find(distribution_id)
4343
@partner = distribution.partner
4444
@distribution = distribution
45-
requestee_email = distribution.request ? distribution.request.user_email : @partner.email
45+
requester_email = distribution.request ? distribution.request.requester.email : @partner.email
4646

4747
return if @distribution.past? || !@partner.send_reminders || @partner.deactivated?
4848

49-
mail(to: requestee_email, cc: @partner.email, subject: "#{@partner.name} Distribution Reminder")
49+
mail(to: requester_email, cc: @partner.email, subject: "#{@partner.name} Distribution Reminder")
5050
end
5151
end

app/mailers/requests_confirmation_mailer.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ def confirmation_email(request)
33
@organization = request.organization
44
@partner = request.partner
55
@request_items = fetch_items(request)
6-
requestee_email = request.user_email
7-
# If the requestee organization has opted in to receiving an email when a
8-
# request is made, CC them
6+
requester = request.requester
7+
@requester_user_name = requester.is_a?(User) ? requester.name : nil # Requester can be the partner, if no user is specified
8+
# If the organization has opted in to receiving an email when a request is made, CC them
99
cc = [@partner.email]
1010
if @organization.receive_email_on_requests
1111
cc.push(@organization.email)
1212
end
1313
cc.flatten!
1414
cc.compact!
1515
cc.uniq!
16-
mail(to: requestee_email, cc: cc, subject: "#{@organization.name} - Requests Confirmation")
16+
mail(to: requester.email, cc: cc, subject: "#{@organization.name} - Requests Confirmation")
1717
end
1818

1919
private

app/models/adjustment.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class Adjustment < ApplicationRecord
2222
include Filterable
2323
scope :at_location, ->(location_id) { where(storage_location_id: location_id) }
2424
scope :by_user, ->(user_id) { where(user_id: user_id) }
25-
scope :for_csv_export, ->(organization, *) {
26-
where(organization: organization)
27-
.includes(:storage_location, :line_items)
28-
}
2925
scope :during, ->(range) { where(adjustments: { created_at: range }) }
3026

3127
validate :storage_locations_belong_to_organization

app/models/barcode_item.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ class BarcodeItem < ApplicationRecord
4242

4343
scope :by_value, ->(value) { where(value: value) }
4444

45-
scope :for_csv_export, ->(organization, *) {
46-
where(organization: organization)
47-
.includes(:barcodeable)
48-
}
49-
5045
scope :global, -> { where(barcodeable_type: "BaseItem") }
5146

5247
# aliases of barcodeable

0 commit comments

Comments
 (0)