summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorprathamesh2016-03-07 15:29:36 +0530
committerprathamesh2016-03-07 15:29:36 +0530
commitb58a0b9831d8e6434362f776c89076c2d84e9b26 (patch)
treeb9580710f6ecb2102b8c20548a60af68a004b1de /yaksh/models.py
parentd9793c01304498d7f59820cf2ab2d7a5483851f8 (diff)
downloadonline_test-b58a0b9831d8e6434362f776c89076c2d84e9b26.tar.gz
online_test-b58a0b9831d8e6434362f776c89076c2d84e9b26.tar.bz2
online_test-b58a0b9831d8e6434362f776c89076c2d84e9b26.zip
Added tests for Course model
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index d6fe972..46fb9a3 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -62,6 +62,7 @@ def get_assignment_dir(instance, filename):
###############################################################################
class Course(models.Model):
+ """ Course for students"""
name = models.CharField(max_length=128)
enrollment = models.CharField(max_length=32, choices=enrollment_methods)
active = models.BooleanField(default=True)
@@ -77,17 +78,7 @@ class Course(models.Model):
def get_requests(self):
return self.requests.all()
- def reject(self, was_enrolled=False, *users):
- self.rejected.add(*users)
- if not was_enrolled:
- self.requests.remove(*users)
- else:
- self.students.remove(*users)
-
- def get_rejected(self):
- return self.rejected.all()
-
- def enroll(self, was_rejected=False, *users):
+ def enroll(self, was_rejected, *users):
self.students.add(*users)
if not was_rejected:
self.requests.remove(*users)
@@ -97,12 +88,25 @@ class Course(models.Model):
def get_enrolled(self):
return self.students.all()
+ def reject(self, was_enrolled, *users):
+ self.rejected.add(*users)
+ if not was_enrolled:
+ self.requests.remove(*users)
+ else:
+ self.students.remove(*users)
+
+ def get_rejected(self):
+ return self.rejected.all()
+
def is_enrolled(self, user_id):
return self.students.filter(id=user_id).exists()
def is_creator(self, user):
return self.creator == user
+ def is_self_enroll(self):
+ return True if self.enrollment == enrollment_methods[1][0] else False
+
def get_quizzes(self):
return self.quiz_set.all()
@@ -112,9 +116,6 @@ class Course(models.Model):
def deactivate(self):
self.active = False
- def is_self_enroll(self):
- return True if self.enrollment == 'open' else False
-
def __unicode__(self):
return self.name