Transaction page completed
This commit is contained in:
parent
0416eb63ce
commit
8559417f24
@ -1,5 +1,5 @@
|
|||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask import render_template, flash, redirect, url_for
|
from flask import render_template, flash, redirect, url_for, request
|
||||||
from app import app
|
from app import app
|
||||||
from app.forms import SearchForm, BlankForm
|
from app.forms import SearchForm, BlankForm
|
||||||
import sqlite3
|
import sqlite3
|
||||||
@ -29,9 +29,10 @@ def index():
|
|||||||
c.execute('SELECT address,SUM(transferBalance) FROM transactiontable GROUP BY address')
|
c.execute('SELECT address,SUM(transferBalance) FROM transactiontable GROUP BY address')
|
||||||
balanceTable = c.fetchall()
|
balanceTable = c.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return render_template('test.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable)
|
return render_template('index.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable)
|
||||||
|
|
||||||
if blankform.validate_on_submit():
|
if blankform.validate_on_submit():
|
||||||
|
return "str"
|
||||||
flash('Balance requested for address {}'.format(form.address.data))
|
flash('Balance requested for address {}'.format(form.address.data))
|
||||||
conn = sqlite3.connect(dblocation)
|
conn = sqlite3.connect(dblocation)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
@ -42,6 +43,23 @@ def index():
|
|||||||
c.execute('SELECT address,SUM(transferBalance) FROM transactiontable GROUP BY address')
|
c.execute('SELECT address,SUM(transferBalance) FROM transactiontable GROUP BY address')
|
||||||
balanceTable = c.fetchall()
|
balanceTable = c.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return render_template('test.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable)
|
return render_template('index.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable)
|
||||||
|
|
||||||
return render_template('index.html', form=form, blankform=blankform, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable)
|
return render_template('index.html', form=form, blankform=blankform, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable)
|
||||||
|
|
||||||
|
@app.route('/transactions', methods=['GET', 'POST'])
|
||||||
|
def transactions():
|
||||||
|
address = request.args.get('address')
|
||||||
|
if address is not None:
|
||||||
|
conn = sqlite3.connect(dblocation)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute('SELECT * FROM transactionHistory WHERE fromAddress="{}" OR toAddress="{}" ORDER BY id DESC'.format(address,address))
|
||||||
|
transactionHistoryTable = c.fetchall()
|
||||||
|
conn.close()
|
||||||
|
return render_template('transactions.html', transactionHistoryTable=transactionHistoryTable)
|
||||||
|
conn = sqlite3.connect(dblocation)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute('SELECT * FROM transactionHistory ORDER BY id DESC')
|
||||||
|
transactionHistoryTable = c.fetchall()
|
||||||
|
conn.close()
|
||||||
|
return render_template('transactions.html', transactionHistoryTable=transactionHistoryTable)
|
||||||
|
|||||||
@ -36,16 +36,13 @@
|
|||||||
<span class="navbar-toggler-bar"></span>
|
<span class="navbar-toggler-bar"></span>
|
||||||
<span class="navbar-toggler-bar"></span>
|
<span class="navbar-toggler-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="https://www.creative-tim.com">RMT Explorer</a>
|
<a class="navbar-brand" href="/">RMT Explorer</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="navbarToggler">
|
<div class="collapse navbar-collapse" id="navbarToggler">
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="../index.html" class="nav-link"><i class="nc-icon nc-layout-11"></i>Components</a>
|
<a href="https://ranchimall.net" target="_blank" class="nav-link"><i
|
||||||
</li>
|
class="nc-icon nc-shop"></i> Ranchi Mall</a>
|
||||||
<li class="nav-item">
|
|
||||||
<a href="../documentation/tutorial-components.html" target="_blank" class="nav-link"><i
|
|
||||||
class="nc-icon nc-book-bookmark"></i> Documentation</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" rel="tooltip" title="Like us on Facebook" data-placement="bottom"
|
<a class="nav-link" rel="tooltip" title="Like us on Facebook" data-placement="bottom"
|
||||||
@ -79,15 +76,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<nav class="footer-nav">
|
<nav class="footer-nav">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://www.creative-tim.com">Creative Tim</a></li>
|
<li><a href="https://ranchimall.net" target="_blank">Ranchi Mall</a></li>
|
||||||
<li><a href="http://blog.creative-tim.com">Blog</a></li>
|
<li><a href="http://medium.com/ranchimall" target="_blank">Medium</a></li>
|
||||||
<li><a href="https://www.creative-tim.com/license">Licenses</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="credits ml-auto">
|
<div class="credits ml-auto">
|
||||||
<span class="copyright">
|
<span class="copyright">
|
||||||
© <script>document.write(new Date().getFullYear())</script>, made with <i
|
© <script>document.write(new Date().getFullYear())</script>, Ranchi Mall
|
||||||
class="fa fa-heart heart"></i> by Creative Tim
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
{% if balance %}
|
{% if balance %}
|
||||||
<div class="ml-auto mr-auto">
|
<div class="ml-auto mr-auto">
|
||||||
<br/>
|
<br/>
|
||||||
<p>Balance {{balance}} RMT</p>
|
<p>Balance - {{balance}} RMT<a href={{url_for('transactions', address=form.address.data)}} class="btn btn-link btn-info">Related transactions</a></p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
@ -85,10 +85,11 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="col-md-6 ml-auto mr-auto text-center">
|
<div class="col-md-6 ml-auto mr-auto text-center">
|
||||||
<btn class="btn btn-outline-default btn-round"><i
|
<a href="/transactions"> <btn class="btn btn-outline-default btn-round"><i
|
||||||
class="nc-icon nc-paper"></i>
|
class="nc-icon nc-paper"></i>
|
||||||
View all
|
View all
|
||||||
</btn>
|
</btn>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -18,36 +18,13 @@
|
|||||||
<div class="section section-buttons">
|
<div class="section section-buttons">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="tim-title">
|
<div class="tim-title">
|
||||||
<h2>RMT Balance</h2>
|
<h2>Transactions</h2>
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<form action="" method="post" novalidate>
|
|
||||||
<div class="form-group">
|
|
||||||
<!--<input type="text" class="form-control" placeholder="Enter FLO address">-->
|
|
||||||
{{ form.hidden_tag() }}
|
|
||||||
{{ form.address(class="form-control", placeholder="Enter FLO address", length=100) }}
|
|
||||||
{% for error in form.address.errors %}
|
|
||||||
<span style="color: red;">[{{ error }}]</span>
|
|
||||||
{% endfor %}
|
|
||||||
{% if balance %}
|
|
||||||
<div class="ml-auto mr-auto">
|
|
||||||
<br/>
|
|
||||||
<p>Balance {{balance}} RMT</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Start of tables -->
|
<!-- Start of tables -->
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="card card-plain">
|
<div class="card card-plain">
|
||||||
<div class="tim-title">
|
|
||||||
<h3>Latest Transactions</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@ -84,41 +61,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="col-md-6 ml-auto mr-auto text-center">
|
|
||||||
<btn class="btn btn-outline-default btn-round"><i class="nc-icon nc-paper"></i>
|
|
||||||
View all
|
|
||||||
</btn>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Table 2 -->
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="card card-plain">
|
|
||||||
<div class="tim-title">
|
|
||||||
<h3>Balances</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<thead class=" text-primary">
|
|
||||||
<th>
|
|
||||||
Address
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Balance
|
|
||||||
</th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for item in balanceTable %}
|
|
||||||
<tr>
|
|
||||||
<td>{{item[0]}}</td>
|
|
||||||
<td>{{item[1]}}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user