From 917e5010f08d354ffb23266f4e32b1795f887c4e Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Thu, 14 Oct 2021 09:44:40 -0700 Subject: [PATCH] add timezone --- data_gateway.py | 3 --- web/app.py | 34 ++++++++++++++++++---------------- web/config-SAMPLE.py | 3 +++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/data_gateway.py b/data_gateway.py index aef4a4e..9086701 100644 --- a/data_gateway.py +++ b/data_gateway.py @@ -119,10 +119,7 @@ def download_aprs_settings(_CONFIG): set_dict = {} req = requests.post(user_man_url, data=json_object, headers={'Content-Type': 'application/json'}) resp = json.loads(req.text) -## raw_json = resp['aprs_settings'] - print(type(resp)) for i in resp['aprs_settings'].items(): - print(i) set_dict[int(i[0])] = i[1] return set_dict # For exception, write blank dict diff --git a/web/app.py b/web/app.py index d460fa5..ca84da9 100644 --- a/web/app.py +++ b/web/app.py @@ -41,6 +41,8 @@ from flask_mail import Message, Mail from socket import gethostbyname import re import folium +##from pytz import timezone +from datetime import timedelta from gen_script_template import gen_script @@ -856,7 +858,7 @@ def hbnet_web_service(): """+ str(i.callsign) +""" - """+ str(i.time.strftime(time_format)) +""" + """+ str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) +""" @@ -1398,7 +1400,7 @@ def hbnet_web_service():  

  - ''' + confirm_link + ''' 

Email confirmed: ''' + str(u.email_confirmed_at.strftime(time_format)) + '''

+ ''' + confirm_link + ''' 

Email confirmed: ''' + str((u.email_confirmed_at + timedelta(hours=hbnet_tz)).strftime(time_format)) + '''

  @@ -2502,8 +2504,8 @@ TG #: ''' + str(tg_d.tg) + ''' To: """ + i.rcv_callsign + ' (' + str(i.rcv_id) + ') - From: ' + i.snd_callsign + """ (""" + str(i.snd_id) + """ """ + url + """/sms - """ + i.message + """ - """ + str(i.time.strftime(time_format)) + """ - """ + i.time.strftime('%a, %d %b %y') +""" + """ + i.message + """ - """ + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + """ + """ + (i.time + timedelta(hours=hbnet_tz)).strftime('%a, %d %b %y') +""" """ @@ -2540,8 +2542,8 @@ TG #: ''' + str(tg_d.tg) + ''' """ + i.callsign + ' - ' + str(i.dmr_id) + """ """ + url + """/bb - """ + i.bulletin + """ - """ + str(i.time.strftime(time_format)) + """ - """ + i.time.strftime('%a, %d %b %y') +""" + """ + i.bulletin + """ - """ + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + """ + """ + (i.time + timedelta(hours=hbnet_tz)).strftime('%a, %d %b %y') +""" """ @@ -2557,7 +2559,7 @@ TG #: ''' + str(tg_d.tg) + '''

''' + i.callsign + '''

\n ''' + i.bulletin + ''' - ''' + str(i.time.strftime(time_format)) + ''' + ''' + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + ''' ''' + i.server + ' - ' + i.system_name + ''' ''' @@ -2625,7 +2627,7 @@ TG #: ''' + str(tg_d.tg) + '''
''' + i.poster + '''
''' + i.text + '''
- +
@@ -2711,10 +2713,10 @@ TG #: ''' + str(tg_d.tg) + ''' for i in ss_all: ss_content = ss_content + """ - """ + str(dmr_id) + ' - ' + str(i.time.strftime(time_format)) + """ + """ + str(dmr_id) + ' - ' + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + """ """ + url + """/ss/""" + dmr_id + """ """ + str(i.message) + """ - """ + str(i.time.strftime(time_format)) + """ - """ + str(i.time.strftime('%a, %d %b %y')) + """ + """ + str((i.time + timedelta(hours=hbnet_tz)).strftime('%a, %d %b %y')) + """ """ @@ -2729,7 +2731,7 @@ TG #: ''' + str(tg_d.tg) + ''' content = '''
-

''' + ssd.callsign + ' - ' + str(ssd.dmr_id) + '''

\n

''' + str(ssd.time.strftime(time_format)) + '''

+

''' + ssd.callsign + ' - ' + str(ssd.dmr_id) + '''

\n

''' + str((ssd.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + '''




''' + ssd.message + '''




@@ -2738,7 +2740,7 @@ TG #: ''' + str(tg_d.tg) + ''' post_content = post_content + ''' ''' + i.message + ''' - ''' + str(i.time.strftime(time_format)) + ''' + ''' + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + ''' ''' except: content = '

No posts by user.

' @@ -2781,7 +2783,7 @@ TG #: ''' + str(tg_d.tg) + ''' To: ''' + i.snd_callsign + ''' - ''' + str(i.snd_id) + '''
From: ''' + i.rcv_callsign + ''' - ''' + str(i.rcv_id) + ''' ''' + i.message + ''' - ''' + str(i.time.strftime(time_format)) + ''' + ''' + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + ''' ''' return render_template('all_mail.html', markup_content = Markup(content), show_mail = show_mailbox) @@ -2826,7 +2828,7 @@ TG #: ''' + str(tg_d.tg) + ''' ''' + i.snd_callsign + ''' - ''' + str(i.snd_id) + ''' ''' + i.message + ''' - ''' + str(i.time.strftime(time_format)) + ''' + ''' + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + ''' ''' else: @@ -6679,7 +6681,7 @@ Name: ''' + p.name + '''  -  Port: ''' + str(  ''' + i.lat + '''   ''' + i.lon + '''  -  ''' + str(i.time.strftime(time_format)) + '''  +  ''' + str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + '''  ''' ## content = dev_loc @@ -6773,7 +6775,7 @@ Name: ''' + p.name + '''  -  Port: ''' + str( burn_list=get_burnlist() ) elif 'aprs_settings' in hblink_req: # ['burn_list']: # == 'burn_list': - print(get_aprs_settings()) +## print(get_aprs_settings()) response = jsonify( aprs_settings=get_aprs_settings() ) diff --git a/web/config-SAMPLE.py b/web/config-SAMPLE.py index 59e4807..e10c53b 100644 --- a/web/config-SAMPLE.py +++ b/web/config-SAMPLE.py @@ -24,6 +24,9 @@ url = 'http://localhost:8080' # Replace below with some random string such as an SHA256 secret_key = 'SUPER SECRET LONG KEY' +# Timezone to show time stamps in. Stored in DB as UTC. Offset in hours. +hbnet_tz = -1 + # Default state for newly created user accounts. Setting to False will require # the approval of an admin user before the user can login. default_account_state = True