app/soc/modules/ghop/models/comment.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Mon, 24 Aug 2009 20:08:35 +0530
changeset 2789 259ce59acaf7
parent 2397 d943fa182fae
child 2822 387a3b80df05
permissions -rw-r--r--
Changed GHOPComment model to inherit from base model. All the properties are specific to the GHOPComment model. The GHOPComment model is also made ID based. Changes changes property from StringProperty to StringListProperty.
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
  #: Reference property to the task entity under which the comment
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    55
  #: is scoped 
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    56
  scope = db.ReferenceProperty(
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    57
      reference_class=soc.modules.ghop.models.task.GHOPTask,
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    58
      required=True, collection_name='comment_scopes',
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    59
      verbose_name=ugettext('Comment Scope'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    60
  scope.help_text = ugettext(
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    61
      'Reference to the task entity under which this comment was posted.')
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
  #: Hidden (not displayed to users or editable in forms) cache of the string
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    64
  #: representation of the transitive closure of scopes, for use in URLs.
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    65
  scope_path = db.StringProperty(required=False,
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    66
                                 verbose_name=ugettext('Scope path'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    67
  scope_path.help_text = ugettext(
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    68
      'Cache of the string form of the entity scope.')
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    69
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    70
  #: 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
    71
  #: 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
    72
  created_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
    73
                                    required=True,
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    74
                                    collection_name="commented_by")
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    75
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    76
  #: 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
    77
  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
    78
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    79
  # 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
    80
  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
    81
                                     required=False,
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    82
                                     collection_name="comment_modified_by",
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    83
                                     verbose_name=ugettext('Modified by'))
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    84
259ce59acaf7 Changed GHOPComment model to inherit from base model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2397
diff changeset
    85
  #: 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
    86
  modified_on = db.DateTimeProperty(auto_now=True)