renamed all the related_name fields for better readability
authorNishanth Amuluru <nishanth@fossee.in>
Sun, 09 Jan 2011 00:30:08 +0530
changeset 346 8ffc889a3b37
parent 345 6df2f882b591
child 347 d291c08c62de
renamed all the related_name fields for better readability
pytask/taskapp/models.py
--- a/pytask/taskapp/models.py	Sun Jan 09 00:11:56 2011 +0530
+++ b/pytask/taskapp/models.py	Sun Jan 09 00:30:08 2011 +0530
@@ -35,16 +35,16 @@
     pynts = models.PositiveSmallIntegerField(help_text = u"No.of pynts a user \
                                              gets on completing the task")
     created_by = models.ForeignKey(User,
-                                   related_name = "%(class)s_created_by")
+                                   related_name = "created_tasks")
     approved_by = models.ForeignKey(User, blank = True, null = True,
-                                    related_name = "%(class)s_approved_by")
+                                    related_name = "approved_tasks")
     reviewers = models.ManyToManyField(User, blank = True, null = True,
-                                       related_name = "%(class)s_reviewers")
+                                       related_name = "reviewing_tasks")
 
     claimed_users = models.ManyToManyField(User, blank = True, null = True, 
-                                           related_name = "%(class)s_claimed_users")
+                                           related_name = "claimed_tasks")
     selected_users = models.ManyToManyField(User, blank = True, null = True, 
-                                            related_name = "%(class)s_selected_users")
+                                            related_name = "selected_tasks")
     
     creation_datetime = models.DateTimeField()
     approval_datetime = models.DateTimeField(blank = True, null = True)
@@ -55,13 +55,13 @@
 class TaskComment(models.Model):
 
     uniq_key = models.CharField(max_length = 10, unique = True)
-    task = models.ForeignKey('Task', related_name = "%(class)s_task")
+    task = models.ForeignKey('Task', related_name = "comments")
             
     data = models.TextField()
     commented_by = models.ForeignKey(User,
-                                     related_name = "%(class)s_created_by")
+                                     related_name = "commented_taskcomments")
     deleted_by = models.ForeignKey(User, null = True, blank = True,
-                                   related_name = "%(class)s_deleted_by")
+                                   related_name = "deleted_taskcomments")
     comment_datetime = models.DateTimeField()
     is_deleted = models.BooleanField(default=False)
 
@@ -71,10 +71,10 @@
 class TaskClaim(models.Model):
 
     uniq_key = models.CharField(max_length = 10, unique = True)
-    task = models.ForeignKey('Task', related_name = "%(class)s_task")
+    task = models.ForeignKey('Task', related_name = "claims")
             
     claimed_by = models.ForeignKey(User,
-                                   related_name = "%(class)s_created_by")
+                                   related_name = "claimed_claims")
     proposal = models.TextField()
 
     comment_datetime = models.DateTimeField()
@@ -85,11 +85,11 @@
 class WorkReport(models.Model):
 
     uniq_key = models.CharField(max_length = 10, unique = True)
-    task = models.ForeignKey(Task, related_name = "%(class)s_task")
+    task = models.ForeignKey(Task, related_name = "reports")
     submitted_by = models.ForeignKey(User, null = True, blank = True,
-                                     related_name = "%(class)s_submitted_by")
+                                     related_name = "submitted_reports")
     approved_by = models.ForeignKey(User, null = True, blank = True,
-                                    related_name = "%(class)s_approved_by")
+                                    related_name = "approved_reports")
 
     data = models.TextField()
     summary = models.CharField(max_length=100, verbose_name="Summary",
@@ -105,25 +105,26 @@
     report = models.ForeignKey('WorkReport', related_name = "%(class)s_report")
             
     data = models.TextField()
-    commented_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
+    commented_by = models.ForeignKey(User, 
+                                     related_name = "commented_reportcomments")
     deleted_by = models.ForeignKey(User, null = True, blank = True,
-                                   related_name = "%(class)s_deleted_by")
+                                   related_name = "deleted_reportcomments")
     comment_datetime = models.DateTimeField()
     is_deleted = models.BooleanField(default=False)
 
-class RequestPynts(models.Model):
+class PyntRequests(models.Model):
 
     uniq_key = models.CharField(max_length = 10, unique = True)
-    task = models.ForeignKey(Task, related_name = "%(class)s_task")
+    task = models.ForeignKey(Task, related_name = "pynt_requests")
     pynts = models.PositiveIntegerField(default=0, help_text="No.of pynts")
 
     requested_by = models.ForeignKey(User, 
-                                     related_name = "%(class)s_requested_by")
+                                     related_name = "requested_by_pynts")
     requested_for = models.ForeignKey(User, 
-                                     related_name = "%(class)s_requested_for")
+                                     related_name = "requested_for_pynts")
 
     responded_by = models.ForeignKey(User, null = True, blank = True,
-                                    related_name = "%(class)s_responded_by")
+                                    related_name = "responded_requests")
 
     is_accepted = models.BooleanField(default=False)
     remarks = models.CharField(max_length=100, blank=True,
@@ -135,12 +136,12 @@
 class TextBook(models.Model):
 
     uniq_key = models.CharField(max_length = 10, unique = True)
-    chapters = models.ManyToManyField(Task, related_name="%(class)s_chapters")
+    chapters = models.ManyToManyField(Task, related_name="%(class)s_set")
     tags_field = TagField(verbose_name="Tags")
 
-    created_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
+    created_by = models.ForeignKey(User, related_name = "created_textbooks")
     approved_by = models.ForeignKey(User, null = True, blank = True,
-                                    related_name = "%(class)s_approved_by")
+                                    related_name = "approved_textbooks")
 
     status = models.CharField(max_length = 2, choices = TB_STATUS_CHOICES, default = "UP")
     creation_datetime = models.DateTimeField()