pytask/taskapp/models.py
author Nishanth Amuluru <nishanth@fossee.in>
Sat, 08 Jan 2011 21:13:56 +0530
changeset 89 539e7a0b5d86
parent 88 8165274cafa1
child 90 437af7ad6cb9
permissions -rwxr-xr-x
Included the missing imports
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     1
from django.db import models
89
539e7a0b5d86 Included the missing imports
Nishanth Amuluru <nishanth@fossee.in>
parents: 88
diff changeset
     2
from django.contrib.auth.models import User
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     3
88
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 87
diff changeset
     4
import tagging
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 87
diff changeset
     5
from tagging.fields import TagField
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 87
diff changeset
     6
82
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
     7
STATUS_CHOICES = (
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
     8
        ("UP", "Unpublished"),
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
     9
        ("OP", "Open"),
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    10
        ("LO", "Locked"),
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    11
        ("WR", "Working"),
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    12
        ("CD", "Closed"),
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    13
        ("DL", "Deleted"),
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    14
        ("CM", "Completed"))
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    15
89
539e7a0b5d86 Included the missing imports
Nishanth Amuluru <nishanth@fossee.in>
parents: 88
diff changeset
    16
UPLOADS_DIR = "./pytask/static/uploads"
539e7a0b5d86 Included the missing imports
Nishanth Amuluru <nishanth@fossee.in>
parents: 88
diff changeset
    17
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    18
class Task(models.Model):
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    19
    
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    20
    uniq_key = models.CharField(max_length = 10, unique = True)
82
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    21
    title = models.CharField(max_length = 100, verbose_name = u"Title", 
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    22
                             help_text = u"Keep it simple and below 100 chars.")
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    23
    desc = models.TextField(verbose_name = u"Description")
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    24
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    25
    status = models.CharField(max_length = 2, choices = STATUS_CHOICES, default = "UP")
82
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    26
    tags_field = TagField(verbose_name = u"Tags", 
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    27
                          help_text = u"Give tags seperated by commas") 
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    28
    
82
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    29
    pynts = models.PositiveSmallIntegerField(help_text = u"No.of pynts a user \
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    30
                                             gets on completing the task")
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    31
    created_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
82
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    32
    approved_by = models.ForeignKey(User, related_name = "%(class)s_approved_by")
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    33
    reviewers = models.ManyToManyField(User, related_name = "%(class)s_reviewers")
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    34
82
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    35
    claimed_users = models.ManyToManyField(User, blank = True, 
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    36
                                           related_name = "%(class)s_claimed_users")
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    37
    selected_users = models.ManyToManyField(User, blank = True, 
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 69
diff changeset
    38
                                            related_name = "%(class)s_selected_users")
69
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    39
    
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    40
    creation_datetime = models.DateTimeField()
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    41
    
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    42
    def __unicode__(self):
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    43
        return unicode(self.title)
84
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    44
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    45
class TaskComment(models.Model):
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    46
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    47
    uniq_key = models.CharField(max_length = 10, unique = True)
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    48
    task = models.ForeignKey('Task', related_name = "%(class)s_task")
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    49
            
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    50
    data = models.TextField()
85
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    51
    commented_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
84
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    52
    deleted_by = models.ForeignKey(User, null = True, blank = True,
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    53
                                   related_name = "%(class)s_deleted_by")
85
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    54
    comment_datetime = models.DateTimeField()
84
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    55
    is_deleted = models.BooleanField(default=False)
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    56
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    57
    def __unicode__(self):
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 82
diff changeset
    58
        return unicode(self.task.title)
85
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    59
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    60
class TaskClaim(models.Model):
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    61
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    62
    uniq_key = models.CharField(max_length = 10, unique = True)
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    63
    task = models.ForeignKey('Task', related_name = "%(class)s_task")
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    64
            
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    65
    claimed_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    66
    proposal = models.TextField()
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    67
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    68
    comment_datetime = models.DateTimeField()
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    69
    is_deleted = models.BooleanField(default=False)
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    70
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    71
    def __unicode__(self):
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    72
        return unicode(self.task.title)
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 84
diff changeset
    73
86
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    74
class WorkReport(models.Model):
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    75
87
8f8bd185aacf Added uniq_key to report model
Nishanth Amuluru <nishanth@fossee.in>
parents: 86
diff changeset
    76
    uniq_key = models.CharField(max_length = 10, unique = True)
86
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    77
    task = models.ForeignKey(Task, related_name = "%(class)s_task")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    78
    submitted_by = models.ForeignKey(User, 
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    79
                                     related_name = "%(class)s_submitted_by")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    80
    approved_by = models.ForeignKey(User, 
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    81
                                    related_name = "%(class)s_approved_by")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    82
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    83
    data = models.TextField()
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    84
    summary = models.CharField(max_length=100, verbose_name="Summary",
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    85
                               help_text="A one line summary")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    86
    attachment = models.FileField(upload_to = UPLOADS_DIR)
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    87
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    88
    revision = models.PositiveIntegerField(default=0)
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    89
    submitted_at = models.DateTimeField()
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    90
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    91
class ReportComment(models.Model):
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    92
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    93
    uniq_key = models.CharField(max_length = 10, unique = True)
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    94
    report = models.ForeignKey('WorkReport', related_name = "%(class)s_report")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    95
            
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    96
    data = models.TextField()
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    97
    commented_by = models.ForeignKey(User, related_name = "%(class)s_created_by")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    98
    deleted_by = models.ForeignKey(User, null = True, blank = True,
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
    99
                                   related_name = "%(class)s_deleted_by")
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
   100
    comment_datetime = models.DateTimeField()
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 85
diff changeset
   101
    is_deleted = models.BooleanField(default=False)
88
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 87
diff changeset
   102
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 87
diff changeset
   103
tagging.register(Task)