From 6db712b31b723f803e4d4d71a95b527bc4137bb5 Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 31 Oct 2022 22:42:19 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0,=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BD=D0=B8=D0=BA=D0=B0=D1=8E=D1=89=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D0=BB=20=D0=B0=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D1=81=D0=B0=20=D0=B8=20=D1=85=D0=BE=D1=82=D0=B5=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D1=82=D1=80=D0=BE=D0=B8=D1=82=D1=8C=20=D0=BC?= =?UTF-8?q?=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/main.py b/main.py index aae6b04..13e5f5b 100644 --- a/main.py +++ b/main.py @@ -315,25 +315,29 @@ def safe_app_school_go(point): if current_user.is_authenticated: data_session = db_session.create_session() address = data_session.query(UserPoint).filter(UserPoint.user == current_user.id).first() - if address.school_address and address.home_address: - with open('static/js/safe_app_school/mapbasics_templates.js', 'r', encoding='utf-8') as file: - new_file = file.read().split('') - new_file = new_file[0] + f'\'{address.home_address if point == "home" else address.school_address}\'' \ - + new_file[1] - new_file = new_file.split('') - new_file = new_file[ - 0] + f'\'{address.school_address if point == "home" else address.home_address}\'' + \ - new_file[1] - with open('static/js/safe_app_school/mapbasics.js', 'w', encoding='utf-8') as new_js: - new_js.write(new_file) - t = Timer(1, remove_java, args=None, kwargs=None) - t.start() - if point == 'home': - return render_template('safe_app_school/route.html', title='Маршрут домой', route='домой') - elif point == 'school': - return render_template('safe_app_school/route.html', title='Маршрут в школу', route='в школу') + if address: + if address.school_address and address.home_address: + with open('static/js/safe_app_school/mapbasics_templates.js', 'r', encoding='utf-8') as file: + new_file = file.read().split('') + new_file = new_file[ + 0] + f'\'{address.home_address if point == "home" else address.school_address}\'' \ + + new_file[1] + new_file = new_file.split('') + new_file = new_file[ + 0] + f'\'{address.school_address if point == "home" else address.home_address}\'' + \ + new_file[1] + with open('static/js/safe_app_school/mapbasics.js', 'w', encoding='utf-8') as new_js: + new_js.write(new_file) + t = Timer(1, remove_java, args=None, kwargs=None) + t.start() + if point == 'home': + return render_template('safe_app_school/route.html', title='Маршрут домой', route='домой') + elif point == 'school': + return render_template('safe_app_school/route.html', title='Маршрут в школу', route='в школу') + else: + return redirect('/safe_app_school/main') else: - return redirect('/safe_app_school/main') + return render_template('safe_app_school/route.html', title='Маршрут не указан', route=False) else: return render_template('safe_app_school/route.html', title='Маршрут не указан', route=False) else: