Skip to content
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

view for remove_friend model #163

Closed
R0b3rt020 opened this issue Jan 26, 2022 · 2 comments
Closed

view for remove_friend model #163

R0b3rt020 opened this issue Jan 26, 2022 · 2 comments
Labels

Comments

@R0b3rt020
Copy link

Is there any view already made for remove_friend function in models?

@frankwiles
Copy link
Member

No, I just looked through things and there isn't. I think we left that as an exercise for the user because how that might work can easily differ across projects. Maybe you can't remove friendships? Maybe the other party gets notified, maybe they don't. etc.

I wouldn't be opposed to adding a view for it if you wanted to contribute one.

@R0b3rt020
Copy link
Author

R0b3rt020 commented Jan 29, 2022

Similar to remove follow:

@login_required
def friendship_remove(
    request, friend_username, template_name="friendship/friend/remove.html"
):
    """ Remove a friend relationship """
    if request.method == "POST":
        friend_to_remove = user_model.objects.get(username=friend_username)
        friend_request = request.user
        Friend.objects.remove_friend(friend_to_remove,friend_request)
        return redirect("friendship_view_friends", request.user)

    return render(request, template_name, {"friend_username": friend_username})

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

No branches or pull requests

2 participants