update api with new models

This commit is contained in:
lza_menace 2022-09-06 00:50:02 -07:00
parent 70ccd57519
commit 1624439bba

View file

@ -1,7 +1,6 @@
from flask import jsonify, Blueprint, url_for, request, abort from flask import jsonify, Blueprint, url_for, request, abort
from suchwow.models import Post from suchwow._models import Post
from suchwow import wownero
bp = Blueprint("api", "api") bp = Blueprint("api", "api")
@ -22,18 +21,17 @@ def api_list():
limit = 30 limit = 30
all_posts = [] all_posts = []
posts = Post.select().where(Post.approved==True).order_by(Post.timestamp.desc()).limit(limit).offset(offset) posts = Post.select().where(
Post.approved == True
).order_by(
Post.timestamp.desc()
).limit(limit).offset(offset)
for post in posts: for post in posts:
wallet = wownero.Wallet()
if wallet.connected:
address = wallet.get_address(account=post.account_index)
else:
address = ''
payload = { payload = {
'image': url_for('post.uploaded_file', filename=post.image_name, _external=True), 'image': url_for('post.uploaded_file', filename=post.image_name, _external=True),
'submitter': post.submitter, 'submitter': post.user.username,
'address': address, 'address': post.address,
'title': post.title, 'title': post.title,
'text': post.text, 'text': post.text,
'href': url_for('post.read', id=post.id, _external=True), 'href': url_for('post.read', id=post.id, _external=True),