app/soc/modules/ghop/models/comment.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 03 Oct 2009 21:49:08 +0200
changeset 3003 6a84c1ff5b5c
parent 2822 387a3b80df05
permissions -rw-r--r--
GHOP Comments do not need to be created by a User. We also have "system" messages.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     4
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     8
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    10
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    16
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    17
"""This module contains the GHOP specific Comment Model.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    18
"""
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    19
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    20
__authors__ = [
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    21
  '"Madhusudan.C.S" <madhusudancs@gmail.com>',
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    22
]
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    23
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    24
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    25
from google.appengine.ext import db
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    26
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    27
from django.utils.translation import ugettext
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    28
2789
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    29
import soc.models.base
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    30
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    31
import soc.modules.ghop.models.task
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    32
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    33
2789
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    34
class GHOPComment(soc.models.base.ModelWithFieldAttributes):
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    35
  """GHOP Comment model for tasks, extends the basic Comment model.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    36
  """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    37
2789
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    38
  #: The rich textual content of this comment
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    39
  content = db.TextProperty(required=False, verbose_name=ugettext('Content'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    40
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    41
  #: Property containing the human readable string that should be
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    42
  #: shown for the comment when something in the task changes, 
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    43
  #: code.google.com issue tracker style
2789
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    44
  changes = db.StringListProperty(required=True, default=[],
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    45
                                  verbose_name=ugettext('Changes in the task'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    46
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    47
  #: Property storing the status of the comment.
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    48
  #: valid: comment is visible to all
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    49
  #: invalid: comment is deleted, which is marked as invalid
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    50
  status = db.StringProperty(default='valid',
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    51
                             choices=['valid','invalid'],
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    52
                             verbose_name=ugettext('Status of this Comment'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    53
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    54
  #: A required many:1 relationship with a comment entity indicating
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    55
  #: the user who provided that comment.
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    56
  created_by = db.ReferenceProperty(reference_class=soc.models.user.User,
3003
6a84c1ff5b5c GHOP Comments do not need to be created by a User.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2822
diff changeset
    57
                                    required=False,
2789
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    58
                                    collection_name="commented_by")
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    59
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    60
  #: Date when the comment was added
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    61
  created_on = db.DateTimeProperty(auto_now_add=True)
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    62
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    63
  # indicating wich user last modified the work. Used in displaying Work
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    64
  modified_by = db.ReferenceProperty(reference_class=soc.models.user.User,
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    65
                                     required=False,
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    66
                                     collection_name="comment_modified_by",
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    67
                                     verbose_name=ugettext('Modified by'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    68
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    69
  #: date when the work was last modified
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    70
  modified_on = db.DateTimeProperty(auto_now=True)