You are viewing a single comment's thread from:
RE: SteemAX 1.2 ~ New Features: Ratio Slider & Instant Invites
A couple of small notes:
Instead of
if votes is not None and len(votes) > 0:
for v in votes:
if v['voter'] == account2:
self.msg.error_message(account2 +
" has aready voted on " + permlink[1])
return False
I would use a list comprehension here; Ex:
if votes and account2 in [v["voter"] for v in votes]:
Regarding verify_post function:
def verify_post(self, account1, account2):
...
Using author, voter instead of account1, account2 may be a better naming for the code readers.
Also, looks like you have fixed a couple of "input" issues on only frontend, shouldn't be also checked on the backend? This is not a good practice since passing the frontend checks are trivial for bad actors.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
@emrebeyler thank you for looking at my code so closely. You have brought up some interesting concerns so let me address them.
The reason I am using the naming "account1" and "account2" is because they are both authors and they are both voters, but account1 is always the inviter, and account2 is always the invitee. I use post1/post2 and vote1/vote2 naming conventions in the same way so that I always know who's inviter and who's invitee. Looking at this function now I suppose it could be renamed author/voter.
The input issues only affected the front-end. Please see sec.py for back-end filtering.
As for using a list comprehension, I'd have to look at that more closely to see how it affects logic since I'm not really used to doing it this way. I'm sure it's more pythonic, but how does it handle an empty vote list (hence why I had len(votes) > 0)? I'll play around with it. Thanks for the advice.
Thank you for your review, @emrebeyler!
So far this week you've reviewed 5 contributions. Keep up the good work!