50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
import requests
|
|
from flask import (
|
|
g, Blueprint, render_template, abort, current_app, redirect,
|
|
redirect, request, url_for, session, flash
|
|
)
|
|
from jinja2 import TemplateNotFound
|
|
from wotstats.openid import oid
|
|
|
|
from wotstats.log import log
|
|
from wotstats.database import db
|
|
from wotstats.models import User
|
|
from wotstats.lib import parse_wargaming_openid_url
|
|
|
|
pages_dir_accounts = Blueprint('pages_dir_accounts', __name__, url_prefix='/dir', template_folder='templates')
|
|
|
|
def __get_player_personal_data():
|
|
log.debug(session)
|
|
user_id = parse_wargaming_openid_url(session['openid'])[0]
|
|
|
|
__ = requests.get(
|
|
'https://api.worldoftanks.ru/wot/account/info/?application_id={}&account_id={}'.format(
|
|
current_app.config['WG_APPLICATION_ID'], user_id
|
|
)
|
|
).json()
|
|
return __.get('data', {}).get(user_id)
|
|
|
|
|
|
@pages_dir_account.route('/')
|
|
def index():
|
|
from wotstats.tasks import hello
|
|
# from wotstats.tasks import *
|
|
|
|
hello.delay()
|
|
|
|
if not g.user:
|
|
return redirect(url_for('pages_home.index'))
|
|
|
|
account_statistics = __get_player_personal_data()
|
|
return render_template(
|
|
'pages/account/index.html',
|
|
account_statistics=account_statistics)
|
|
|
|
|
|
@pages_dir_account.route('/statistics.html')
|
|
def statistics():
|
|
if not g.user:
|
|
return redirect(url_for('pages_home.index'))
|
|
|
|
return render_template(
|
|
'pages/account/statistics.html')
|