diff options
author | adityacp | 2016-06-06 13:51:17 +0530 |
---|---|---|
committer | adityacp | 2016-06-06 13:51:17 +0530 |
commit | bff7f1c916db44e3aec09020affe347e0a1846a6 (patch) | |
tree | 6b7ff6435b9a1507d4bab18d452d0db558b0981e /yaksh/models.py | |
parent | 660a8b4f8b21a1e5836536a9db755fcf840ecd63 (diff) | |
download | online_test-bff7f1c916db44e3aec09020affe347e0a1846a6.tar.gz online_test-bff7f1c916db44e3aec09020affe347e0a1846a6.tar.bz2 online_test-bff7f1c916db44e3aec09020affe347e0a1846a6.zip |
changed naive datetime to aware datetime in models.py, views.py, tests.py
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6ee02e1..6a1dfbe 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -390,7 +390,7 @@ class QuestionPaper(models.Model): user_ip=ip, attempt_number=attempt_num ) - ans_paper.start_time = datetime.now() + ans_paper.start_time = timezone.now() ans_paper.end_time = ans_paper.start_time + \ timedelta(minutes=self.quiz.duration) ans_paper.question_paper = self @@ -414,7 +414,7 @@ class QuestionPaper(models.Model): last_attempt = AnswerPaper.objects.get_user_last_attempt(user=user, questionpaper=self) if last_attempt: - time_lag = (datetime.today() - last_attempt.start_time.replace(tzinfo=None)).days + time_lag = (timezone.now() - last_attempt.start_time).days return time_lag >= self.quiz.time_between_attempts else: return True @@ -660,7 +660,7 @@ class AnswerPaper(models.Model): def time_left(self): """Return the time remaining for the user in seconds.""" - dt = datetime.now() - self.start_time.replace(tzinfo=None) + dt = timezone.now() - self.start_time try: secs = dt.total_seconds() except AttributeError: |