To recreate: -Set MaxOpenSuggestions to something low, like 1. -Make some suggestions via the API, making sure they are not anonymous and they include a status of 'ASKED'. -You can make as many requests as you want, regardless of MaxOpenSuggestions. I am using this simple jQuery snippet to test: $.ajax({ type: 'POST', url: '/api/v1/suggestions/', data: '{"collection_title": "dasdas", "suggested_by": 5}', success: function(data) { console.log('suggestion added'); }, contentType: "application/json", dataType: 'json' });
Created attachment 134541 [details] [review] Bug 30663: Add Koha::Suggestions helper methods This patch adds the following helper methods: * filter_by_pending * filter_by_suggested_days_range This methods follow basically what's done in opac-suggestions.pl I chose 'pending' as opposed to 'open' to follow what we use in the UI which might be the case because of being more accurate for end users. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Suggestions.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 134542 [details] [review] Bug 30663: Add x-koha-override options to /suggestions This patch adds the x-koha-override header parameter to the route that is used to create suggestions, POST /suggestions. The idea is that adding suggestions will be rejected under certain conditions unless x-koha-override is passed with appropriate values. The added overrides are: * any * max_total * max_pending Tests are added for the expected behavior. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 134543 [details] [review] Bug 30663: Implement overrides handling in POST /suggestions This patch implements the override checks in the controller as expected by the previous patch. To test: 1. Apply this bug patches up to 'Add x-koha-override options...' 2. Run: $ kshell k$ prove t/db_dependent/api/v1/suggestions.t => FAIL: Tests fail! The controller doesn't care about overrides or sysprefs about suggestions limits. 3. Apply this patch 4. Repeat 2 => SUCCESS: Things work! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 134544 [details] [review] Bug 30663: Add Koha::Suggestions helper methods This patch adds the following helper methods: * filter_by_pending * filter_by_suggested_days_range This methods follow basically what's done in opac-suggestions.pl I chose 'pending' as opposed to 'open' to follow what we use in the UI which might be the case because of being more accurate for end users. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Suggestions.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 134545 [details] [review] Bug 30663: Add x-koha-override options to /suggestions This patch adds the x-koha-override header parameter to the route that is used to create suggestions, POST /suggestions. The idea is that adding suggestions will be rejected under certain conditions unless x-koha-override is passed with appropriate values. The added overrides are: * any * max_total * max_pending Tests are added for the expected behavior. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 134546 [details] [review] Bug 30663: Implement overrides handling in POST /suggestions This patch implements the override checks in the controller as expected by the previous patch. To test: 1. Apply this bug patches up to 'Add x-koha-override options...' 2. Run: $ kshell k$ prove t/db_dependent/api/v1/suggestions.t => FAIL: Tests fail! The controller doesn't care about overrides or sysprefs about suggestions limits. 3. Apply this patch 4. Repeat 2 => SUCCESS: Things work! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 134604 [details] [review] Bug 30663: Add Koha::Suggestions helper methods This patch adds the following helper methods: * filter_by_pending * filter_by_suggested_days_range This methods follow basically what's done in opac-suggestions.pl I chose 'pending' as opposed to 'open' to follow what we use in the UI which might be the case because of being more accurate for end users. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Suggestions.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 134605 [details] [review] Bug 30663: Add x-koha-override options to /suggestions This patch adds the x-koha-override header parameter to the route that is used to create suggestions, POST /suggestions. The idea is that adding suggestions will be rejected under certain conditions unless x-koha-override is passed with appropriate values. The added overrides are: * any * max_total * max_pending Tests are added for the expected behavior. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 134606 [details] [review] Bug 30663: Implement overrides handling in POST /suggestions This patch implements the override checks in the controller as expected by the previous patch. To test: 1. Apply this bug patches up to 'Add x-koha-override options...' 2. Run: $ kshell k$ prove t/db_dependent/api/v1/suggestions.t => FAIL: Tests fail! The controller doesn't care about overrides or sysprefs about suggestions limits. 3. Apply this patch 4. Repeat 2 => SUCCESS: Things work! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Great work.. as a follow-up bug I'd love to see us move these checks and override into the Object classes.. but given this is a bug and there's already work underway in those classes I think this is an acceptable middle ground. Passing QA
Pushed for 22.05. Thanks everyone.
It would be very helpful if this could be backported to 21.11, thanks!
Doesn't apply to 21.11.x, please rebase if needed!
Created attachment 134987 [details] [review] [21.11.x] Bug 30663: Add x-koha-override options to /suggestions This patch adds the x-koha-override header parameter to the route that is used to create suggestions, POST /suggestions. The idea is that adding suggestions will be rejected under certain conditions unless x-koha-override is passed with appropriate values. The added overrides are: * any * max_total * max_pending Tests are added for the expected behavior. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 134988 [details] [review] [21.11.x] Bug 30663: Implement overrides handling in POST /suggestions This patch implements the override checks in the controller as expected by the previous patch. To test: 1. Apply this bug patches up to 'Add x-koha-override options...' 2. Run: $ kshell k$ prove t/db_dependent/api/v1/suggestions.t => FAIL: Tests fail! The controller doesn't care about overrides or sysprefs about suggestions limits. 3. Apply this patch 4. Repeat 2 => SUCCESS: Things work! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Pushed to 21.11.x for 21.11.06
Backported: Pushed to 21.05.x branch for 21.05.16