taskapp/models.py
changeset 1 7818992cbf83
child 9 3ad980fc23ca
equal deleted inserted replaced
0:a87d642f1ba5 1:7818992cbf83
       
     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 	("MT", "Mentor"),
       
    10 	("CT", "Contributor"),
       
    11 	("GP", "Public"),)
       
    12 
       
    13 STATUS_CHOICES = (
       
    14 	("OP", "Open"),
       
    15 	("CL", "Claimed"),
       
    16 	("LO", "Locked"),
       
    17 	("AS", "Assigned"),)
       
    18 
       
    19 IMAGES_DIR = "./images"
       
    20 UPLOADS_DIR = "./uploads"
       
    21 
       
    22 class Person(models.Model):
       
    23 #class Person(User):
       
    24 	
       
    25     user = models.ForeignKey(User, unique = True)
       
    26     aboutme = models.TextField()
       
    27     DOB = models.DateField()
       
    28     gender = models.CharField(max_length = 1, choices = GENDER_CHOICES)
       
    29     rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES)
       
    30     credits = models.PositiveSmallIntegerField()
       
    31     
       
    32     foss_comm = models.CharField(max_length = 80, blank = True)
       
    33     phoneNum = models.CharField(max_length = 15, blank = True)
       
    34     homepage = models.URLField(blank = True)
       
    35     street = models.CharField(max_length = 80, blank = True)
       
    36     city = models.CharField(max_length = 25, blank = True)
       
    37     country = models.CharField(max_length = 25, blank = True)
       
    38     nick = models.CharField(max_length = 20, blank = True)
       
    39     photo = models.ImageField(upload_to = IMAGES_DIR, blank = True)
       
    40 
       
    41     def __unicode__(self):
       
    42         return unicode(self.user.username)
       
    43 
       
    44 
       
    45 class Task(models.Model):
       
    46     
       
    47     title = models.CharField(max_length = 200, unique = True)
       
    48     desc = models.TextField()
       
    49     status = models.CharField(max_length = 2, choices = STATUS_CHOICES)
       
    50     tags = models.CharField(max_length = 200, blank = True)
       
    51     
       
    52     parents = models.ManyToManyField('self', blank = True, related_name = "%(class)s_parents")
       
    53     deps = models.ManyToManyField('self', blank = True, related_name = "%(class)s_deps")
       
    54     
       
    55     credits = models.PositiveSmallIntegerField()
       
    56     progress = models.PositiveSmallIntegerField()
       
    57         
       
    58     mentors = models.ManyToManyField('Person', related_name = "%(class)s_mentors")
       
    59     created_by = models.ForeignKey('Person', related_name = "%(class)s_created_by")
       
    60     claimed_users = models.ManyToManyField('Person', blank = True, related_name = "%(class)s_claimed_users")
       
    61     assigned_users = models.ManyToManyField('Person', blank = True, related_name = "%(class)s_assigned_users")
       
    62     
       
    63     creation_date = models.DateField()
       
    64     
       
    65     ## not yet decided if attribs after this are to be included
       
    66     ## tasktype = "" ## "bugfix"/"enhancement"
       
    67     ## priority = "" ## "very urgent"/"urgent"
       
    68     
       
    69     def __unicode__(self):
       
    70         return unicode(self.title)
       
    71 
       
    72 class Comment(models.Model):
       
    73     
       
    74     task = models.ForeignKey('Task')
       
    75     data = models.TextField()
       
    76     created_by = models.ForeignKey('Person', related_name = "%(class)s_created_by")
       
    77     deleted_by = models.ForeignKey('Person', null = True, blank = True, related_name = "%(class)s_deleted_by")
       
    78     creation_date = models.DateField()
       
    79     deleted = models.BooleanField()
       
    80     attachment = models.FileField(upload_to = UPLOADS_DIR, blank = True)
       
    81     
       
    82     def __unicode__(self):
       
    83         return unicode(self.task.title)
       
    84 
       
    85 class Credit(models.Model):
       
    86     
       
    87     task = models.ForeignKey('Task')
       
    88     given_by = models.ForeignKey('Person', related_name = "%(class)s_given_by")
       
    89     given_to = models.ForeignKey('Person', related_name = "%(class)s_given_to")
       
    90     points = models.PositiveSmallIntegerField()
       
    91     
       
    92     def __unicode__(self):
       
    93         return unicode(self.task.title)
       
    94