Skip to content

Commit

Permalink
Merge pull request #543 from CityOfNewYork/johnyu95-agency-read-only
Browse files Browse the repository at this point in the history
Agency Read Only Bug Fixes
  • Loading branch information
zgary authored Oct 26, 2021
2 parents 77389a3 + ab75a1f commit 96797ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/request/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ def get_request_responses():

current_request = Requests.query.filter_by(id=flask_request.args['request_id']).one()

if current_user in current_request.agency_users or current_user.is_agency_read_only(current_request.agency.ein):
if current_user.is_agency and \
(current_user in current_request.agency_users or
current_user.is_agency_read_only(current_request.agency.ein)):
# If the user is an agency user assigned to the request, all responses can be retrieved.
responses = Responses.query.filter(
Responses.request_id == current_request.id,
Expand Down
3 changes: 2 additions & 1 deletion app/response/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ def get_response_content(response_id):
400 error if response/file not found
"""
response_ = Responses.query.filter_by(id=response_id, deleted=False).one()
request = Requests.query.filter_by(id=response_.request_id).one()

if response_ is not None and response_.type == FILE:
upload_path = os.path.join(
Expand Down Expand Up @@ -751,7 +752,7 @@ def remove(resp):
and UserRequests.query.filter_by(
request_id=response_.request_id,
user_guid=current_user.guid
).first() is not None):
).first() is not None or current_user.is_agency_read_only(request.agency_ein)):
@after_this_request
def remove(resp):
os.remove(serving_path)
Expand Down

0 comments on commit 96797ab

Please sign in to comment.