update wallet and generate dummy data

migrate-new-models
lza_menace 2 years ago
parent f93bd618ad
commit 70ccd57519

@ -9,3 +9,4 @@ qrcode
Pillow
arrow
python-dotenv
lorem

@ -21,7 +21,7 @@ fi
# run rpc process
docker run --restart=always -d --name suchwow-wallet-rpc \
-v $WALLET_PATH:/root \
-p 8888:8888 \
-p $WALLET_PORT:8888 \
lalanza808/wownero:latest \
wownero-wallet-rpc \
--daemon-address $DAEMON_URI \

@ -57,13 +57,16 @@ class Post(Model):
account_index = IntegerField()
address_index = IntegerField(unique=True)
address = CharField(unique=True)
timestamp = DateTimeField(default=datetime.now)
timestamp = DateTimeField(default=datetime.utcnow)
approved = BooleanField(default=False)
approved_by = ForeignKeyField(User, null=True)
def get_random(self):
all_posts = Post.select().where(Post.approved == True)
return choice([i.id for i in all_posts])
if all_posts:
return choice([i.id for i in all_posts])
else:
return None
def get_previous(self):
prev = Post.select().where(Post.id == self.id - 1).first()

@ -1,5 +1,7 @@
from os import makedirs
from os import makedirs, getenv
from random import choice
import lorem
from flask import Blueprint
from suchwow._models import db, User, Post, AuditEvent, TipSent, TipReceived, Vote
@ -19,6 +21,36 @@ def init():
# init db
db.create_tables([User, Post, AuditEvent, TipSent, TipReceived, Vote])
@bp.cli.command('generate_data')
def generate_data():
if getenv('FLASK_DEBUG', 0) == '1':
users = ['lza_menace', 'wowario', 'jwinterm', 'dsc', 'asymptotically']
for user in users:
moderator = False
if not User.select().where(User.username == user):
if user == 'lza_menace':
moderator = True
User.create(
username=user,
moderator=moderator
)
print(f'Created user {user}')
for i in range(1, 5):
wallet = wownero.Wallet()
address_idx, address = wallet.new_address(config.WALLET_ACCOUNT)
wallet.store()
Post.create(
title=lorem.sentence(),
text=lorem.sentence(),
user=choice(list(User.select())),
image_name='test.jpg',
account_index=config.WALLET_ACCOUNT,
address_index=address_idx,
address=address
)
@bp.cli.command('rescan')
def rescan():

@ -21,7 +21,7 @@
</a>
</li>
<li>
<a href="{{ url_for('post.read', id=post.get_random()) }}">
<a {% if post.get_random() %}href="{{ url_for('post.read', id=post.get_random()) }}{% endif %}">
<span class="icon"><i class="fas fa-question" aria-hidden="true"></i></span>
<span>Random</span>
</a>