-
Notifications
You must be signed in to change notification settings - Fork 1
Tg 13 kyc vote on playlist #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Update to vote > views.py > vote_for_track for correct vote functionality but requires testing with multiple users:
# If the upvote already exists, then unset upvote
# If the downvote already exists, then unset downvote
# If upvote already exists and then downvote is clicked, unset upvote and set downvote
# If downvote already exists and then upvote is clicked, unset downvote and set upvote
Update to vote > views.py > vote_for_track for correct vote functionality but requires testing with multiple users:
# If the upvote already exists, then unset upvote
# If the downvote already exists, then unset downvote
# If upvote already exists and then downvote is clicked, unset upvote and set downvote
# If downvote already exists and then upvote is clicked, unset downvote and set upvote
Vote view re-factoring (work in progress) with aim of vote model unit testing
…eHubOrg/TeamGroove into TG-13--KYC--vote_on_playlist
finish moving the vote calculation to `models.py`.
Moved logic to `models.py`. Added a `utils.py` with vote logic. Renamed voting methods from `spotify_up_vote`/`spotify_down_vote` to just `up_vote`/`down_vote`
Working on getting the view tests to work with login.
pylance from reformatting .env files.
an unexpected 404 error.
including testing two users voting.
variables rather than class variables.
| build-backend = "poetry.core.masonry.api" | ||
|
|
||
| [tool.pyright] | ||
| exclude = [".env", "env.example"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we using pyright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pyright is apparently used by VS Code. However, the problem with the .env file doesn't appear to be related to pyright misbehaving so this change doesn't seem to help.
| # Voting the same way twice resets the vote | ||
| # If the user has already voted up... | ||
| if self.track_vote > 0: | ||
| # And the user votes up... | ||
| if vote_type == 1: | ||
| # Then reset the vote | ||
| self.track_vote = 0 | ||
| # Otherwise if the user votes down... | ||
| else: | ||
| # Then record a down vote | ||
| self.track_vote = -1 | ||
| # If the user has already voted down... | ||
| elif self.track_vote < 0: | ||
| # And the user votes up... | ||
| if vote_type == 1: | ||
| # Then record an up vote | ||
| self.track_vote = 1 | ||
| # Otherwise if the user votes down... | ||
| else: | ||
| # Then reset the vote | ||
| self.track_vote = 0 | ||
| # Otherwise the user has not voted yet | ||
| else: | ||
| # So if the user votes up... | ||
| if vote_type == 1: | ||
| # Record an up vote | ||
| self.track_vote = 1 | ||
| # So if the user votes down... | ||
| else: | ||
| # Record a down vote | ||
| self.track_vote = -1 | ||
| self.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider:
def update_vote(self, vote_type):
vote_upwards = 1 if vote_type > 0 else -1
same_direction = -1 if vote_upwards == self.track_vote else 1
self.track_vote += vote_upwards * same_direction
assert -1 <= self.track_vote <= 1
self.save()| else: | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing else: pass
Single user vote function, now with unit and view tests.