forked from bcgov/lear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21985 Review Endpoint Creation (bcgov#2822)
* 21985 review endpoint creation * fix: added missing json for review result * review result logic fixes * changed auth to only staff access * updated reviews to admin folder * review endpoint pre unit test addition * lint fix * review fixes for filing link and reviewer in model * removed unit test for reviews for next PR * removed if statement
- Loading branch information
1 parent
b33b3df
commit 2c4290a
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,43 @@ | ||
# Copyright © 2024 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""API endpoints for retrieving review data.""" | ||
from http import HTTPStatus | ||
|
||
from flask import current_app, jsonify | ||
from flask_cors import cross_origin | ||
|
||
from legal_api.models import Filing, Review, UserRoles | ||
from legal_api.utils.auth import jwt | ||
|
||
from .bp import bp_admin | ||
|
||
|
||
@bp_admin.route('/reviews/<int:review_id>', methods=['GET', 'OPTIONS']) | ||
@cross_origin(origin='*') | ||
@jwt.has_one_of_roles([UserRoles.staff]) | ||
def get_review(review_id: int): | ||
"""Return specific review.""" | ||
review = Review.find_by_id(review_id) | ||
|
||
if not review: | ||
return jsonify({'message': 'Review not found.'}), HTTPStatus.NOT_FOUND | ||
result = review.json | ||
|
||
filing = Filing.find_by_id(review.filing_id) | ||
base_url = current_app.config.get('LEGAL_API_BASE_URL') | ||
filing_link = f'{base_url}/{filing.temp_reg}/filings/{filing.id}' | ||
|
||
result['filingLink'] = filing_link | ||
|
||
return jsonify(result), HTTPStatus.OK |