Skip to content

Bugfix/aaradhyaberi07/issue 91/bug codeforces updater for list #150

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

Open
wants to merge 2 commits into
base: bugfix/aaradhyaberi07/issue-91/bug-codeforces-updater-for-list
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions codedigger/lists/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
SearchUserlistView,
ListGetView,
EnrollListView,
UpdateForUserView,
UpdatesForUserView,
testing)

urlpatterns = [
Expand Down Expand Up @@ -66,9 +66,7 @@
path('enroll-list/', EnrollListView.as_view(), name='enroll-list'),
path('userlists', SearchUserlistView.as_view(), name='userlist-search'),
path('user/<str:username>', ListGetView.as_view(), name='user-list'),
path('update/<str:platform>/',
UpdateForUserView.as_view(),
name='update-codeforces'),
path('update', UpdatesForUserView.as_view(), name='update-codeforces'),
# path('<str:slug>/stats', ListStats.as_view(), name='list-stats'),
path('<str:slug>/stats/standing',
UserStandingStats.as_view(),
Expand Down
30 changes: 16 additions & 14 deletions codedigger/lists/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
EnrollInListSerializer,
UpdateCodeforcesForUserSerializer)
from codeforces.api import user_status
from .solved_update import (UpdateforUserCodeforces, UpdateforUserAtcoder,
UpdateforUserCodechef, UpdateforUserSpoj,
UpdateforUserUva, EnrollInListSerializer)
from .solved_update import (
UpdateforUserCodeforces,
UpdateforUserAtcoder,
UpdateforUserCodechef,
UpdateforUserSpoj,
UpdateforUserUva,
)
from django.db.models import Q, Subquery, Count
from user.permissions import *
from user.exception import *
Expand Down Expand Up @@ -830,11 +834,13 @@ class UpdatesForUserView(generics.GenericAPIView):
def post(self, request, *args, **kwargs):
curr_user = self.request.user
data = request.data
platform = self.kwargs['platform']
platform = request.GET.get('platform',None)
username = data.get("username", None)
limit = data.get("limit", None)
if curr_user and curr_user.is_staff and username:
curr_user = User.objects.get(username=username)
curr_user = User.objects.get(username = username)
returned_status = None
returned_response = None
if platform == 'F':
returned_status, returned_response = UpdateforUserCodeforces(
curr_user, limit)
Expand All @@ -851,15 +857,11 @@ def post(self, request, *args, **kwargs):
returned_status, returned_response = UpdateforUserUva(
curr_user, limit)
if returned_status:
return response.Response(
{
'status': 'OK',
'result': returned_response
},
status=status.HTTP_200_OK)
else:
return ValidationException(returned_response)

return response.Response({'status': 'OK', 'result': returned_response}, status = status.HTTP_200_OK)
return ValidationException(returned_response)




def testing(request):
updater()
Expand Down