Skip to content

Instantly share code, notes, and snippets.

@lananovikova10
Created October 19, 2021 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lananovikova10/0b6d962ced134dfd49d8188d290a6948 to your computer and use it in GitHub Desktop.
Save lananovikova10/0b6d962ced134dfd49d8188d290a6948 to your computer and use it in GitHub Desktop.
{% extends "base.html" %}
{% block content %}
<h1>{{ page_title }}</h1>
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-9">
<h3>{{ title }}</h3>
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="alert alert-warning" role="alert">
{{ messages[-1] }}<br>
</div>
{% endif %}
{% endwith %}
<br><br>
<p>
<div class="col-sm-9">
<h2>
Отправление из: {{ country_dep }} <br><br>
Прибытие в: {{ country_arr }} <br><br>
</h2>
{% if no_data_by_country %}
<p>{{ no_data_by_country }}</p>
{% else %}
<p><b>Как добраться:</b> {{ transportation }}</p>
<p><b>Нужна ли виза:</b> {{ visa }}</p>
<p><b>Нужно для въезда:</b> {{ conditions }}</p>
<p><b>Какие вакцины признаются:</b> {{ vaccine }}</p>
<p><b>Что открыто:</b> {{ open_objects }}</p>
<p><b>Ограничения:</b> {{ lockdown_restrictions }}</p>
</p>
{% endif %}
<h3><a href="{{ url_for('display') }}">на главную</a></h3>
</div>
</div>
{% endblock %}
@app.route('/process_country', methods=['GET', 'POST'])
def check_signin():
if current_user.is_authenticated:
return process_country()
else:
flash('пожалуйста, авторизируйтесь')
return redirect(url_for('login'))
def process_country():
form = CounryChoose()
if form.validate_on_submit():
form.country_dep
select_dep = request.form.get('country_dep')
select_arr = request.form.get('country_arr')
if select_dep != select_arr:
choice = UserRequest(user_id=current_user.id, country_dep = select_dep, country_arr = select_arr)
db.session.add(choice)
db.session.commit()
return redirect(url_for('country_request'))
else:
flash('одинаковые страны, попробуйте еще')
return redirect(url_for('display'))
@app.route('/country_request')
@login_required
def country_request():
title = f'Актуальная информация по странам'
que = UserRequest.query.filter(UserRequest.user_id==current_user.id).order_by(UserRequest.id.desc()).limit(1)
dep = que[0].country_dep
arr = que[0].country_arr
restrictions_by_country = get_info_rosturizm(arr)
if restrictions_by_country == {}:
no_data_by_country = "Сюда пока нельзя"
log.logging.info(restrictions_by_country)
return render_template('country_request.html', page_title=title, country_dep=dep, country_arr=arr, no_data_by_country = no_data_by_country)
else:
if 'transportation' in restrictions_by_country:
transportation = restrictions_by_country['transportation']
else:
transportation = "У нас пока нет информации"
if 'visa' in restrictions_by_country:
visa = restrictions_by_country['visa']
else:
visa = "У нас пока нет информации"
if 'vaccine' in restrictions_by_country:
vaccine = restrictions_by_country['vaccine']
else:
vaccine = "У нас пока нет информации"
if 'open_objects' in restrictions_by_country:
open_objects = restrictions_by_country['open_objects']
else:
open_objects = "У нас пока нет информации"
if 'conditions' in restrictions_by_country:
conditions = restrictions_by_country['conditions']
else:
conditions = "У нас пока нет информации"
if 'restrictions' in restrictions_by_country:
lockdown_restrictions = restrictions_by_country['restrictions']
else:
lockdown_restrictions = "У нас пока нет информации"
return render_template('country_request.html', page_title=title, country_dep=dep, country_arr=arr, transportation = transportation, visa = visa, vaccine = vaccine, open_objects = open_objects, conditions = conditions, lockdown_restrictions = lockdown_restrictions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment