Use the right names for the roles and all other choices.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Mon, 17 Jan 2011 04:06:06 +0530
changeset 438 f861c753e55a
parent 437 b5a93feac34d
child 439 66bdb28ebaf6
Use the right names for the roles and all other choices.
pytask/profile/models.py
pytask/taskapp/models.py
--- a/pytask/profile/models.py	Mon Jan 17 02:58:27 2011 +0530
+++ b/pytask/profile/models.py	Mon Jan 17 04:06:06 2011 +0530
@@ -2,69 +2,103 @@
 
 from django.contrib.auth.models import User
 
-GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
+
+GENDER_CHOICES = (
+  ( 'Male', 'Male'),
+  ('Female', 'Female'),
+)
+
 
-RIGHTS_CHOICES = (
-  ("DC", "Director"),
-  ("MG", "Manager"),
-  ("CR", "Co-ordinator"),
-  ("CT", "Contributor"),)
+ROLES_CHOICES = (
+  ("Administrator", "Administrator"),
+  ("Coordinator", "Coordinator"),
+  ("Mentor", "Mentor"),
+  ("Contributor", "Contributor"),
+)
+
 
 ROLE_CHOICES = (
-  ("DC", "Request sent by Director \
-                to a user at lower level, asking him to act as a director"),
-  ("MG", "Request sent by Manager \
-                to a user at lower level, asking him to act as a manager"),)
+  ("Administrator", "Request sent by Administrator \
+    to a user at lower level, asking him to act as a administrator"),
+  ("Coordinator", "Request sent by Coordinator \
+    to a user at lower level, asking him to act as a coordinator"),
+)
+
 
 class Profile(models.Model):
-    full_name = models.CharField(max_length=50, verbose_name="Name as on bank\
-                                 account", help_text="Any DD/Cheque will be\
-                                 issued on this name")
+    full_name = models.CharField(
+      max_length=50, verbose_name="Name as on bank account",
+      help_text="Any DD/Cheque will be issued on this name")
+
     user = models.ForeignKey(User, unique = True)
-    rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT")
-    pynts = models.PositiveSmallIntegerField(default = 0)
-    
-    aboutme = models.TextField(blank = True, help_text="This information will\
-                               be used to judge the eligibility for any task")
+
+    role = models.CharField(max_length=2,
+                              choices=ROLES_CHOICES,
+                              default=u"Contributor")
+
+    pynts = models.PositiveSmallIntegerField(default=0)
+
+    aboutme = models.TextField(
+      blank = True,
+      help_text="This information will be used to judge the eligibility "
+        "for any task")
 
-    dob = models.DateField(verbose_name = u"Date of Birth", help_text = "YYYY-MM-DD")
-    gender = models.CharField(max_length = 1, choices = GENDER_CHOICES)
+    dob = models.DateField(verbose_name=u"Date of Birth",
+                           help_text="YYYY-MM-DD")
+
+    gender = models.CharField(max_length=24, choices=GENDER_CHOICES)
 
-    address = models.TextField(blank = False, help_text="This information will\
-                               be used to send any DDs/Cheques")
-    phonenum = models.CharField(max_length = 15, blank = True, verbose_name = u"Phone Number")
+    address = models.TextField(
+      blank=False, help_text="This information will be used to send "
+        "any DDs/Cheques.")
+
+    phonenum = models.CharField(max_length = 15, blank = True,
+                                verbose_name = u"Phone Number")
 
     def __unicode__(self):
         return unicode(self.user.username)
 
+
 class Notification(models.Model):
     """ A model to hold notifications.
     All these are sent by the site to users.
     Hence there is no sent_from option.
     """
 
-    sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
+    sent_to = models.ForeignKey(User,
+                                related_name = "%(class)s_sent_to",
+                                blank = False)
 
     subject = models.CharField(max_length=100, blank=True)
+
     message = models.TextField()
 
     sent_date = models.DateTimeField()
+
     is_read = models.BooleanField(default = False)
+
     is_deleted = models.BooleanField(default = False)
 
+
 class RoleRequest(models.Model):
     """ A request sent by one user to the other.
     Typically requesting to raise one's status.
     """
 
     role = models.CharField(max_length=2, choices=ROLE_CHOICES)
+
     is_accepted = models.BooleanField(default=False)
 
     message = models.TextField()
+
     response = models.TextField()
 
-    sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
+    sent_from = models.ForeignKey(User,
+                                  related_name = "%(class)s_sent_from",
+                                  null = True, blank = True)
 
     sent_date = models.DateTimeField()
