diff options
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 32fb0d0..6ee02e1 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -8,7 +8,8 @@ from django.contrib.auth.models import User from django.forms.models import model_to_dict from django.contrib.contenttypes.models import ContentType from taggit.managers import TaggableManager - +from django.utils import timezone +import pytz languages = ( ("python", "Python"), @@ -144,6 +145,8 @@ class Profile(models.Model): institute = models.CharField(max_length=128) department = models.CharField(max_length=64) position = models.CharField(max_length=64) + timezone = models.CharField(max_length=64, + choices=[(tz, tz) for tz in pytz.common_timezones]) ############################################################################### @@ -291,12 +294,14 @@ class Quiz(models.Model): # The start date of the quiz. start_date_time = models.DateTimeField("Start Date and Time of the quiz", - default=datetime.now(), + default=timezone.now(), null=True) # The end date and time of the quiz end_date_time = models.DateTimeField("End Date and Time of the quiz", - default=datetime(2199, 1, 1, 0, 0, 0, 0), + default=datetime(2199, 1, 1, + tzinfo=pytz.timezone\ + (timezone.get_current_timezone_name())), null=True) # This is always in minutes. @@ -331,7 +336,7 @@ class Quiz(models.Model): def is_expired(self): - return not self.start_date_time <= datetime.now() < self.end_date_time + return not self.start_date_time <= timezone.now() < self.end_date_time def has_prerequisite(self): return True if self.prerequisite else False @@ -409,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).days + time_lag = (datetime.today() - last_attempt.start_time.replace(tzinfo=None)).days return time_lag >= self.quiz.time_between_attempts else: return True |