app/soc/models/comment.py
changeset 1678 80411f57f31a
child 1687 8203c805edc7
equal deleted inserted replaced
1677:b2cf6ad50a2a 1678:80411f57f31a
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2008 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """This module contains the comment Model."""
       
    18 
       
    19 __authors__ = [
       
    20   '"Matthew Wilkes" <matthew@matthewwilkes.co.uk>',
       
    21 ]
       
    22 
       
    23 from google.appengine.ext import db
       
    24 
       
    25 import soc.models.work
       
    26 import soc.models.user
       
    27 from soc.models import base
       
    28 import soc.models.linkable
       
    29 
       
    30 
       
    31 from django.utils.translation import ugettext as _
       
    32 
       
    33 
       
    34 class Comment(soc.models.linkable.Linkable):
       
    35   """Model of a comment on a work.
       
    36 
       
    37   A comment is associated with a Work, for example a Document or a Proposal,
       
    38   and with a user, the author.  There are two types of comment, public (i.e.
       
    39   visible to the student), or private (i.e. visible to programme/club staff).
       
    40   Neither type are visible to people who are not connected to the work being
       
    41   commented on.
       
    42   """
       
    43 
       
    44   #: A required many:1 relationship with a Work, where the comment entity
       
    45   #: provides additional textual information about the commented work.
       
    46   #: There is a backreference in Work called comments, which is a db.Query
       
    47   #: instance
       
    48   commented = db.ReferenceProperty(reference_class=soc.models.work.Work,
       
    49                                   required=False, collection_name="comments")
       
    50 
       
    51   #: A required many:1 relationship with a comment entity indicating
       
    52   #: the user who provided that comment.  There is a backreference in Work
       
    53   #: called comments, which is a db.Query instance.
       
    54   author = db.ReferenceProperty(reference_class=soc.models.user.User,
       
    55                                   required=True, collection_name="commented")
       
    56 
       
    57   #: The rich textual content of this comment
       
    58   content = db.TextProperty(verbose_name=_('Content'))
       
    59 
       
    60   #: Indicated if the comment should be visible to the appropriate student
       
    61   is_public = db.BooleanProperty(
       
    62     verbose_name=_('Public comment'))
       
    63 
       
    64   #: Date when the comment was added
       
    65   created = db.DateTimeProperty(auto_now_add=True)
       
    66 
       
    67   #: date when the work was last modified
       
    68   modified = db.DateTimeProperty(auto_now=True)
       
    69 
       
    70   # indicating wich user last modified the work. Used in displaying Work
       
    71   modified_by = db.ReferenceProperty(reference_class=soc.models.user.User,
       
    72                                      required=False,
       
    73                                      collection_name="modified_comments",
       
    74                                      verbose_name=_('Modified by'))