Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

#8 - Allow users to favorite articles #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

luanfonceca
Copy link
Contributor

@luanfonceca luanfonceca commented Jan 8, 2021

Note:
I don't know why yet, but the turbo-frames are not being updated with eachother. When I favorite a article, only the first turbo-frame gets updated, which make sense but I couldn't find anything on the docs to make both turbo-frames work.

Screen Shot 2021-01-08 at 19 21 13

Context: #8

Description:

  • Added a new template/turbo-frame called _favorite.html
  • Create a new view called FavoriteArticle to handle favorite/unfavorite articles with annotated favorited_by__count

Screenshots:
Screen Shot 2021-01-08 at 19 24 27
Screen Shot 2021-01-08 at 19 24 33
Screen Shot 2021-01-08 at 19 24 44

@davish
Copy link
Contributor

davish commented Jan 8, 2021

I think we'd need to use turbo streams if we wanted both buttons to update at the same time -- frames can only update content within its own fame (or a single other one with the target attribute). Maybe target="other_favorite" would work? I'm not actually sure if "this" frame will update if target="that".

@blopker
Copy link
Member

blopker commented Jan 9, 2021

I agree, I think streams might be the way to go here, however, they work on ids, can one stream response change the contents of 2 elements?

@@ -55,3 +63,32 @@ def form_valid(self, form):
"""
self.object = form.save(self.request.user)
return HttpResponseRedirect(self.get_success_url(), status=303)


class FavoriteArticle(IsAuthenticatedOrReadOnly, UpdateView):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see the LoginRequiredMixin? I will redirect the user back to the right page after they login.

@blopker
Copy link
Member

blopker commented Jan 12, 2021

Where did this PR land? Did we figure out how to get all the buttons to toggle?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants