summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-04-06 12:38:33 +0530
committerGitHub2017-04-06 12:38:33 +0530
commitad73f7b938b7620ab4be202dc33c699cf5cb4ac5 (patch)
treeadb65fe68d409206a26e23175c9543c12a47c43a /yaksh/models.py
parent969cccf998059e0a800276759535a36d3529b3c6 (diff)
parent1a6653567bdf58b5b70e874822cae6a1116b942f (diff)
downloadonline_test-ad73f7b938b7620ab4be202dc33c699cf5cb4ac5.tar.gz
online_test-ad73f7b938b7620ab4be202dc33c699cf5cb4ac5.tar.bz2
online_test-ad73f7b938b7620ab4be202dc33c699cf5cb4ac5.zip
Merge pull request #267 from ankitjavalkar/course-time-window
Multiple changes to Course:
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 9e05af0..802a1fc 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -126,6 +126,24 @@ class Course(models.Model):
teachers = models.ManyToManyField(User, related_name='teachers')
is_trial = models.BooleanField(default=False)
instructions = models.TextField(default=None, null=True, blank=True)
+
+ # The start date of the course enrollment.
+ start_enroll_time = models.DateTimeField(
+ "Start Date and Time for enrollment of course",
+ default=timezone.now,
+ null=True
+ )
+
+ # The end date and time of the course enrollment
+ end_enroll_time = models.DateTimeField(
+ "End Date and Time for enrollment of course",
+ default=datetime(
+ 2199, 1, 1,
+ tzinfo=pytz.timezone(timezone.get_current_timezone_name())
+ ),
+ null=True
+ )
+
objects = CourseManager()
def request(self, *users):
@@ -134,6 +152,9 @@ class Course(models.Model):
def get_requests(self):
return self.requests.all()
+ def is_active_enrollment(self):
+ return self.start_enroll_time <= timezone.now() < self.end_enroll_time
+
def enroll(self, was_rejected, *users):
self.students.add(*users)
if not was_rejected: