pytask/taskapp/models.py
author nishanth
Mon, 01 Feb 2010 11:10:29 +0530
changeset 14 f2623fb8041a
parent 11 d28fcc644fbb
child 15 c6038cbf8a39
permissions -rw-r--r--
implemented add another mentor functionality to a task.
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 = (
11
d28fcc644fbb implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents: 5
diff changeset
    12
    ("UP", "Unpublished"),
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    13
	("OP", "Open"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    14
    ("LO", "Locked"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    15
	("CL", "Claimed"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    16
	("AS", "Assigned"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    17
    ("RO", "Reopened"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    18
    ("CD", "Closed"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    19
    ("DL", "Deleted"),
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    20
    ("CM", "Completed"))
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    21
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    22
IMAGES_DIR = "./images"
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    23
UPLOADS_DIR = "./uploads"
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    24
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    25
class Profile(models.Model):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    26
	
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    27
    user = models.ForeignKey(User, unique = True)
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    28
    dob = models.DateField(help_text = "YYYY-MM-DD")
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    29
    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
    30
    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
    31
    credits = models.PositiveSmallIntegerField(default = 0)
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    32
    
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    33
    aboutme = models.TextField(blank = True)
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    34
    foss_comm = models.CharField(max_length = 80, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    35
    phonenum = models.CharField(max_length = 15, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    36
    homepage = models.URLField(blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    37
    street = models.CharField(max_length = 80, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    38
    city = models.CharField(max_length = 25, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    39
    country = models.CharField(max_length = 25, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    40
    nick = models.CharField(max_length = 20, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    41
#    photo = models.ImageField(upload_to = IMAGES_DIR, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    42
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    43
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    44
        return unicode(self.user.username)
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
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    47
class Task(models.Model):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    48
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    49
    title = models.CharField(max_length = 200, unique = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    50
    desc = models.TextField()
11
d28fcc644fbb implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents: 5
diff changeset
    51
    status = models.CharField(max_length = 2, choices = STATUS_CHOICES, default = "UP")
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    52
    tags = models.CharField(max_length = 200, blank = True)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    53
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    54
    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
    55
    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
    56
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    57
    credits = models.PositiveSmallIntegerField()
11
d28fcc644fbb implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents: 5
diff changeset
    58
    progress = models.PositiveSmallIntegerField(default = 0)
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    59
        
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    60
    mentors = models.ManyToManyField(User, related_name = "%(class)s_mentors")
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    61
    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
    62
    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
    63
    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
    64
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    65
    creation_datetime = models.DateTimeField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    66
    
5
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    67
    #is_claimable = models.BooleanField()
aea7e764c033 created views and templates for homepage,browse_task and added actions.
nishanth
parents: 2
diff changeset
    68
    
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    69
    ## 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
    70
    ## tasktype = "" ## "bugfix"/"enhancement"
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    71
    ## priority = "" ## "very urgent"/"urgent"
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
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    74
        return unicode(self.title)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    75
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    76
class Comment(models.Model):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    77
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    78
    task = models.ForeignKey('Task')
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    79
    data = models.TextField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    80
    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
    81
    creation_datetime = models.DateTimeField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    82
#    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
    83
#    deleted = models.BooleanField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    84
#    attachment = models.FileField(upload_to = UPLOADS_DIR, blank = True)
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
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    87
        return unicode(self.task.title)
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    88
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    89
class Credit(models.Model):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    90
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    91
    task = models.ForeignKey('Task')
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    92
    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
    93
    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
    94
    points = models.PositiveSmallIntegerField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    95
    given_time = models.DateTimeField()
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    96
    
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    97
    def __unicode__(self):
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
    98
        return unicode(self.task.title)
14
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
    99
        
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
   100
class Claim(models.Model):
2
3db830ff66ee added an app called taskapp and created the models.
nishanth
parents:
diff changeset
   101
    
14
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
   102
    task = models.ForeignKey('Task')
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
   103
    user = models.ForeignKey(User)
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
   104
    message = models.TextField()
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
   105
    creation_datetime = models.DateTimeField()
f2623fb8041a implemented add another mentor functionality to a task.
nishanth
parents: 11
diff changeset
   106