Skip to content

Commit

Permalink
Fix routing issue in location qualification (data-for-change#2542)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaked-hayek committed Jan 9, 2024
1 parent 71ddd9e commit 91e8171
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 9 additions & 8 deletions anyway/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,21 @@ def datetime_to_str(val: datetime.datetime) -> str:
)


@api.route("/api/news-flash/<int:news_flash_id>")
class RetrieveSingleNewsFlash(Resource):
@api.route("/api/news-flash/<int:news_flash_id>", methods=["GET", "PATCH"])
class ManageSingleNewsFlash(Resource):
@api.doc("get single news flash")
@api.response(404, "News flash not found")
@api.response(200, "Retrieve single news-flash item", news_flash_fields_model)
def get(self, news_flash_id):
return single_news_flash(news_flash_id)

@api.doc("update single news flash")
@api.response(400, "News flash new location is bad")
@api.response(404, "News flash not found")
@api.response(200, "Retrieve single news-flash item", news_flash_fields_model)
def patch(self, news_flash_id):
return update_news_flash_qualifying(news_flash_id)


@api.route("/api/news-flash-new", methods=["GET"])
class RetrieveNewsFlash(Resource):
Expand Down Expand Up @@ -1492,12 +1499,6 @@ def get(self):
return City.get_all_cities()


@api.route("/api/news-flash/<int:id>", methods=["PUT"])
class SetNewsflashLocationQualification(Resource):
def put(self, id):
return update_news_flash_qualifying(id)


download_data_parser = reqparse.RequestParser()
download_data_parser.add_argument("format", type=str, default="csv",
help="Format for downloaded data (.csv/.xlsx)")
Expand Down
4 changes: 3 additions & 1 deletion anyway/views/news_flash/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ def update_news_flash_qualifying(id):
return return_json_error(Es.BR_BAD_FIELD)
news_flash_obj = db.session.query(NewsFlash).filter(NewsFlash.id == id).first()
old_location, old_location_qualifiction = extracted_location_and_qualification(news_flash_obj)
if news_flash_obj is not None:
if news_flash_obj is None:
return Response(status=404)
else:
if manual_update:
if use_road_segment:
news_flash_obj.road_segment_name = road_segment_name
Expand Down

0 comments on commit 91e8171

Please sign in to comment.