pytask/taskapp/models.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Thu, 20 Jan 2011 17:46:49 +0530
changeset 501 b84d6a1d4603
parent 494 066deed9fba0
child 527 c894de293216
permissions -rwxr-xr-x
Change all the queries to Textbook model to Tasks. Since Textbook model is deprecated now, implemented the changes in the views to query respected queries and make corresponding changes in the views.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
     1
from datetime import datetime
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
     2
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     3
from django.db import models
327
539e7a0b5d86 Included the missing imports
Nishanth Amuluru <nishanth@fossee.in>
parents: 326
diff changeset
     4
from django.contrib.auth.models import User
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     5
326
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 325
diff changeset
     6
import tagging
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 325
diff changeset
     7
from tagging.fields import TagField
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 325
diff changeset
     8
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
     9
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
    10
TASK_STATUS_CHOICES = (
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    11
        ("Unpublished", "Unpublished"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    12
        ("Open", "Open"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    13
        ("Locked", "Locked"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    14
        ("Working", "Working"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    15
        ("Closed", "Closed"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    16
        ("Deleted", "Deleted"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    17
        ("Completed", "Completed"))
320
285320d3063c finalised the task model
Nishanth Amuluru <nishanth@fossee.in>
parents: 307
diff changeset
    18
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
    19
TB_STATUS_CHOICES = (
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    20
    ("Unpublished", "Unpublished"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    21
    ("Open", "Open"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    22
    ("All tasks have users selected", "All tasks have users selected"),
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    23
    ("Completed", "Completed"))
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
    24
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    25
UPLOADS_DIR = "/pytask/static/uploads"
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    26
327
539e7a0b5d86 Included the missing imports
Nishanth Amuluru <nishanth@fossee.in>
parents: 326
diff changeset
    27
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    28
class Task(models.Model):
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    29
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    30
    title = models.CharField(
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    31
      max_length=1024, verbose_name=u"Title",
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    32
      help_text=u"Keep it simple and below 100 chars.")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    33
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    34
    desc = models.TextField(verbose_name=u"Description")
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    35
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    36
    status = models.CharField(max_length=255,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    37
                              choices=TASK_STATUS_CHOICES,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    38
                              default="Unpublished")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    39
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    40
    tags_field = TagField(verbose_name=u"Tags", 
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    41
                          help_text=u"Give tags separated by commas") 
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    42
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    43
    pynts = models.PositiveSmallIntegerField(
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    44
      help_text=u"Number of Pynts a user gets on completing the task")
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    45
341
e7302ae73e53 added blank=true whereever required
Nishanth Amuluru <nishanth@fossee.in>
parents: 331
diff changeset
    46
    created_by = models.ForeignKey(User,
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    47
                                   related_name="created_tasks")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    48
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    49
    approved_by = models.ForeignKey(User, blank=True, null=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    50
                                    related_name="approved_tasks")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    51
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    52
    reviewers = models.ManyToManyField(User, blank=True, null=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    53
                                       related_name="reviewing_tasks")
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    54
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    55
    claimed_users = models.ManyToManyField(User, blank=True, null=True, 
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    56
                                           related_name="claimed_tasks")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    57
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    58
    selected_users = models.ManyToManyField(User, blank=True, null=True, 
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    59
                                            related_name="selected_tasks")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    60
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    61
    creation_datetime = models.DateTimeField(auto_now_add=True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    62
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    63
    approval_datetime = models.DateTimeField(blank=True, null=True)
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    64
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    65
    last_modified = models.DateTimeField(auto_now=True,
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    66
                                         default=datetime.now())
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    67
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    68
    def __unicode__(self):
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    69
        return unicode(self.title)
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    70
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    71
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    72
class TaskComment(models.Model):
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    73
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    74
    task = models.ForeignKey('Task', related_name="comments")
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    75
437
b5a93feac34d Add label to the comment form field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    76
    data = models.TextField(verbose_name='Comment')
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    77
341
e7302ae73e53 added blank=true whereever required
Nishanth Amuluru <nishanth@fossee.in>
parents: 331
diff changeset
    78
    commented_by = models.ForeignKey(User,
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    79
                                     related_name="commented_taskcomments")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    80
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    81
    deleted_by = models.ForeignKey(User, null=True, blank=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    82
                                   related_name="deleted_taskcomments")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    83
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    84
    comment_datetime = models.DateTimeField(auto_now_add=True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    85
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    86
    is_deleted = models.BooleanField(default=False)
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    87
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    88
    last_modified = models.DateTimeField(auto_now=True,
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    89
                                         default=datetime.now())
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
    90
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    91
    def __unicode__(self):
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    92
        return unicode(self.task.title)
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
    93
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    94
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
    95
class TaskClaim(models.Model):
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    96
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    97
    task = models.ForeignKey('Task', related_name="claims")
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
    98
            
341
e7302ae73e53 added blank=true whereever required
Nishanth Amuluru <nishanth@fossee.in>
parents: 331
diff changeset
    99
    claimed_by = models.ForeignKey(User,
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   100
                                   related_name="claimed_claims")
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   101
    proposal = models.TextField()
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   102
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   103
    claim_datetime = models.DateTimeField(auto_now_add=True)
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   104
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   105
    def __unicode__(self):
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   106
        return unicode(self.task.title)
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   107
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   108
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   109
class WorkReport(models.Model):
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   110
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   111
    task = models.ForeignKey(Task, related_name="reports")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   112
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   113
    submitted_by = models.ForeignKey(User, null=True, blank=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   114
                                     related_name="submitted_reports")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   115
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   116
    approved_by = models.ForeignKey(User, null=True, blank=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   117
                                    related_name="approved_reports")
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   118
383
4252da60a4ef submit report works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 375
diff changeset
   119
    data = models.TextField(verbose_name="Report")
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   120
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   121
    summary = models.CharField(max_length=1024, verbose_name="Summary",
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   122
                               help_text="A one line summary")
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   123
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   124
    attachment = models.FileField(upload_to=UPLOADS_DIR)
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   125
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   126
    revision = models.PositiveIntegerField(default=0)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   127
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   128
    submitted_at = models.DateTimeField(auto_now_add=True)
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   129
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   130
    last_modified = models.DateTimeField(auto_now=True,
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   131
                                         default=datetime.now())
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   132
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   133
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   134
class ReportComment(models.Model):
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   135
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   136
    report = models.ForeignKey('WorkReport', related_name="%(class)s_report")
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   137
            
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   138
    data = models.TextField()
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   139
346
8ffc889a3b37 renamed all the related_name fields for better readability
Nishanth Amuluru <nishanth@fossee.in>
parents: 342
diff changeset
   140
    commented_by = models.ForeignKey(User, 
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   141
                                     related_name="commented_reportcomments")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   142
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   143
    deleted_by = models.ForeignKey(User, null=True, blank=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   144
                                   related_name="deleted_reportcomments")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   145
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   146
    comment_datetime = models.DateTimeField(auto_now_add=True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   147
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   148
    is_deleted = models.BooleanField(default=False)
326
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 325
diff changeset
   149
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   150
    last_modified = models.DateTimeField(auto_now=True,
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   151
                                         default=datetime.now())
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   152
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   153
375
40f1ef7a46d8 added admin files
Nishanth Amuluru <nishanth@fossee.in>
parents: 370
diff changeset
   154
class PyntRequest(models.Model):
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   155
    task = models.ForeignKey(Task, related_name="pynt_requests")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   156
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   157
    pynts = models.PositiveIntegerField(default=0, help_text="No.of pynts")
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   158
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   159
    requested_by = models.ForeignKey(User,
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   160
                                     related_name="requested_by_pynts")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   161
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   162
    requested_for = models.ForeignKey(User, 
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   163
                                     related_name="requested_for_pynts")
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   164
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   165
    responded_by = models.ForeignKey(User, null=True, blank=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   166
                                    related_name="responded_requests")
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   167
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   168
    is_accepted = models.BooleanField(default=False)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   169
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   170
    remarks = models.CharField(max_length=100, blank=True,
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   171
                               help_text="Reason in case of rejection")
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   172
            
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   173
    request_datetime = models.DateTimeField(auto_now_add=True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   174
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   175
    is_responded = models.BooleanField(default=False)
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   176
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   177
    last_modified = models.DateTimeField(auto_now=True,
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   178
                                         default=datetime.now())
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   179
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   180
493
096ba514790b Adding deprecation warning to Textbook model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 491
diff changeset
   181
# THIS MODEL IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS.
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   182
class TextBook(models.Model):
494
066deed9fba0 Added additional text message for the deprecated model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 493
diff changeset
   183
    """THIS MODEL IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS
066deed9fba0 Added additional text message for the deprecated model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 493
diff changeset
   184
    SINCE THIS MODEL IS A MERE COPY OF Task MODEL.
066deed9fba0 Added additional text message for the deprecated model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 493
diff changeset
   185
    Whatever this model tries to do can be done on views side thereby
066deed9fba0 Added additional text message for the deprecated model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 493
diff changeset
   186
    keeping our database as normalized as possible avoiding redundancies.
493
096ba514790b Adding deprecation warning to Textbook model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 491
diff changeset
   187
    """
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   188
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   189
    name = models.CharField(max_length=1024)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   190
368
a4fa11b2cb5c add textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 351
diff changeset
   191
    chapters = models.ManyToManyField(Task, related_name="textbooks")
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   192
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   193
    tags_field = TagField(verbose_name="Tags")
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   194
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   195
    created_by = models.ForeignKey(User, related_name="created_textbooks")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   196
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   197
    approved_by = models.ForeignKey(User, null=True, blank=True,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   198
                                    related_name="approved_textbooks")
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   199
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   200
    status = models.CharField(max_length=255,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   201
                              choices=TB_STATUS_CHOICES,
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   202
                              default="Unpublished")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   203
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   204
    creation_datetime = models.DateTimeField(auto_now_add=True)
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   205
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   206
    approval_datetime = models.DateTimeField(blank=True, null=True)
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   207
491
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   208
    last_modified = models.DateTimeField(auto_now=True,
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   209
                                         default=datetime.now())
630719435d16 Add last_modified field to most of the models and make other necessary model changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 438
diff changeset
   210
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   211
326
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 325
diff changeset
   212
tagging.register(Task)
370
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 368
diff changeset
   213
tagging.register(TextBook)