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