pytask/taskapp/models.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sat, 05 Feb 2011 03:24:52 +0530
changeset 559 96e8e65a3738
parent 527 c894de293216
permissions -rwxr-xr-x
Display Pynts on task/textbook description page. Also make some style fixes.
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
527
c894de293216 A task should be able to have sub tasks. So sub tasks are linked to their parents.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 494
diff changeset
    30
    parent = models.ForeignKey('self', blank=True, null=True,
c894de293216 A task should be able to have sub tasks. So sub tasks are linked to their parents.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 494
diff changeset
    31
                               related_name="children_tasks")
c894de293216 A task should be able to have sub tasks. So sub tasks are linked to their parents.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 494
diff changeset
    32
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    33
    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
    34
      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
    35
      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
    36
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    37
    desc = models.TextField(verbose_name=u"Description")
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    38
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    39
    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
    40
                              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
    41
                              default="Unpublished")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    42
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    43
    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
    44
                          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
    45
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    46
    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
    47
      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
    48
341
e7302ae73e53 added blank=true whereever required
Nishanth Amuluru <nishanth@fossee.in>
parents: 331
diff changeset
    49
    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
    50
                                   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
    51
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    52
    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
    53
                                    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
    54
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    55
    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
    56
                                       related_name="reviewing_tasks")
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    57
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    58
    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
    59
                                           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
    60
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    61
    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
    62
                                            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
    63
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
    64
    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
    65
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    66
    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
    67
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
    68
    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
    69
                                         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
    70
307
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    71
    def __unicode__(self):
c6bca38c1cbf Added buildout stuff and made changes accordingly
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
    72
        return unicode(self.title)
322
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
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    75
class TaskComment(models.Model):
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    76
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    77
    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
    78
437
b5a93feac34d Add label to the comment form field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 403
diff changeset
    79
    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
    80
341
e7302ae73e53 added blank=true whereever required
Nishanth Amuluru <nishanth@fossee.in>
parents: 331
diff changeset
    81
    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
    82
                                     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
    83
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    84
    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
    85
                                   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
    86
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
    87
    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
    88
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    89
    is_deleted = models.BooleanField(default=False)
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    90
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
    91
    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
    92
                                         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
    93
322
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    94
    def __unicode__(self):
2120e853f10b added comment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 320
diff changeset
    95
        return unicode(self.task.title)
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
    96
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
    97
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
    98
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
    99
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   100
    task = models.ForeignKey('Task', related_name="claims")
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   101
            
341
e7302ae73e53 added blank=true whereever required
Nishanth Amuluru <nishanth@fossee.in>
parents: 331
diff changeset
   102
    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
   103
                                   related_name="claimed_claims")
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   104
    proposal = models.TextField()
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   105
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
   106
    claim_datetime = models.DateTimeField(auto_now_add=True)
323
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   107
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   108
    def __unicode__(self):
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   109
        return unicode(self.task.title)
4ca185390379 added claim model
Nishanth Amuluru <nishanth@fossee.in>
parents: 322
diff changeset
   110
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   111
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   112
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
   113
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   114
    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
   115
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   116
    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
   117
                                     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
   118
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   119
    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
   120
                                    related_name="approved_reports")
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   121
383
4252da60a4ef submit report works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 375
diff changeset
   122
    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
   123
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
   124
    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
   125
                               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
   126
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   127
    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
   128
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   129
    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
   130
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
   131
    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
   132
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
   133
    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
   134
                                         default=datetime.now())
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   135
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   136
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   137
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
   138
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   139
    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
   140
            
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   141
    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
   142
346
8ffc889a3b37 renamed all the related_name fields for better readability
Nishanth Amuluru <nishanth@fossee.in>
parents: 342
diff changeset
   143
    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
   144
                                     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
   145
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   146
    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
   147
                                   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
   148
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
   149
    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
   150
324
2f20098f2da3 created work report model and reportcomment model
Nishanth Amuluru <nishanth@fossee.in>
parents: 323
diff changeset
   151
    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
   152
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
   153
    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
   154
                                         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
   155
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   156
375
40f1ef7a46d8 added admin files
Nishanth Amuluru <nishanth@fossee.in>
parents: 370
diff changeset
   157
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
   158
    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
   159
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   160
    pynts = models.PositiveIntegerField(default=0, help_text="No.of pynts")
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   161
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
   162
    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
   163
                                     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
   164
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   165
    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
   166
                                     related_name="requested_for_pynts")
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   167
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   168
    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
   169
                                    related_name="responded_requests")
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   170
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   171
    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
   172
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   173
    remarks = models.CharField(max_length=100, blank=True,
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   174
                               help_text="Reason in case of rejection")
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   175
            
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
   176
    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
   177
328
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   178
    is_responded = models.BooleanField(default=False)
437af7ad6cb9 added request pynts model
Nishanth Amuluru <nishanth@fossee.in>
parents: 327
diff changeset
   179
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
   180
    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
   181
                                         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
   182
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   183
493
096ba514790b Adding deprecation warning to Textbook model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 491
diff changeset
   184
# 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
   185
class TextBook(models.Model):
494
066deed9fba0 Added additional text message for the deprecated model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 493
diff changeset
   186
    """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
   187
    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
   188
    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
   189
    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
   190
    """
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   191
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
   192
    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
   193
368
a4fa11b2cb5c add textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 351
diff changeset
   194
    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
   195
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   196
    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
   197
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   198
    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
   199
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   200
    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
   201
                                    related_name="approved_textbooks")
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   202
438
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   203
    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
   204
                              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
   205
                              default="Unpublished")
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   206
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
   207
    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
   208
f861c753e55a Use the right names for the roles and all other choices.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 437
diff changeset
   209
    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
   210
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
   211
    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
   212
                                         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
   213
330
b92347d24557 Added textbook model and made a few small changes
Nishanth Amuluru <nishanth@fossee.in>
parents: 328
diff changeset
   214
326
8165274cafa1 eanbled taskapp and registered task model into tagging
Nishanth Amuluru <nishanth@fossee.in>
parents: 325
diff changeset
   215
tagging.register(Task)
370
1be4a3c09a47 view textbook works fine
Nishanth Amuluru <nishanth@fossee.in>
parents: 368
diff changeset
   216
tagging.register(TextBook)