Allow a hard limit on number of specific items per request#5386
Open
Allow a hard limit on number of specific items per request#5386
Conversation
embarnard
commented
Sep 13, 2025
| tabindex="-1" | ||
| data-bs-backdrop="static" | ||
| data-confirmation-target="modal"> | ||
| </div> |
Collaborator
Author
There was a problem hiding this comment.
just added a missing div in this file, rest of the changes are just spacing from auto-format
embarnard
commented
Sep 13, 2025
| data-confirmation-pre-check-path-value="<%= validate_partners_requests_path(format: :json) %>"> | ||
| <div class="card-body"> | ||
|
|
||
| <% if @errors.present? %> |
Collaborator
Author
embarnard
commented
Sep 13, 2025
| item_ids = item_requests.map(&:item_id) | ||
| if item_ids.uniq.length != item_ids.length | ||
| errors.add(:item_requests, "should have unique item_ids") | ||
| errors.add(:base, "Please ensure a single unit is selected for each item that supports it") |
Collaborator
Author
There was a problem hiding this comment.
changed to :base since we are printing from the error.full_messages now so that it won't include the ugly and confusing item_requests before the error message
embarnard
commented
Sep 13, 2025
| .joins(profile: :counties) | ||
| .group(:id) | ||
| .pluck(Arel.sql("partners.id, STRING_AGG(counties.name, '; ' ORDER BY counties.region, counties.name) AS county_list")) | ||
| .pluck(Arel.sql("partners.id, STRING_AGG(counties.name, '; ' ORDER BY LOWER(counties.region), LOWER(counties.name)) AS county_list")) |
Collaborator
Author
There was a problem hiding this comment.
have no idea why this started failing in this PR but if a region or name is lower case and another is uppercase of the same letter the uppercase will take precedence in the order
embarnard
commented
Sep 13, 2025
| pre_existing_entry = items[input_item['item_id']] | ||
|
|
||
| if pre_existing_entry | ||
| if pre_existing_entry.request_unit != input_item['request_unit'] |
Collaborator
Author
There was a problem hiding this comment.
removed this because we basically add the same error in the model
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves #5269
Description
request_limittoItemUnitandunit_request_limittoItemfields to models"[Item name]: You requested [amount requested] [units if applicable], but are limited to [request limit] [units if applicable].
Type of change
How Has This Been Tested?
Screenshots
items/:id/editpage/partners/requestspageremoved this error message from

/partners/requestspage