update to django 2.0

This commit is contained in:
virusdefender
2019-03-11 11:25:10 +08:00
parent f7bd9f16b4
commit 6b7654a0c3
18 changed files with 69 additions and 53 deletions

View File

@@ -28,7 +28,7 @@ class ProblemDifficulty(object):
class Problem(models.Model):
# display ID
_id = models.TextField(db_index=True)
contest = models.ForeignKey(Contest, null=True)
contest = models.ForeignKey(Contest, null=True, on_delete=models.CASCADE)
# for contest problem
is_public = models.BooleanField(default=False)
title = models.TextField()
@@ -47,7 +47,7 @@ class Problem(models.Model):
create_time = models.DateTimeField(auto_now_add=True)
# we can not use auto_now here
last_update_time = models.DateTimeField(null=True)
created_by = models.ForeignKey(User)
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
# ms
time_limit = models.IntegerField()
# MB

View File

@@ -25,7 +25,7 @@ class PickOneAPI(APIView):
class ProblemAPI(APIView):
@staticmethod
def _add_problem_status(request, queryset_values):
if request.user.is_authenticated():
if request.user.is_authenticated:
profile = request.user.userprofile
acm_problems_status = profile.acm_problems_status.get("problems", {})
oi_problems_status = profile.oi_problems_status.get("problems", {})
@@ -81,7 +81,7 @@ class ProblemAPI(APIView):
class ContestProblemAPI(APIView):
def _add_problem_status(self, request, queryset_values):
if request.user.is_authenticated():
if request.user.is_authenticated:
profile = request.user.userprofile
if self.contest.rule_type == ContestRuleType.ACM:
problems_status = profile.acm_problems_status.get("contest_problems", {})