Skip to content

Commit

Permalink
Merge pull request #200 from bounswe/fatih/follow-unfollow
Browse files Browse the repository at this point in the history
followings and followers
  • Loading branch information
fatih260 authored May 11, 2024
2 parents bf8a899 + de2d471 commit aca791f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/nba_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
path('login/', views.log_in, name='login'),
path('feed/', views.feed, name='feed'),
path('profile_view_edit/', views.profile_view_edit, name='profile_view_edit'),
path('user_followings/', views.user_followings, name='user_followings'),
path('user_followers/', views.user_followers, name='user_followers'),
path('follow_user/<int:user_id>', views.follow_user, name='follow_user'),
path('unfollow_user/<int:user_id>', views.unfollow_user, name='unfollow_user'),
path('profile_view_edit/', views.profile_view_edit, name='profile_view_edit'),
path('reset_password/', views.reset_password, name='reset_password'),
path('post/', views.post, name='post'),
path('search/', views.search, name='search'),
Expand Down
14 changes: 14 additions & 0 deletions backend/nba_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ def post_detail(request, post_id):
return render(request, 'post_detail.html', {'post': post, 'comments': comments})


def user_followings(request):
user = request.user
followings = user.following.all()
followings_info = [{'user_id': following.user_id, 'username':following.username} for following in followings]
return JsonResponse({'followings_info': followings_info}, status=200)


def user_followers(request):
user = request.user
followers = user.followers.all()
followers_info = [{'user_id': follower.user_id, 'username':follower.username} for follower in followers]
return JsonResponse({'followers_info': followers_info}, status=200)


def profile_view_edit(request):
if request.method == 'POST':
new_username = request.POST.get('username')
Expand Down

0 comments on commit aca791f

Please sign in to comment.