Setting time zone within profile

merge-requests/30/head
Bob Mottram 2022-02-25 19:57:31 +00:00
parent 49884ca2d6
commit bacf8dece4
20 changed files with 75 additions and 19 deletions

View File

@ -247,6 +247,8 @@ from languages import set_actor_languages
from languages import get_understood_languages
from like import update_likes_collection
from reaction import update_reaction_collection
from utils import get_account_timezone
from utils import set_account_timezone
from utils import load_account_timezones
from utils import local_network_host
from utils import undo_reaction_collection_entry
@ -5625,6 +5627,24 @@ class PubServer(BaseHTTPRequestHandler):
set_actor_languages(base_dir, actor_json, '')
actor_changed = True
# change time zone
timezone = \
get_account_timezone(base_dir, nickname, domain)
if fields.get('timeZone'):
if fields['timeZone'] != timezone:
set_account_timezone(base_dir,
nickname, domain,
fields['timeZone'])
self.server.account_timezone[nickname] = \
fields['timeZone']
actor_changed = True
else:
if timezone:
set_account_timezone(base_dir,
nickname, domain, '')
del self.server.account_timezone[nickname]
actor_changed = True
# change tox address
current_tox_address = get_tox_address(actor_json)
if fields.get('toxAddress'):

View File

@ -510,5 +510,6 @@
"Multi Status": "متعدد الحالات",
"Lots of things": "أشياء كثيرة",
"Created": "مخلوق",
"It is done": "تم"
"It is done": "تم",
"Time Zone": "وحدة زمنية"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Estat múltiple",
"Lots of things": "Moltes coses",
"Created": "Creat",
"It is done": "Esta fet"
"It is done": "Esta fet",
"Time Zone": "Fus horari"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Statws Aml",
"Lots of things": "Llawer o pethau",
"Created": "Wedi creu",
"It is done": "Mae'n cael ei wneud"
"It is done": "Mae'n cael ei wneud",
"Time Zone": "Parth Amser"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Multi-Status",
"Lots of things": "Viele Dinge",
"Created": "Erstellt",
"It is done": "Es ist vollbracht"
"It is done": "Es ist vollbracht",
"Time Zone": "Zeitzone"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Multi Status",
"Lots of things": "Lots of things",
"Created": "Created",
"It is done": "It is done"
"It is done": "It is done",
"Time Zone": "Time Zone"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Estado múltiple",
"Lots of things": "Muchas cosas",
"Created": "Creada",
"It is done": "Se hace"
"It is done": "Se hace",
"Time Zone": "Zona horaria"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Statut multiple",
"Lots of things": "Beaucoup de choses",
"Created": "Créé",
"It is done": "C'est fait"
"It is done": "C'est fait",
"Time Zone": "Fuseau horaire"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Stádas Il",
"Lots of things": "A lán rudaí",
"Created": "Cruthaithe",
"It is done": "Déantar é"
"It is done": "Déantar é",
"Time Zone": "Crios Ama"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "बहु स्थिति",
"Lots of things": "बहुत सी बातें",
"Created": "बनाया था",
"It is done": "हो गया है"
"It is done": "हो गया है",
"Time Zone": "समय क्षेत्र"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Stato multiplo",
"Lots of things": "Un sacco di cose",
"Created": "Creata",
"It is done": "È fatta"
"It is done": "È fatta",
"Time Zone": "Fuso orario"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "マルチステータス",
"Lots of things": "多くの物",
"Created": "作成した",
"It is done": "されております"
"It is done": "されております",
"Time Zone": "タイムゾーン"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Multi Status",
"Lots of things": "Gelek tişt",
"Created": "Afirandin",
"It is done": "Tê kirin"
"It is done": "Tê kirin",
"Time Zone": "Qada demê"
}

View File

@ -506,5 +506,6 @@
"Multi Status": "Multi Status",
"Lots of things": "Lots of things",
"Created": "Created",
"It is done": "It is done"
"It is done": "It is done",
"Time Zone": "Time Zone"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Vários status",
"Lots of things": "Muitas coisas",
"Created": "Criada",
"It is done": "Está feito"
"It is done": "Está feito",
"Time Zone": "Fuso horário"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Мульти статус",
"Lots of things": "Много всего",
"Created": "Созданный",
"It is done": "Сделано"
"It is done": "Сделано",
"Time Zone": "Часовой пояс"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "Hali nyingi",
"Lots of things": "Mambo mengi",
"Created": "Imeundwa",
"It is done": "Imefanyika"
"It is done": "Imefanyika",
"Time Zone": "Eneo la Saa"
}

View File

@ -510,5 +510,6 @@
"Multi Status": "多状态",
"Lots of things": "很多事情",
"Created": "已创建",
"It is done": "完成了"
"It is done": "完成了",
"Time Zone": "时区"
}

View File

@ -3402,3 +3402,14 @@ def get_account_timezone(base_dir: str, nickname: str, domain: str) -> str:
with open(tz_filename, 'r') as fp_timezone:
timezone = fp_timezone.read().strip()
return timezone
def set_account_timezone(base_dir: str, nickname: str, domain: str,
timezone: str) -> None:
"""Sets the timezone for the given account
"""
tz_filename = \
base_dir + '/accounts/' + nickname + '@' + domain + '/timezone.txt'
timezone = timezone.strip()
with open(tz_filename, 'w+') as fp_timezone:
fp_timezone.write(timezone)

View File

@ -29,6 +29,7 @@ from utils import acct_dir
from utils import get_supported_languages
from utils import local_actor_url
from utils import get_reply_interval_hours
from utils import get_account_timezone
from languages import get_actor_languages
from skills import get_skills
from theme import get_themes_list
@ -2021,7 +2022,8 @@ def _get_supported_languagesSorted(base_dir: str) -> str:
def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
moved_to: str, donate_url: str, website_url: str,
blog_address: str, actor_json: {},
translate: {}) -> str:
translate: {},
nickname: str, domain: str) -> str:
"""main info on edit profile screen
"""
image_formats = get_image_formats()
@ -2084,6 +2086,11 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
edit_text_field(translate['Languages'], 'showLanguages',
show_languages, languages_list_str)
timezone = get_account_timezone(base_dir, nickname, domain)
edit_profile_form += \
edit_text_field(translate['Time Zone'], 'timeZone',
timezone, 'Europe/London')
edit_profile_form += ' </div>\n'
return edit_profile_form
@ -2302,7 +2309,8 @@ def html_edit_profile(css_cache: {}, translate: {}, base_dir: str, path: str,
edit_profile_form += \
_html_edit_profile_main(base_dir, display_nickname, bio_str,
moved_to, donate_url, website_url,
blog_address, actor_json, translate)
blog_address, actor_json, translate,
nickname, domain)
# Option checkboxes
edit_profile_form += \