Skip to content

Commit

Permalink
add None values when resolution fields not relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
atalyaalon committed May 30, 2024
1 parent caf46e7 commit 12e98c2
Showing 1 changed file with 15 additions and 1 deletion.
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 @@ -378,12 +379,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

0 comments on commit 12e98c2

Please sign in to comment.