diff --git a/suchwow/routes/post.py b/suchwow/routes/post.py index 6722a45..e5dd803 100644 --- a/suchwow/routes/post.py +++ b/suchwow/routes/post.py @@ -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" diff --git a/suchwow/routes/profile.py b/suchwow/routes/profile.py index c181494..f017ccb 100644 --- a/suchwow/routes/profile.py +++ b/suchwow/routes/profile.py @@ -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) diff --git a/suchwow/templates/about.html b/suchwow/templates/about.html index 302bfe2..a8d7646 100644 --- a/suchwow/templates/about.html +++ b/suchwow/templates/about.html @@ -5,7 +5,7 @@

About

-

Post memes! Have fun! Comment and talk shit! Earn WOW! (soon :tm:)

+

Post memes! Have fun! Comment and talk shit! Earn WOW! (soon :tm:)

diff --git a/suchwow/templates/post/read.html b/suchwow/templates/post/read.html index 0163484..363371b 100644 --- a/suchwow/templates/post/read.html +++ b/suchwow/templates/post/read.html @@ -8,27 +8,58 @@ {% if post.hidden %}

You cannot see this post

{% else %} + +

{{ post.title }}

{{ post.text }}

Submitted by {{ post.submitter }} at {{ post.timestamp }}



+ + +

Payments

Vote for this post by sending WOW to the following address:
{{ address }}

+ {% if transfers %} +
WOW Received
+ {% if transfers.in %} + + {% else %} +

No WOW received yet. Show this post some love!

+ {% endif %} +
WOW Sent
+ {% if transfers.out %} + + {% else %} +

No payouts yet. Exit scam underway?

+ {% endif %} + {% endif %}
-

Comments

+ + +

Comments

{% if comments %} {% for comment in comments %} -

+

#{{ comment.id }} - {{ comment.commenter.username }} - {{ comment.comment }}

{% endfor %} {% else %}

No comments yet.

{% endif %} + {% endif %} -
+ + diff --git a/suchwow/templates/profile/edit.html b/suchwow/templates/profile/edit.html index e9529c8..42af6a1 100644 --- a/suchwow/templates/profile/edit.html +++ b/suchwow/templates/profile/edit.html @@ -15,6 +15,9 @@ + {% if profile %} +

Existing Address:
{{ profile.address }}

+ {% endif %} {% endblock %} diff --git a/suchwow/wownero.py b/suchwow/wownero.py index ce5fc5a..6d036e2 100644 --- a/suchwow/wownero.py +++ b/suchwow/wownero.py @@ -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)