Python Beem Project: Account Information Part 5

avatar

I have updated my project a bit.
It is kind of nice to know how HIVE and STEEM are doing so I took some chart widgets from CoinGecko and added to my home page.
Also I have added a "Profile" thing that you can check your account information.
Reputation, voting power, wallet info and delegations.

https://floating-meadow-28045.herokuapp.com

ezgif.com-gif-maker.gif

UI, layout stuff will probably change again soon since I am going to add information in this page, but it is a nice start.
Design inspirations came from https://hivestats.io/ and https://steemworld.org/ that I use time to time but I don't use all the features.
I just want some specific information and display it in my way but I like hivestats' clean design so I think it will probably end up looking like to hivestat 🤣
Hopefully able to add some nice touch to it though 🙈 🙊 🙉

Main stuff I added was like this 👇

@app.route('/hive/profile', methods=['GET', 'POST'])
def hive_profile():
    form = UserNameForm(request.form)

    if request.method == 'POST':
        if form.validate():
            username = request.form['username'].lower()

            return redirect('/hive/profile/' + username)
        else:
            flash('Username is Required')

    return render_template('hive/profile.html', form=form)


@app.route('/hive/profile/<username>')
@app.route('/hive/profile/<username>/')
def hive_profile_data(username=None):
    data = {}
    if username:
        username = escape(username).lower()
        data = get_user_profile('hive', username)

    logging.warning('get_user_profile')
    logging.warning(data)
    if data:
        return render_template('hive/profile_data.html',
                               username=username, data=data)
    else:
        return render_template('hive/profile_data.html',
                               username=None, data=data)
                               
def get_user_profile(chain_type, username):
    chain = None
    if chain_type == 'hive':
        chain = set_node_list(chain_type='hive')
        chain.is_hive
    elif chain_type == 'steemit':
        chain = set_node_list(chain_type='steemit')
    else:
        return None

    # Create account object
    try:
        account = Account(username)
    except Exception as e:
        logging.warning(e)
        return None

    profile = account.profile

    profile['balances'] = account.get_balances()
    profile['voting_power'] = f"{account.get_voting_power(): .2f}"
    profile['reputation'] = f"{account.get_reputation(): .1f}"

    token_power = account.get_token_power()
    profile['token_power'] = f"{token_power:.3f}"
    logging.warning('token_power')
    logging.warning(token_power)

    # Get delegations
    delegations = account.get_vesting_delegations()
    if delegations:
        profile['delegations'] = get_user_delegations(
            chain, username, delegations)
    else:
        profile['delegations'] = []

    return profile
    
def get_user_delegations(chain, username, delegations):
    # Convert vest to power
    delegation_list = []
    for d in delegations:
        amount = d['vesting_shares']['amount']
        precision = d['vesting_shares']['precision']
        precision = 10 ** precision
        delegatee = d['delegatee']
        vest_amount = float(int(amount) / precision)
        if chain.is_hive:
            delegation_power = f"{chain.vests_to_hp(vest_amount):.3f}"
        elif chain.is_steem:
            delegation_power = f"{chain.vests_to_sp(vest_amount):.3f}"

        delegation_list.append(
            {'delegatee': delegatee, 'amount': delegation_power})

    return delegation_list

My stuff is all in here if you like to look at it.
(please dont. it is a big mess right now lol)
https://github.com/tomoyan/blockchain-tools


Get Rewarded For Browsing! Are you Brave?

happy tears
➡️ Website
➡️ Twitter



0
0
0.000
8 comments
avatar

This is shaping up really great. I really like how it looks now.

0
0
0.000
avatar

really really really 🤩 🤩 🤩

0
0
0.000
avatar

Oh yeah, it looks great, I like it a lot. 🤩😄

Posted using Dapplr

0
0
0.000
avatar

OMG 😳 thank you thank you!!!

0
0
0.000
avatar

This is beginning to intrigued me. What's the language? I'm familiar with perl and PHP and have used them quite a bit. Perl is easier to write, but PHP has better database hooks.

0
0
0.000
avatar

Looking at other people's wallet is fun right 😆 I am using python. If you know perl and PHP, you can do python too. Pretty easy... similar to perl. I thought you were a brown legged speedo person 😝

0
0
0.000
avatar

I have picked your post for my daily hive voting initiative, Keep it up and Hive On!!

0
0
0.000