-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_render_template.py
79 lines (65 loc) · 3.11 KB
/
util_render_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import json
from flask import render_template, session, jsonify
from flask_wtf import csrf
import utils
from constants import RECAPTCHA_PUBLIC_KEY
from db_classes import TxnEntry, UserEntry
from forms import LoginForm, RegisterForm
def create_db_table(queries):
loader = []
for query in queries:
loader.append(query.as_dict())
# rec.insert(0, query.serialize())
return {"total": len(loader), "totalNotFiltered": len(loader), "rows": loader}
def setup_pendingWithdraw_template(wrap=False):
# rec = []
# queries = TxnEntry().query.filter_by(type='Withdraw').filter_by(status='Pending')
queries = TxnEntry().query.all()
txn_data = create_db_table(queries)
queries = UserEntry().query.all()
user_data = create_db_table(queries)
# loader = []
# for query in queries:
# loader.append(query.as_dict())
# # rec.insert(0, query.serialize())
# txn_data = {"total": len(loader), "totalNotFiltered": len(loader), "rows": loader}
if wrap:
return render_template('page-pendingWithdraw-wrap.html', txn_data=txn_data, user_data=user_data,
translations=utils.translations)
else:
session['page'] = 'pendingWithdraw'
div_render = render_template('page-pendingWithdraw.html', txn_data=txn_data, user_data=user_data,
translations=utils.translations)
return jsonify(
render=render_template('page-pendingWithdraw-wrap.html', txn_data=txn_data, user_data=user_data,
translations=utils.translations),
div_render=div_render)
def setup_search_template(wrap=False):
queries = UserEntry().query.all()
loader = []
for query in queries:
loader.append(query.as_dict())
user_data = {"total": len(loader), "totalNotFiltered": len(loader), "rows": loader}
if wrap:
rec = []
return render_template('page-search-wrap.html', user_data=user_data, translations=utils.translations)
else:
session['page'] = 'search_user_page'
div_render = render_template('page-search.html', user_data=user_data, translations=utils.translations)
return jsonify(div_render=div_render)
def setup_home_template(notification_title='', notification='', reset_pass_popup=True):
csrf_token = csrf.generate_csrf()
login_form = LoginForm()
login_form.csrf_token.data = csrf_token
register_form = RegisterForm()
register_form.csrf_token.data = csrf_token
if len(notification) > 0:
notification_popup = True
else:
notification_popup = False
return render_template('page-gallery-wrap.html', icon_placement=utils.icon_placement, game_titles=utils.game_titles,
root_path='../', login_form=login_form, register_form=register_form,
RECAPTCHA_PUBLIC_KEY=RECAPTCHA_PUBLIC_KEY, translations=utils.translations,
notification_popup=notification_popup,
notification=notification, notification_title=notification_title,
reset_pass=reset_pass_popup)