From 2688960be3f1fce2d7c3d721acb5af12a577fa08 Mon Sep 17 00:00:00 2001 From: vanzhiganov Date: Mon, 25 Dec 2017 04:09:03 +0300 Subject: [PATCH] upd --- README.md | 13 +-- wotstats/templates/pages/rush/history.html | 95 ++++++++++++++++++++++ wotstats/templates/pages/rush/index.html | 91 ++++++--------------- wotstats/views/home.py | 7 +- wotstats/views/rush.py | 10 ++- 5 files changed, 135 insertions(+), 81 deletions(-) create mode 100644 wotstats/templates/pages/rush/history.html diff --git a/README.md b/README.md index 594930e..e04adfa 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,7 @@ For Postgres installation https://developer.fedoraproject.org/tech/database/postgresql/about.html - -``` -pip install -r requirements.txt -``` + pip install -r requirements.txt ## Upgrade @@ -28,15 +25,11 @@ Upgrade database Application -``` -python run_app.py -``` + python run_app.py Celery Worker -``` -celery worker -A run_celery.celery -l info -``` + celery worker -A run_celery.celery -l info Celery Beat diff --git a/wotstats/templates/pages/rush/history.html b/wotstats/templates/pages/rush/history.html new file mode 100644 index 0000000..b376c82 --- /dev/null +++ b/wotstats/templates/pages/rush/history.html @@ -0,0 +1,95 @@ +{% extends 'layouts/main.html' %} + +{% block content %} +

Турниры

+
+
+ + + + + + + + + + + {% for r in rush_list %} + {% if r.status == "preparation" %} + + + + + + + + {% endif %} + {% endfor %} +
IDСтартФинишСтавкаСтатус
{{ r.id }}{{ r.at_start }}{{ r.at_finish }}{{ r.bet }} рублей{{ r.status }}
+
+

Участники

+ {% set allow_apply = 'true' %} + {% for u in rush_list_accounts %} + {% if u.account_id|int == account_id|int %} + {% set allow_apply = 'false' %} + {{ u.account_id }} + {% endif %} + {% endfor %} +
+ {% if allow_apply == 'true' %} + Участвовать + {% else %} +

Вы участвуете, вам необходимо совершить максимальное кол-во побед за время турнира

+ {% endif %} +
+
+

Текущий

+ + + + + + + + + + + {% for r in rush_list %} + {% if r.status == "started" %} + + + + + + + + {% endif %} + {% endfor %} +
IDСтартФинишСтавкаСтатус
{{ r.id }}{{ r.at_start }}{{ r.at_finish }}{{ r.bet }} рублей{{ r.status }}
+

Завершены

+ + + + + + + + + + + {% for r in rush_list %} + {% if r.status in ["finished", "canceled"] %} + + + + + + + + {% endif %} + {% endfor %} +
IDСтартФинишСтавкаСтатус
{{ r.id }}{{ r.at_start }}{{ r.at_finish }}{{ r.bet }} рублей{{ r.status }}
+
+
+ +{% endblock %} diff --git a/wotstats/templates/pages/rush/index.html b/wotstats/templates/pages/rush/index.html index b376c82..7c569da 100644 --- a/wotstats/templates/pages/rush/index.html +++ b/wotstats/templates/pages/rush/index.html @@ -4,70 +4,15 @@

Турниры

- - - - - - - - - - - {% for r in rush_list %} - {% if r.status == "preparation" %} - - - - - - - - {% endif %} - {% endfor %} -
IDСтартФинишСтавкаСтатус
{{ r.id }}{{ r.at_start }}{{ r.at_finish }}{{ r.bet }} рублей{{ r.status }}
-
-

Участники

- {% set allow_apply = 'true' %} - {% for u in rush_list_accounts %} - {% if u.account_id|int == account_id|int %} - {% set allow_apply = 'false' %} - {{ u.account_id }} - {% endif %} - {% endfor %} -
- {% if allow_apply == 'true' %} - Участвовать + {% if account_balance < 100 %} +
+
+

Недостаточно денег в кошельке.

+

Необходимо пополнить кошелёк для участия в турнире.

+
+
{% else %} -

Вы участвуете, вам необходимо совершить максимальное кол-во побед за время турнира

- {% endif %} -
-
-

Текущий

- - - - - - - - - - - {% for r in rush_list %} - {% if r.status == "started" %} - - - - - - - - {% endif %} - {% endfor %} -
IDСтартФинишСтавкаСтатус
{{ r.id }}{{ r.at_start }}{{ r.at_finish }}{{ r.bet }} рублей{{ r.status }}
-

Завершены

- +
@@ -78,7 +23,7 @@ {% for r in rush_list %} - {% if r.status in ["finished", "canceled"] %} + {% if r.status == "preparation" %} @@ -89,6 +34,24 @@ {% endif %} {% endfor %}
ID
{{ r.id }} {{ r.at_start }}
+
+

Участники

+ {% set allow_apply = 'true' %} + {% for u in rush_list_accounts %} + {% if u.account_id|int == account_id|int %} + {% set allow_apply = 'false' %} + {{ u.account_id }} + {% endif %} + {% endfor %} +
+ {% if allow_apply == 'true' %} + Участвовать + {% else %} +

Вы участвуете, вам необходимо совершить максимальное кол-во побед за время турнира

+ {% endif %} + + {% endif %} +
diff --git a/wotstats/views/home.py b/wotstats/views/home.py index ff66d46..f99db6a 100644 --- a/wotstats/views/home.py +++ b/wotstats/views/home.py @@ -43,9 +43,6 @@ def login(): @pages_home.route('/login', methods=['POST']) @oid.loginhandler def login_post(): - print request.form - print request.args - if g.user is not None: return redirect(oid.get_next_url()) @@ -104,8 +101,8 @@ def token(): print request.form print session - #if 'openid' not in session or 'user' in session: - # return redirect(url_for('pages_home.index')) + # if 'openid' not in session or 'user' in session: + # return redirect(url_for('pages_home.index')) # ImmutableMultiDict([('status', u'ok'), ('access_token', u'a4d0a13df7c733102fbf6cd650794c6d047e91aa'), ('nickname', u'CrazyPants1999'), ('account_id', u'69552613'), ('', u'1505047809')]) if request.args.get('status') == 'ok' and request.args.get('access_token'): diff --git a/wotstats/views/rush.py b/wotstats/views/rush.py index 1ffcc35..5549d90 100644 --- a/wotstats/views/rush.py +++ b/wotstats/views/rush.py @@ -7,7 +7,7 @@ from jinja2 import TemplateNotFound from wotstats.openid import oid from wotstats.database import db -from wotstats.models import Rush, RushAccounts, WotAccounts +from wotstats.models import Rush, RushAccounts, WotAccounts, UserWallet from wotstats.lib import parse_wargaming_openid_url pages_rush = Blueprint( @@ -29,6 +29,10 @@ def index(): account_id, account_nickname = parse_wargaming_openid_url(session['openid']) + print(session) + + ub = UserWallet.query.filter(UserWallet.user == session['user']).first() + # # # app_id = current_app.config['WG_APPLICATION_ID'] # url = 'https://api.worldoftanks.ru/wot/account/info/' @@ -72,7 +76,9 @@ def index(): 'pages/rush/index.html', rush_list=rush_list, rush_list_accounts=rush_list_accounts, - account_id=account_id, account_nickname=account_nickname + account_id=account_id, + account_nickname=account_nickname, + account_balance=ub.balance ) @pages_rush.route('/apply.html')