45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
import requests
|
|
from flask import (
|
|
g, Blueprint, render_template, abort, current_app, redirect,
|
|
redirect, request, url_for, session, flash, jsonify
|
|
)
|
|
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_achievements = Blueprint(
|
|
'achievements', __name__, url_prefix='/achievements',
|
|
template_folder='templates')
|
|
|
|
def __get_achievements():
|
|
log.debug(session)
|
|
user_id = parse_wargaming_openid_url(session['openid'])[0]
|
|
|
|
url = "https://api.worldoftanks.ru/wot/account/achievements/"
|
|
payload = {
|
|
"application_id": current_app.config['WG_APPLICATION_ID'],
|
|
"account_id": user_id
|
|
}
|
|
|
|
__ = requests.get(url, params=payload).json()
|
|
return __.get('data', {}).get(user_id)
|
|
|
|
|
|
@pages_achievements.route('/')
|
|
def index():
|
|
"""Summary statistics"""
|
|
if not g.user:
|
|
return redirect(url_for('pages_home.index'))
|
|
|
|
# TODO: total accounts
|
|
#
|
|
account_achievements = __get_achievements()
|
|
|
|
return render_template(
|
|
'pages/account/achievements.html',
|
|
account_achievements=account_achievements
|
|
)
|