mirror of https://gitlab.com/bashrc2/epicyon
Save addresses to address book
parent
3f85198737
commit
f83a6825b1
26
maps.py
26
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 = '<datalist id="addressbook">\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 += '<option>' + addr + '</option>\n'
|
||||
list_str += '</datalist>\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
|
||||
|
|
|
@ -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=') + '</p>\n'
|
||||
address_str = translate['Address']
|
||||
date_and_location += '<p>\n' + \
|
||||
edit_text_field(address_str, 'locationAddress', '', '') + '</p>\n'
|
||||
|
||||
date_and_location += \
|
||||
'<br><label class="labels">' + translate['Address'] + ':' + \
|
||||
'</label><br>\n'
|
||||
date_and_location += \
|
||||
'<input type="text" name="locationAddress" ' + \
|
||||
'list="addressbook">\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')
|
||||
|
|
Loading…
Reference in New Issue