-
Notifications
You must be signed in to change notification settings - Fork 11
B 39900 #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mrenvoize
wants to merge
5
commits into
main
Choose a base branch
from
b_39900
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
B 39900 #137
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
668663e
Bug 39900: Preparation: Refactor public_query_search_params for reusa…
ammopt dbd66e2
Bug 39900: Preparation: Move html customizations options to class for…
ammopt a9d6c8a
Bug 39900: REST API specs and class changes
ammopt 80136a0
Bug 39900: Add translated_contents embed
ammopt 9bd1082
Bug 39900: Add tests
ammopt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,43 @@ sub translated_content { | |
| return $content; | ||
| } | ||
|
|
||
| =head3 public_read_list | ||
|
|
||
| This method returns the list of publicly readable database fields for both API and UI output purposes | ||
|
|
||
| =cut | ||
|
|
||
| sub public_read_list { | ||
| return [ | ||
| 'id', 'category', 'code', | ||
| 'location', 'branchcode', 'published_on', | ||
| 'updated_on', 'expirationdate', 'number', | ||
| 'borrowernumber' | ||
| ]; | ||
| } | ||
|
|
||
| =head3 to_api_mapping | ||
|
|
||
| This method returns the mapping for representing a Koha::AdditionalContent object | ||
| on the API. | ||
|
|
||
| =cut | ||
|
|
||
| sub to_api_mapping { | ||
| return { | ||
| id => 'additional_content_id', | ||
| category => 'category', | ||
| code => 'code', | ||
| location => 'location', | ||
| branchcode => 'library_id', | ||
| published_on => 'published_on', | ||
| updated_on => 'updated_on', | ||
| expirationdate => 'expirationdate', | ||
| number => 'number', | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| borrowernumber => 'patron_id', | ||
| }; | ||
| } | ||
|
|
||
| =head3 _type | ||
|
|
||
| =cut | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package Koha::REST::V1::AdditionalContents; | ||
|
|
||
| # This file is part of Koha. | ||
| # | ||
| # Koha is free software; you can redistribute it and/or modify it | ||
| # under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Koha is distributed in the hope that it will be useful, but | ||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with Koha; if not, see <http://www.gnu.org/licenses>. | ||
|
|
||
| use Modern::Perl; | ||
|
|
||
| use Mojo::Base 'Mojolicious::Controller'; | ||
|
|
||
| use Koha::AdditionalContents; | ||
|
|
||
| use Try::Tiny qw( catch try ); | ||
|
|
||
| =head1 API | ||
|
|
||
| =head2 Methods | ||
|
|
||
| =head3 list_public | ||
|
|
||
| Controller function that handles retrieving a list of additional contents | ||
|
|
||
| =cut | ||
|
|
||
| sub list_public { | ||
| my $c = shift->openapi->valid_input or return; | ||
|
|
||
| return try { | ||
|
|
||
| my @public_locations = ( | ||
| @{ Koha::AdditionalContents::get_html_customizations_options('opac') }, | ||
| 'staff_and_opac', | ||
| 'opac_only' | ||
| ); | ||
|
|
||
| my $public_additional_contents_query = | ||
| Koha::AdditionalContents::get_public_query_search_params( { location => { '-in' => \@public_locations } } ); | ||
|
|
||
| my $additional_contents = | ||
| $c->objects->search( Koha::AdditionalContents->search($public_additional_contents_query) ); | ||
|
|
||
| return $c->render( status => 200, openapi => $additional_contents ); | ||
| } catch { | ||
| $c->unhandled_exception($_); | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| 1; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| --- | ||
| additionalProperties: false | ||
| properties: | ||
| additional_content_id: | ||
| description: Internal identifier for the additional content | ||
| type: integer | ||
| category: | ||
| description: Category of the additional content | ||
| type: string | ||
| code: | ||
| description: Code of the additional content | ||
| type: string | ||
| location: | ||
| description: Location of the additional content | ||
| type: string | ||
| library_id: | ||
| description: Library id of the additional content | ||
| type: | ||
| - string | ||
| - "null" | ||
| published_on: | ||
| description: Publication date of the additional content | ||
| type: string | ||
| updated_on: | ||
| description: Last modification date of the additional content | ||
| type: string | ||
| expirationdate: | ||
| description: Expiration date of the additional content | ||
| type: string | ||
| number: | ||
| description: The order in which this additional content appears in that specific location | ||
| type: integer | ||
| patron_id: | ||
| description: The author of the additional content | ||
| type: | ||
| - string | ||
| - "null" | ||
| translated_contents: | ||
| description: Related additional contents translations | ||
| type: | ||
| - array | ||
| - "null" | ||
| required: | ||
| - additional_content_id | ||
| - category | ||
| - code | ||
| - location | ||
| type: object |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| "/public/additional_contents": | ||
| get: | ||
| x-mojo-to: AdditionalContents#list_public | ||
| operationId: listAdditionalContents | ||
| parameters: | ||
| - description: Case insensitive search on additional_contents id | ||
| in: query | ||
| name: additional_content_id | ||
| required: false | ||
| type: string | ||
| - description: Case insensitive search on additional_contents category | ||
| in: query | ||
| name: category | ||
| required: false | ||
| type: string | ||
| - description: Case insensitive search on additional_contents code | ||
| in: query | ||
| name: code | ||
| required: false | ||
| type: string | ||
| - description: Case insensitive search on additional_contents location | ||
| in: query | ||
| name: location | ||
| required: false | ||
| type: string | ||
| - description: Case insensitive search on additional_contents library_id | ||
| in: query | ||
| name: library_id | ||
| required: false | ||
| type: string | ||
| - $ref: "../swagger.yaml#/parameters/match" | ||
| - $ref: "../swagger.yaml#/parameters/order_by" | ||
| - $ref: "../swagger.yaml#/parameters/page" | ||
| - $ref: "../swagger.yaml#/parameters/per_page" | ||
| - $ref: "../swagger.yaml#/parameters/q_param" | ||
| - $ref: "../swagger.yaml#/parameters/q_body" | ||
| - name: x-koha-embed | ||
| in: header | ||
| required: false | ||
| description: Embed list sent as a request header | ||
| type: array | ||
| items: | ||
| type: string | ||
| enum: | ||
| - translated_contents | ||
| collectionFormat: csv | ||
| produces: | ||
| - application/json | ||
| responses: | ||
| 200: | ||
| description: A list of additional contents | ||
| schema: | ||
| items: | ||
| $ref: ../swagger.yaml#/definitions/additional_content | ||
| type: array | ||
| 400: | ||
| description: | | ||
| Bad request. Possible `error_code` attribute values: | ||
|
|
||
| * `invalid_query` | ||
| schema: | ||
| $ref: "../swagger.yaml#/definitions/error" | ||
| 403: | ||
| description: Access forbidden | ||
| schema: | ||
| $ref: ../swagger.yaml#/definitions/error | ||
| 500: | ||
| description: Internal error | ||
| schema: | ||
| $ref: ../swagger.yaml#/definitions/error | ||
| 503: | ||
| description: Under maintenance | ||
| schema: | ||
| $ref: ../swagger.yaml#/definitions/error | ||
| summary: List public additional contents | ||
| tags: | ||
| - additional_contents |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a mix of
expiry_dateandexpiration_datein the API to date.. I think I'm leaning towards the latter as it's just about got more occurrences.