-
Notifications
You must be signed in to change notification settings - Fork 5
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
🚀 Like Button #111
🚀 Like Button #111
Conversation
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.
LGTM
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.
Looking good
👍
98d73e3
to
2217eb1
Compare
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.
the way authenticate is used here should be revised
https://docs.djangoproject.com/en/4.0/topics/auth/default/#authenticating-users
It is a low level authentication,
Dont you think the logic should be done ins the App side?
f2be968
to
ec66e12
Compare
Updated, you could find the updates in the test file added to this PR in lines 139 and 157. |
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.
Please see this as sample tests
https://github.com/redhat-beyond/beyond-tutorial/blob/main/msgboard/tests.py#L43
Hi @Yarboa, |
You should run another request with client to the redirect URL |
I've added the 200 status code in the def test_after_like_redirect_to_detail_view(self, post, logged_in_client):
# Testing that after successful like, if the user got to the like URL
# by typing it, he would get redirected to the post detail view page.
# Also, if a user turned off the HTTP_REFERER option in his browser he would
# get returned to the post detail view
response = logged_in_client.get(post_like_url(post.id))
assert response.status_code == REDIRECT_URL_STATUS
assert response.url == POST_DETAIL_URL + f'{post.id}/' But I think there is another test missing and I cant figure out how to set it, I tried: def test(self, post, logged_in_client):
logged_in_client.get(FEED_URL)
response = logged_in_client.get(post_like_url(post.id))
assert response.url == FEED_URL but I dont get the feed to be the response.url, I get the post detail view as the test before. origin_url = request.META.get('HTTP_REFERER')
if origin_url is not None:
return HttpResponseRedirect(origin_url) |
Just review the UI talk, you have those sample tests.
|
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.
LGTM
Thanks |
Setting up the like button.
feed/views.py
file.Only an authenticated user can like a post.
Future Improvements:
Close #110