diff --git a/maps.py b/maps.py index 8cd846c69..bfefed4cf 100644 --- a/maps.py +++ b/maps.py @@ -97,6 +97,32 @@ def _get_location_from_tags(tags: []) -> str: return None +def html_address_book_list(base_dir: str, nickname: str, domain: str) -> str: + """Creates a list of potential addresses when creating a new post + with a location + """ + list_str = '\n' + address_book_filename = \ + acct_dir(base_dir, nickname, domain) + '/addresses.json' + address_book_dict = {} + if os.path.isfile(address_book_filename): + address_book_dict2 = load_json(address_book_filename) + if address_book_dict2: + address_book_dict = address_book_dict2 + + addresses_list = [] + for _, address in address_book_dict.items(): + addresses_list.append(address) + addresses_list.sort() + if addresses_list: + for addr in addresses_list: + if not addr: + continue + list_str += '\n' + list_str += '\n' + return list_str + + def update_address_book(base_dir: str, nickname: str, domain: str, location: str, address: str) -> None: """Adds an address to the address book for the given account diff --git a/webapp_create_post.py b/webapp_create_post.py index f4c58f7b3..77e8bb182 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -44,6 +44,7 @@ from webapp_utils import edit_text_field from webapp_utils import edit_number_field from webapp_utils import edit_currency_field from webapp_post import individual_post_as_html +from maps import html_address_book_list from maps import get_map_preferences_url from maps import get_map_preferences_coords from maps import get_location_from_post @@ -1079,9 +1080,16 @@ def html_new_post(edit_post_params: {}, edit_text_field(location_label_with_link, 'location', default_location, 'https://www.openstreetmap.org/#map=') + '

\n' - address_str = translate['Address'] - date_and_location += '

\n' + \ - edit_text_field(address_str, 'locationAddress', '', '') + '

\n' + + date_and_location += \ + '

\n' + date_and_location += \ + '\n' + date_and_location += \ + html_address_book_list(base_dir, nickname, domain) + date_and_location += end_edit_section() instance_title = get_config_param(base_dir, 'instanceTitle')