pytask/taskapp/models.py
changeset 2 3db830ff66ee
child 5 aea7e764c033
equal deleted inserted replaced
1:b7bbb12e3b8e 2:3db830ff66ee
       
     1 from django.db import models
       
     2 from django.contrib.auth.models import User
       
     3 
       
     4 GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
       
     5 RIGHTS_CHOICES = (
       
     6 	("AD", "Admin"),
       
     7 	("MN", "Manager"),
       
     8 	("DV", "Developer"),
       
     9 	("CT", "Contributor"),)
       
    10 
       
    11 STATUS_CHOICES = (
       
    12 	("OP", "Open"),
       
    13     ("LO", "Locked"),
       
    14 	("CL", "Claimed"),
       
    15 	("AS", "Assigned"),
       
    16     ("RO", "Reopened"),
       
    17     ("CD", "Closed"),
       
    18     ("DL", "Deleted"),
       
    19     ("CM", "Completed"))
       
    20 
       
    21 IMAGES_DIR = "./images"
       
    22 UPLOADS_DIR = "./uploads"
       
    23 
       
    24 class Profile(models.Model):
       
    25 	
       
    26     user = models.ForeignKey(User, unique = True)
       
    27     aboutme = models.TextField()
       
    28     dob = models.DateField()
       
    29     gender = models.CharField(max_length = 1, choices = GENDER_CHOICES)
       
    30     rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES)
       
    31     credits = models.PositiveSmallIntegerField()
       
    32     
       
    33     foss_comm = models.CharField(max_length = 80, blank = True)
       
    34     phonenum = models.CharField(max_length = 15, blank = True)
       
    35     homepage = models.URLField(blank = True)
       
    36     street = models.CharField(max_length = 80, blank = True)
       
    37     city = models.CharField(max_length = 25, blank = True)
       
    38     country = models.CharField(max_length = 25, blank = True)
       
    39     nick = models.CharField(max_length = 20, blank = True)
       
    40 #    photo = models.ImageField(upload_to = IMAGES_DIR, blank = True)
       
    41 
       
    42     def __unicode__(self):
       
    43         return unicode(self.user.username)
       
    44 
       
    45 
       
    46 class Task(models.Model):
       
    47     
       
    48     title = models.CharField(max_length = 200, unique = True)
       
    49     desc = models.TextField()
       
    50     status = models.CharField(max_length = 2, choices = STATUS_CHOICES)
       
    51     tags = models.CharField(max_length = 200, blank = True)
       
    52     
       
    53     subs = models.ManyToManyField('self', blank = True, related_name = "%(class)s_parents")
       
    54     deps = models.ManyToManyField('self', blank = True, related_name = "%(class)s_deps")
       
    55     
       
    56     credits = models.PositiveSmallIntegerField()
       
    57     progress = models.PositiveSmallIntegerField()
       
    58         
       
    59     mentors = models.ManyToManyField(User, related_name = "%(class)s_mentors")
       
    60     created_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
       
    61     claimed_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_claimed_users")
       
    62     assigned_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_assigned_users")
       
    63     
       
    64     creation_datetime = models.DateTimeField()
       
    65     
       
    66     ## not yet decided if attribs after this are to be included
       
    67     ## tasktype = "" ## "bugfix"/"enhancement"
       
    68     ## priority = "" ## "very urgent"/"urgent"
       
    69     
       
    70     def __unicode__(self):
       
    71         return unicode(self.title)
       
    72 
       
    73 class Comment(models.Model):
       
    74     
       
    75     task = models.ForeignKey('Task')
       
    76     data = models.TextField()
       
    77     created_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
       
    78     creation_datetime = models.DateTimeField()
       
    79 #    deleted_by = models.ForeignKey(User, null = True, blank = True, related_name = "%(class)s_deleted_by")
       
    80 #    deleted = models.BooleanField()
       
    81 #    attachment = models.FileField(upload_to = UPLOADS_DIR, blank = True)
       
    82     
       
    83     def __unicode__(self):
       
    84         return unicode(self.task.title)
       
    85 
       
    86 class Credit(models.Model):
       
    87     
       
    88     task = models.ForeignKey('Task')
       
    89     given_by = models.ForeignKey(User, related_name = "%(class)s_given_by")
       
    90     given_to = models.ForeignKey(User, related_name = "%(class)s_given_to")
       
    91     points = models.PositiveSmallIntegerField()
       
    92     given_time = models.DateTimeField()
       
    93     
       
    94     def __unicode__(self):
       
    95         return unicode(self.task.title)
       
    96