+
     is_read = models.BooleanField(default = False)
+
     is_deleted = models.BooleanField(default = False)
--- a/pytask/taskapp/models.py	Mon Jan 17 02:58:27 2011 +0530
+++ b/pytask/taskapp/models.py	Mon Jan 17 04:06:06 2011 +0530
@@ -4,72 +4,92 @@
 import tagging
 from tagging.fields import TagField
 
+
 TASK_STATUS_CHOICES = (
-        ("UP", "Unpublished"),
-        ("OP", "Open"),
-        ("LO", "Locked"),
-        ("WR", "Working"),
-        ("CD", "Closed"),
-        ("DL", "Deleted"),
-        ("CM", "Completed"))
+        ("Unpublished", "Unpublished"),
+        ("Open", "Open"),
+        ("Locked", "Locked"),
+        ("Working", "Working"),
+        ("Closed", "Closed"),
+        ("Deleted", "Deleted"),
+        ("Completed", "Completed"))
 
 TB_STATUS_CHOICES = (
-    ("UP", "Unpublished"),
-    ("OP", "Open"),
-    ("WR", "All tasks have users selected"),
-    ("CM", "Completed"))
+    ("Unpublished", "Unpublished"),
+    ("Open", "Open"),
+    ("All tasks have users selected", "All tasks have users selected"),
+    ("Completed", "Completed"))
 
-UPLOADS_DIR = "./pytask/static/uploads"
+UPLOADS_DIR = "/pytask/static/uploads"
+
 
 class Task(models.Model):
-    title = models.CharField(max_length = 100, verbose_name = u"Title", 
-                             help_text = u"Keep it simple and below 100 chars.")
-    desc = models.TextField(verbose_name = u"Description")
+
+    title = models.CharField(
+      max_length=100, verbose_name=u"Title",
+      help_text=u"Keep it simple and below 100 chars.")
+
+    desc = models.TextField(verbose_name=u"Description")
 
-    status = models.CharField(max_length = 2, choices = TASK_STATUS_CHOICES, default = "UP")
-    tags_field = TagField(verbose_name = u"Tags", 
-                          help_text = u"Give tags seperated by commas") 
+    status = models.CharField(max_length=255,
+                              choices=TASK_STATUS_CHOICES,
+                              default="Unpublished")
+
+    tags_field = TagField(verbose_name=u"Tags", 
+                          help_text=u"Give tags seperated by commas") 
     
-    pynts = models.PositiveSmallIntegerField(help_text = u"No.of pynts a user \
-                                             gets on completing the task")
+    pynts = models.PositiveSmallIntegerField(
+      help_text=u"No.of pynts a user gets on completing the task")
+
     created_by = models.ForeignKey(User,
-                                   related_name = "created_tasks")
-    approved_by = models.ForeignKey(User, blank = True, null = True,
-                                    related_name = "approved_tasks")
-    reviewers = models.ManyToManyField(User, blank = True, null = True,
-                                       related_name = "reviewing_tasks")
+                                   related_name="created_tasks")
+
+    approved_by = models.ForeignKey(User, blank=True, null=True,
+                                    related_name="approved_tasks")
+
+    reviewers = models.ManyToManyField(User, blank=True, null=True,
+                                       related_name="reviewing_tasks")
 
-    claimed_users = models.ManyToManyField(User, blank = True, null = True, 
-                                           related_name = "claimed_tasks")
-    selected_users = models.ManyToManyField(User, blank = True, null = True, 
-                                            related_name = "selected_tasks")
-    
+    claimed_users = models.ManyToManyField(User, blank=True, null=True, 
+                                           related_name="claimed_tasks")
+
+    selected_users = models.ManyToManyField(User, blank=True, null=True, 
+                                            related_name="selected_tasks")
+
     creation_datetime = models.DateTimeField()
-    approval_datetime = models.DateTimeField(blank = True, null = True)
-    
+
+    approval_datetime = models.DateTimeField(blank=True, null=True)
+
     def __unicode__(self):
         return unicode(self.title)
 
+
 class TaskComment(models.Model):
 
-    task = models.ForeignKey('Task', related_name = "comments")
+    task = models.ForeignKey('Task', related_name="comments")
             
     data = models.TextField(verbose_name='Comment')
+
     commented_by = models.ForeignKey(User,
-                                     related_name = "commented_taskcomments")
-    deleted_by = models.ForeignKey(User, null = True, blank = True,
-                                   related_name = "deleted_taskcomments")
+                                     related_name="commented_taskcomments")
+
+    deleted_by = models.ForeignKey(User, null=True, blank=True,
+                                   related_name="deleted_taskcomments")
+
     comment_datetime = models.DateTimeField()
