setting up transfers and payment info for posts

graphs-n-shit
lza_menace 4 years ago
parent 42a060fc71
commit 7ab965107a

@ -18,9 +18,17 @@ def read(id):
comments = Comment.select().where(Comment.post==post.id)
if wallet.connected:
address = wallet.addresses(account=post.account_index)[0]
transfers = wallet.transfers(account=post.account_index)
else:
address = "?"
return render_template("post/read.html", post=post, address=address, comments=comments)
transfers = "?"
return render_template(
"post/read.html",
post=post,
address=address,
comments=comments,
transfers=transfers
)
else:
return "no meme there brah"

@ -9,16 +9,27 @@ bp = Blueprint("profile", "profile")
@bp.route("/profile/edit", methods=["GET", "POST"])
@login_required
def edit():
un = session["auth"]["preferred_username"]
profile_exists = Profile.filter(username=un)
if request.method == "POST":
address = request.form.get("address")
if len(address) in [97, 108]:
profile = Profile(
username=session["auth"]["preferred_username"],
address=address
)
profile.save()
if profile_exists:
profile = Profile.get(username=un)
profile.address = address
profile.save()
else:
profile = Profile(
username=un,
address=address
)
profile.save()
return redirect(request.args.get("redirect", "/"))
else:
flash("WTF bro, that's not a valid Wownero address")
return redirect(request.url)
return render_template("profile/edit.html")
if profile_exists:
profile = Profile.get(username=un)
else:
profile = None
return render_template("profile/edit.html", profile=profile)

@ -5,7 +5,7 @@
<div class="container" style="text-align:center;">
<div class="about">
<h1>About</h1>
<p>Post memes! Have fun! <s>Comment and talk shit! Earn WOW!</s> (soon :tm:)</p>
<p>Post memes! Have fun! Comment and talk shit! <s>Earn WOW!</s> (soon :tm:)</p>
</div>
</div>

@ -8,27 +8,58 @@
{% if post.hidden %}
<h2>You cannot see this post</h2>
{% else %}
<!-- Post Info -->
<h1>{{ post.title }}</h1>
<p class="subtitle">{{ post.text }}</p>
<p class="subtext">Submitted by <i><u>{{ post.submitter }}</u></i> at <i>{{ post.timestamp }}</i></p>
<br>
<img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=500/ style="margin-bottom:1em;border-radius:4px;">
<hr>
<!-- Payments -->
<h2>Payments</h2>
<p style="word-break:break-all;">Vote for this post by sending WOW to the following address:<br><i>{{ address }}</i></p>
{% if transfers %}
<h5>WOW Received</h5>
{% if transfers.in %}
<ul>
{% for transfer in transfers.in %}
<li>{{ transfer.amount / 100000000000 }} WOW (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid }}</a>)</li>
{% endfor %}
</ul>
{% else %}
<p>No WOW received yet. Show this post some love!</p>
{% endif %}
<h5>WOW Sent</h5>
{% if transfers.out %}
<ul>
{% for transfer in transfers.out %}
<li>{{ transfer.amount / 100000000000 }} WOW (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid }}</a>)</li>
{% endfor %}
</ul>
{% else %}
<p>No payouts yet. Exit scam underway?</p>
{% endif %}
{% endif %}
<hr>
<h3>Comments</h3>
<!-- Comments -->
<h2>Comments</h2>
{% if comments %}
{% for comment in comments %}
<p id="comment{{ comment.id }}">
<p id="comment{{ comment.id }}" class="comment">
<a href="{{ url_for('post.read', id=post.id, _external=True) }}#comment{{ comment.id }}">#{{ comment.id }}</a> - <i>{{ comment.commenter.username }}</i> - {{ comment.comment }}
</p>
{% endfor %}
{% else %}
<p>No comments yet.</p>
{% endif %}
{% endif %}
<hr>
<a href="{{ url_for('comment.create', post_id=post.id) }}"><button class="btn btn-warning">Leave a Comment</button></a>
</div>
</div>

@ -15,6 +15,9 @@
<button type="submit" class="btn btn-success">Submit</button>
</div>
</form>
{% if profile %}
<p style="word-break:break-all;">Existing Address:<br>{{ profile.address }}</p>
{% endif %}
</div>
</div>
{% endblock %}

@ -35,7 +35,6 @@ class Wallet(object):
data=json.dumps({'method': method, 'params': params}),
auth=self.auth
)
# print(r.status_code)
if 'error' in r.json():
return r.json()['error']
else:
@ -83,6 +82,16 @@ class Wallet(object):
_address = self.make_wallet_rpc('create_address', data)
return (_address['address_index'], _address['address'])
def transfers(self, account, address_indices=[]):
data = {
'account_index': account,
'subaddr_indices': address_indices,
'in': True,
'out': True
}
_transfers = self.make_wallet_rpc('get_transfers', data)
return _transfers
def balances(self, account):
data = {'account_index': account}
_balance = self.make_wallet_rpc('get_balance', data)

Loading…
Cancel
Save