Remove uniqkey field from every model.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Sat, 15 Jan 2011 00:41:50 +0530
changeset 403 61292fa7f61a
parent 402 b8ca16f03916
child 404 c83eba94f643
Remove uniqkey field from every model. This field is redundant data. Every Django database model has a built-in id which is unique for that database entity. So this field becomes redundant. In addition this field is not even a primary key. So I am not sure what it is trying to achieve. It is also agains the schema design principles. Normalization level 2 is lost by having redundant data. The way uniqkey is generated using random is also awkward.
pytask/profile/models.py
pytask/taskapp/models.py
--- a/pytask/profile/models.py	Sat Jan 15 00:37:46 2011 +0530
+++ b/pytask/profile/models.py	Sat Jan 15 00:41:50 2011 +0530
@@ -5,21 +5,18 @@
 GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
 
 RIGHTS_CHOICES = (
-	("DC", "Director"),
-	("MG", "Manager"),
-        ("CR", "Co-ordinator"),
-	("CT", "Contributor"),)
+  ("DC", "Director"),
+  ("MG", "Manager"),
+  ("CR", "Co-ordinator"),
+  ("CT", "Contributor"),)
 
 ROLE_CHOICES = (
-	("DC", "Request sent by Director \
+  ("DC", "Request sent by Director \
                 to a user at lower level, asking him to act as a director"),
-	("MG", "Request sent by Manager \
+  ("MG", "Request sent by Manager \
                 to a user at lower level, asking him to act as a manager"),)
 
 class Profile(models.Model):
-    
-    uniq_key = models.CharField(max_length=20)
-
     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")
@@ -46,8 +43,6 @@
     Hence there is no sent_from option.
     """
 
-    uniq_key = models.CharField(max_length=20)
-
     sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
 
     subject = models.CharField(max_length=100, blank=True)
@@ -62,7 +57,6 @@
     Typically requesting to raise one's status.
     """
 
-    uniq_key = models.CharField(max_length=20)
     role = models.CharField(max_length=2, choices=ROLE_CHOICES)
     is_accepted = models.BooleanField(default=False)
 
@@ -74,4 +68,3 @@
     sent_date = models.DateTimeField()
     is_read = models.BooleanField(default = False)
     is_deleted = models.BooleanField(default = False)
-
--- a/pytask/taskapp/models.py	Sat Jan 15 00:37:46 2011 +0530
+++ b/pytask/taskapp/models.py	Sat Jan 15 00:41:50 2011 +0530
@@ -22,8 +22,6 @@
 UPLOADS_DIR = "./pytask/static/uploads"
 
 class Task(models.Model):
-    
-    uniq_key = models.CharField(max_length = 10, unique = True)
     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")
@@ -54,7 +52,6 @@
 
 class TaskComment(models.Model):
 
-    uniq_key = models.CharField(max_length = 10, unique = True)
     task = models.ForeignKey('Task', related_name = "comments")
             
     data = models.TextField(verbose_name="")
@@ -69,8 +66,6 @@
         return unicode(self.task.title)
 
 class TaskClaim(models.Model):
-
-    uniq_key = models.CharField(max_length = 10, unique = True)
     task = models.ForeignKey('Task', related_name = "claims")
             
     claimed_by = models.ForeignKey(User,
@@ -83,8 +78,6 @@
         return unicode(self.task.title)
 
 class WorkReport(models.Model):
-
-    uniq_key = models.CharField(max_length = 10, unique = True)
     task = models.ForeignKey(Task, related_name = "reports")
     submitted_by = models.ForeignKey(User, null = True, blank = True,
                                      related_name = "submitted_reports")
@@ -100,8 +93,6 @@
     submitted_at = models.DateTimeField()
 
 class ReportComment(models.Model):
-
-    uniq_key = models.CharField(max_length = 10, unique = True)
     report = models.ForeignKey('WorkReport', related_name = "%(class)s_report")
             
     data = models.TextField()
@@ -113,8 +104,6 @@
     is_deleted = models.BooleanField(default=False)
 
 class PyntRequest(models.Model):
-
-    uniq_key = models.CharField(max_length = 10, unique = True)
     task = models.ForeignKey(Task, related_name = "pynt_requests")
     pynts = models.PositiveIntegerField(default=0, help_text="No.of pynts")
 
@@ -135,7 +124,6 @@
 
 class TextBook(models.Model):
 
-    uniq_key = models.CharField(max_length = 10, unique = True)
     name = models.CharField(max_length = 100)
     chapters = models.ManyToManyField(Task, related_name="textbooks")
     tags_field = TagField(verbose_name="Tags")