pytask/taskapp/models.py
author anoop
Fri, 29 Jan 2010 22:18:29 +0530
changeset 8 825a497d95b0
parent 5 aea7e764c033
child 11 d28fcc644fbb
permissions -rw-r--r--
corrected views/user/register method
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)
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    27
    dob = models.DateField(help_text = "YYYY-MM-DD")
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    28
    gender = models.CharField(max_length = 1, choices = GENDER_CHOICES)
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    29
    rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT")
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    30
    credits = models.PositiveSmallIntegerField(default = 0)
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    31
    
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    32
    aboutme = models.TextField(blank = True)
2
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
    
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    66
    #is_claimable = models.BooleanField()
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    67
    
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    68
    ## 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
    69
    ## tasktype = "" ## "bugfix"/"enhancement"
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    70
    ## priority = "" ## "very urgent"/"urgent"
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    71
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    72
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    73
        return unicode(self.title)
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
class Comment(models.Model):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    76
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    77
    task = models.ForeignKey('Task')
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    78
    data = models.TextField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    79
    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
    80
    creation_datetime = models.DateTimeField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    81
#    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
    82
#    deleted = models.BooleanField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    83
#    attachment = models.FileField(upload_to = UPLOADS_DIR, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    84
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    85
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    86
        return unicode(self.task.title)
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
class Credit(models.Model):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    89
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    90
    task = models.ForeignKey('Task')
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    91
    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
    92
    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
    93
    points = models.PositiveSmallIntegerField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    94
    given_time = models.DateTimeField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    95
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    96
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    97
        return unicode(self.task.title)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    98