diff options
author | Prabhu Ramachandran | 2016-05-04 11:13:10 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2016-05-04 11:13:10 +0530 |
commit | 03f0aa839e4d91a3d83d68d5301f1425f18cca73 (patch) | |
tree | 26ba7a6d92878844a25d988cb57112f287b7a85c /yaksh/models.py | |
parent | 825f8464ef1b2853c029cc23bf7fb89f6a9c1c09 (diff) | |
parent | 78795446d89ae5c247f5424d70d652437c93cda6 (diff) | |
download | online_test-03f0aa839e4d91a3d83d68d5301f1425f18cca73.tar.gz online_test-03f0aa839e4d91a3d83d68d5301f1425f18cca73.tar.bz2 online_test-03f0aa839e4d91a3d83d68d5301f1425f18cca73.zip |
Merge pull request #92 from adityacp/Add_Teachers
Add teachers to a course
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 9b92791..a4ea6c3 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -23,7 +23,6 @@ class Profile(models.Model): department = models.CharField(max_length=64) position = models.CharField(max_length=64) - languages = ( ("python", "Python"), ("bash", "Bash"), @@ -71,6 +70,8 @@ class Course(models.Model): requests = models.ManyToManyField(User, related_name='requests') rejected = models.ManyToManyField(User, related_name='rejected') created_on = models.DateTimeField(auto_now_add=True) + teachers = models.ManyToManyField(User, related_name='teachers') + def request(self, *users): self.requests.add(*users) @@ -104,6 +105,9 @@ class Course(models.Model): def is_creator(self, user): return self.creator == user + def is_teacher(self, user): + return True if user in self.teachers.all() else False + def is_self_enroll(self): return True if self.enrollment == enrollment_methods[1][0] else False @@ -116,6 +120,15 @@ class Course(models.Model): def deactivate(self): self.active = False + def add_teachers(self, *teachers): + self.teachers.add(*teachers) + + def get_teachers(self): + return self.teachers.all() + + def remove_teachers(self, *teachers): + self.teachers.remove(*teachers) + def __unicode__(self): return self.name |