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

Fatih/follow unfollow #198

Merged
merged 3 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/nba_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
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('follow_user/', views.follow_user, name='follow_user'),
path('unfollow_user/', views.unfollow_user, name='unfollow_user'),
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('reset_password/', views.reset_password, name='reset_password'),
path('post/', views.post, name='post'),
path('search/', views.search, name='search'),
Expand Down
8 changes: 4 additions & 4 deletions backend/nba_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ def reset_password(request):



def follow_user(request):
def follow_user(request, user_id):
if request.method != 'POST':
return JsonResponse({'error': 'Only POST requests are allowed.'}, status=405)

user_id = request.POST.get('user_id')
# user_id = request.POST.get('user_id')

if request.user.user_id == user_id:
return JsonResponse({'error': 'You cannot follow yourself.'}, status=400)
Expand All @@ -236,11 +236,11 @@ def follow_user(request):



def unfollow_user(request):
def unfollow_user(request, user_id):
if request.method != 'POST':
return JsonResponse({'error': 'Only POST requests are allowed.'}, status=405)

user_id = request.POST.get('user_id')
# user_id = request.POST.get('user_id')

# Retrieve the user to unfollow
try:
Expand Down
5 changes: 3 additions & 2 deletions backend/nba_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases



DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.getenv('DB_NAME'),
'HOST': '64.226.89.39',#os.getenv('DB_HOST'),
'PORT': '3307',#os.getenv('DB_PORT'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
}
Expand Down