Skip to content
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

add None values when resolution fields not relevant #2664

Merged
merged 5 commits into from
Oct 10, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion anyway/views/news_flash/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from anyway.parsers.resolution_fields import ResolutionFields as RF
from anyway.models import AccidentMarkerView, InvolvedView
from anyway.widgets.widget_utils import get_accidents_stats
from anyway.parsers.location_extraction import get_road_segment_name_and_number
from anyway.telegram_accident_notifications import trigger_generate_infographics_and_send_to_telegram
from io import BytesIO

Expand Down Expand Up @@ -260,12 +261,25 @@ def update_news_flash_qualifying(id):
old_location, old_location_qualifiction = extracted_location_and_qualification(news_flash_obj)
if manual_update:
if use_road_segment:
road_number, road_segment_name = get_road_segment_name_and_number(road_segment_id)
if road_number != road1:
logging.error("road number from road_segment_id does not match road1 input.")
return return_json_error(Es.BR_BAD_FIELD)
news_flash_obj.road_segment_id = road_segment_id
news_flash_obj.road1 = road1
news_flash_obj.road_segment_name = road_segment_name
news_flash_obj.road1 = road_number
news_flash_obj.road2 = None
news_flash_obj.yishuv_name = None
news_flash_obj.street1_hebrew = None
news_flash_obj.street2_hebrew = None
news_flash_obj.resolution = BE_CONST.ResolutionCategories.SUBURBAN_ROAD.value
else:
news_flash_obj.yishuv_name = yishuv_name
news_flash_obj.street1_hebrew = street1_hebrew
news_flash_obj.road_segment_id = None
news_flash_obj.road_segment_name = None
news_flash_obj.road1 = None
news_flash_obj.road2 = None
news_flash_obj.resolution = BE_CONST.ResolutionCategories.STREET.value
else:
if ((news_flash_obj.road_segment_id is None) or (news_flash_obj.road1 is None)) and (
Expand Down
Loading