taskapp/models.py
changeset 167 b61e45074ba1
parent 166 ac72d641046e
child 182 1b4253350a3c
equal deleted inserted replaced
166:ac72d641046e 167:b61e45074ba1
    41     ("NA", "New Admin"),
    41     ("NA", "New Admin"),
    42     ("AU", "Assign user"), ## i mean assign the task
    42     ("AU", "Assign user"), ## i mean assign the task
    43     ("RU", "Remove user"), ## remove from working users list in task
    43     ("RU", "Remove user"), ## remove from working users list in task
    44 )
    44 )
    45 
    45 
    46 
       
    47 IMAGES_DIR = "./images"
    46 IMAGES_DIR = "./images"
    48 UPLOADS_DIR = "./uploads"
    47 UPLOADS_DIR = "./uploads"
    49 
       
    50 
    48 
    51 class CustomImageStorage(FileSystemStorage):
    49 class CustomImageStorage(FileSystemStorage):
    52 
    50 
    53     def path(self, name):
    51     def path(self, name):
    54         """ we return images directory path.
    52         """ we return images directory path.
    85     photo = models.ImageField(storage = CustomImageStorage(),upload_to = IMAGES_DIR, blank = True)
    83     photo = models.ImageField(storage = CustomImageStorage(),upload_to = IMAGES_DIR, blank = True)
    86 
    84 
    87     def __unicode__(self):
    85     def __unicode__(self):
    88         return unicode(self.user.username)
    86         return unicode(self.user.username)
    89 
    87 
    90 
       
    91 class Task(models.Model):
    88 class Task(models.Model):
    92     
    89     
    93     prim_key = models.AutoField(primary_key = True)
    90     prim_key = models.AutoField(primary_key = True)
    94     id = models.CharField(max_length = 10, unique = True)
    91     id = models.CharField(max_length = 10, unique = True)
    95     title = models.CharField(max_length = 100, verbose_name = u"Title", help_text = u"Keep it simple and below 100 chars.")
    92     title = models.CharField(max_length = 100, verbose_name = u"Title", help_text = u"Keep it simple and below 100 chars.")
   114 
   111 
   115 class Map(models.Model):
   112 class Map(models.Model):
   116 
   113 
   117     main = models.ForeignKey('Task', related_name = "%(class)s_main")
   114     main = models.ForeignKey('Task', related_name = "%(class)s_main")
   118     subs = models.ManyToManyField('Task', blank = True, null = True, related_name = "%(class)s_subs")
   115     subs = models.ManyToManyField('Task', blank = True, null = True, related_name = "%(class)s_subs")
   119 
       
   120 
   116 
   121 class Comment(models.Model):
   117 class Comment(models.Model):
   122     
   118     
   123     task = models.ForeignKey('Task')
   119     task = models.ForeignKey('Task')
   124     data = models.TextField()
   120     data = models.TextField()
   167     role = models.CharField(max_length = 2, choices = NOTIFY_CHOICES, blank = False)
   163     role = models.CharField(max_length = 2, choices = NOTIFY_CHOICES, blank = False)
   168     sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
   164     sent_to = models.ForeignKey(User, related_name = "%(class)s_sent_to", blank = False)
   169     sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
   165     sent_from = models.ForeignKey(User, related_name = "%(class)s_sent_from", null = True, blank = True)
   170     task = models.ForeignKey(Task, related_name = "%(class)s_sent_for", null = True, blank = True)
   166     task = models.ForeignKey(Task, related_name = "%(class)s_sent_for", null = True, blank = True)
   171 
   167 
   172 
       
   173     sub = models.CharField(max_length = 100)
   168     sub = models.CharField(max_length = 100)
   174     message = models.TextField()
   169     message = models.TextField()
   175     remarks = models.CharField(max_length = 100)
   170     remarks = models.CharField(max_length = 100)
   176 
   171 
   177     sent_date = models.DateTimeField()
   172     sent_date = models.DateTimeField()