Skip to content
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
Binary file modified ModelGrader.sqlite3
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
path("accounts",account.create_account),
path("accounts/<int:account_id>",account.get_account),
path("accounts/<int:account_id>/daily-submissions",account.get_daily_submission),
path("accounts/<int:account_id>/password",account.change_password),

path('accounts/<int:account_id>/problems',problem.create_problem),
path('problems',problem.all_problem),
Expand Down
10 changes: 8 additions & 2 deletions api/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def get_account(request,account_id):
except:
return Response({'message':'Account not found!'},status=status.HTTP_404_NOT_FOUND)

@api_view([PUT])
def change_password(request,account_id):
account = Account.objects.get(account_id=account_id)
account.password = passwordEncryption(request.data['password'])
account.save()

return Response({'message':"Your password has been changed"})

@api_view([GET])
def get_daily_submission(request,account_id:int):
submissions = Submission.objects.filter(account_id=account_id)
Expand All @@ -40,6 +48,4 @@ def get_daily_submission(request,account_id:int):
else:
submission_by_date[date] = {"count":1, "submissions": [ submission ]}

print(submission_by_date)

return Response({"submissions_by_date": submission_by_date})
3 changes: 1 addition & 2 deletions api/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from time import time
from decouple import config

TOKEN_LIFETIME_HOURS = int(config('TOKEN_LIFETIME_HOURS'))
TOKEN_LIFETIME = TOKEN_LIFETIME_HOURS * 60 * 60 # (Second)
TOKEN_LIFETIME = int(config('TOKEN_LIFETIME_SECOND')) # (Second)

@api_view([POST])
def login(request):
Expand Down
18 changes: 16 additions & 2 deletions api/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create_problem(request,account_id):
checked = checker(1,request.data['solution'],request.data['testcases'],request.data.get('time_limit',1.5))

if checked['has_error'] or checked['has_timeout']:
return Response({'detail': 'Error during creating. Your code may has an error/timeout!'},status=status.HTTP_406_NOT_ACCEPTABLE)
return Response({'detail': 'Error during creating. Your code may has an error/timeout!','result': checked},status=status.HTTP_406_NOT_ACCEPTABLE)

problem = Problem(
language = request.data['language'],
Expand All @@ -44,13 +44,27 @@ def create_problem(request,account_id):
@api_view([GET,DELETE])
def all_problem(request):
if request.method == GET:

problem = Problem.objects.all()

get_private = int(request.query_params.get("private",0))
get_deactive = int(request.query_params.get("deactive",0))
account_id = int(request.query_params.get("account_id",0))

if not get_private:
problem = problem.filter(is_private=False)
if not get_deactive:
problem = problem.filter(is_active=True)
if account_id != 0:
problem = problem.filter(account_id=account_id)

problem = problem.order_by('-problem_id')

result = [model_to_dict(i) for i in problem]

for i in result:
i['creator'] = model_to_dict(Account.objects.get(account_id=i['account_id']))

result.reverse()
return Response({'result':result},status=status.HTTP_200_OK)
elif request.method == DELETE:
target = request.data.get("problem",[])
Expand Down
2 changes: 1 addition & 1 deletion api/views/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..sandbox import grader
from time import sleep

QUEUE = [0,0,0]
QUEUE = [0,0,0,0,0,0,0,0,0,0]

def avaliableQueue():
global QUEUE
Expand Down
1 change: 1 addition & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python manage.py runserver 0.0.0.0:8000