diff --git a/anyway/request_params.py b/anyway/request_params.py index d0abc456..80c23ecc 100644 --- a/anyway/request_params.py +++ b/anyway/request_params.py @@ -96,7 +96,7 @@ def get_request_params_from_request_values(vals: dict) -> Optional[RequestParams years_ago = vals.get("years_ago", BE_CONST.DEFAULT_NUMBER_OF_YEARS_AGO) lang = vals.get("lang", "he") location_text = location["text"] - gps = location["gps"] + gps = location.get("gps", {}) location_info = location["data"] if location_info is None: @@ -223,9 +223,7 @@ def extract_road_segment_location(road_segment_id): data["road_segment_name"] = road_segment_name data["road_segment_id"] = int(road_segment_id) text = get_road_segment_location_text(road1, road_segment_name) - # fake gps - todo: fix - gps = {"lat": 32.825610, "lon": 35.165395} - return {"name": "location", "data": data, "gps": gps, "text": text} + return {"name": "location", "data": data, "text": text} # todo: fill both codes and names into location @@ -236,9 +234,7 @@ def extract_street_location(input_vals: dict): for k in ["yishuv_name", "yishuv_symbol", "street1", "street1_hebrew"]: data[k] = vals[k] text = get_street_location_text(vals["yishuv_name"], vals["street1_hebrew"]) - # fake gps - todo: fix - gps = {"lat": 32.825610, "lon": 35.165395} - return {"name": "location", "data": data, "gps": gps, "text": text} + return {"name": "location", "data": data, "text": text} def extract_street_location_suggestion_version(input_vals: dict): @@ -274,12 +270,9 @@ def extract_non_urban_intersection_location(input_vals: dict): data = {"resolution": BE_CONST.ResolutionCategories.SUBURBAN_JUNCTION} for k in ["non_urban_intersection", "non_urban_intersection_hebrew", "road1", "road2"]: data[k] = vals[k] - # fake gps - todo: fix - gps = {"lat": 32.825610, "lon": 35.165395} return { "name": "location", "data": data, - "gps": gps, "text": vals["non_urban_intersection_hebrew"], } diff --git a/anyway/widgets/road_segment_widgets/street_view_widget.py b/anyway/widgets/road_segment_widgets/street_view_widget.py index 17da2739..07d98cc9 100644 --- a/anyway/widgets/road_segment_widgets/street_view_widget.py +++ b/anyway/widgets/road_segment_widgets/street_view_widget.py @@ -16,10 +16,14 @@ def __init__(self, request_params: RequestParams): def generate_items(self) -> None: self.items = { - "longitude": self.request_params.gps["lon"], - "latitude": self.request_params.gps["lat"], + "longitude": self.request_params.gps.get("lon"), + "latitude": self.request_params.gps.get("lat"), } + def is_included(self): + return self.request_params.gps and self.request_params.gps.get("lon") and self.request_params.gps.get("lat") + + @staticmethod def localize_items(request_params: RequestParams, items: Dict) -> Dict: items["data"]["text"] = {"title": _("Street view widget")} diff --git a/tests/test_request_params.py b/tests/test_request_params.py index ec0b35a6..aa7f7a78 100644 --- a/tests/test_request_params.py +++ b/tests/test_request_params.py @@ -30,7 +30,6 @@ class TestRequestParams(unittest.TestCase): 'resolution': BE_CONST.ResolutionCategories.SUBURBAN_JUNCTION, 'road1': 669, 'road2': 71}, - 'gps': {'lat': 32.82561, 'lon': 35.165395}, 'name': 'location', 'text': 'צומת השיטה'} nf = NewsFlash() @@ -46,7 +45,7 @@ class TestRequestParams(unittest.TestCase): lang='he', news_flash_description=nf.description, news_flash_title=nf.title, - gps={"lat": 32.825610, "lon": 35.165395} + gps={} ) @patch("anyway.request_params.fill_missing_non_urban_intersection_values")