+
     is_deleted = models.BooleanField(default=False)
 
     def __unicode__(self):
         return unicode(self.task.title)
 
+
 class TaskClaim(models.Model):
-    task = models.ForeignKey('Task', related_name = "claims")
+
+    task = models.ForeignKey('Task', related_name="claims")
             
     claimed_by = models.ForeignKey(User,
-                                   related_name = "claimed_claims")
+                                   related_name="claimed_claims")
     proposal = models.TextField()
 
     claim_datetime = models.DateTimeField()
@@ -77,64 +97,91 @@
     def __unicode__(self):
         return unicode(self.task.title)
 
+
 class WorkReport(models.Model):
-    task = models.ForeignKey(Task, related_name = "reports")
-    submitted_by = models.ForeignKey(User, null = True, blank = True,
-                                     related_name = "submitted_reports")
-    approved_by = models.ForeignKey(User, null = True, blank = True,
-                                    related_name = "approved_reports")
+
+    task = models.ForeignKey(Task, related_name="reports")
+
+    submitted_by = models.ForeignKey(User, null=True, blank=True,
+                                     related_name="submitted_reports")
+
+    approved_by = models.ForeignKey(User, null=True, blank=True,
+                                    related_name="approved_reports")
 
     data = models.TextField(verbose_name="Report")
+
     summary = models.CharField(max_length=100, verbose_name="Summary",
                                help_text="A one line summary")
-    attachment = models.FileField(upload_to = UPLOADS_DIR)
+
+    attachment = models.FileField(upload_to=UPLOADS_DIR)
 
     revision = models.PositiveIntegerField(default=0)
+
     submitted_at = models.DateTimeField()
 
+
 class ReportComment(models.Model):
-    report = models.ForeignKey('WorkReport', related_name = "%(class)s_report")
+
+    report = models.ForeignKey('WorkReport', related_name="%(class)s_report")
             
     data = models.TextField()
+
     commented_by = models.ForeignKey(User, 
-                                     related_name = "commented_reportcomments")
-    deleted_by = models.ForeignKey(User, null = True, blank = True,
-                                   related_name = "deleted_reportcomments")
+                                     related_name="commented_reportcomments")
+
+    deleted_by = models.ForeignKey(User, null=True, blank=True,
+                                   related_name="deleted_reportcomments")
+
     comment_datetime = models.DateTimeField()
+
     is_deleted = models.BooleanField(default=False)
 
+
 class PyntRequest(models.Model):
-    task = models.ForeignKey(Task, related_name = "pynt_requests")
+    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 = "requested_by_pynts")
+                                     related_name="requested_by_pynts")
+
     requested_for = models.ForeignKey(User, 
-                                     related_name = "requested_for_pynts")
+                                     related_name="requested_for_pynts")
 
-    responded_by = models.ForeignKey(User, null = True, blank = True,
-                                    related_name = "responded_requests")
+    responded_by = models.ForeignKey(User, null=True, blank=True,
+                                    related_name="responded_requests")
 
     is_accepted = models.BooleanField(default=False)
+
     remarks = models.CharField(max_length=100, blank=True,
                                help_text="Reason in case of rejection")
             
     request_datetime = models.DateTimeField()
+
     is_responded = models.BooleanField(default=False)
 
+
 class TextBook(models.Model):
 
-    name = models.CharField(max_length = 100)
+    name = models.CharField(max_length=100)
+
     chapters = models.ManyToManyField(Task, related_name="textbooks")
+
     tags_field = TagField(verbose_name="Tags")
 
-    created_by = models.ForeignKey(User, related_name = "created_textbooks")
-    approved_by = models.ForeignKey(User, null = True, blank = True,
-                                    related_name = "approved_textbooks")
+    created_by = models.ForeignKey(User, related_name="created_textbooks")
+
+    approved_by = models.ForeignKey(User, null=True, blank=True,
+                                    related_name="approved_textbooks")
 
-    status = models.CharField(max_length = 2, choices = TB_STATUS_CHOICES, default = "UP")
+    status = models.CharField(max_length=255,
+                              choices=TB_STATUS_CHOICES,
+                              default="Unpublished")
+
     creation_datetime = models.DateTimeField()
-    approval_datetime = models.DateTimeField(blank = True, null = True)
+
+    approval_datetime = models.DateTimeField(blank=True, null=True)
+
 
 tagging.register(Task)
 tagging.register(TextBook)