app/soc/models/comment.py
author Daniel Bentley <dbentley@google.com>
Wed, 01 Apr 2009 10:24:26 +0000
changeset 2048 236f37777764
parent 1874 35b65c11d6a1
child 2074 5c75312566d5
permissions -rw-r--r--
A new model for seeding the database that makes it easier to seed many entities. new_seed_many is a function that seeds in a different way. Instead of using redirects, it figures out what the high-water mark of seeding is and proceeds from there. This is obviously a half-way step. I've talked about it with Sverre; I think I've mentioned it to others. If we like it, I volunteer to convert everything to this model (I think there will be savings and simplification when we're all the way). If we don't like it, I'll back out this code. But I'll also be sad, because this makes it a lot easier to add many entities (which I care about because I'm trying to fix list view for that many entities). Patch by: Dan Bentley
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""This module contains the comment Model."""
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
__authors__ = [
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
  '"Matthew Wilkes" <matthew@matthewwilkes.co.uk>',
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
]
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
from google.appengine.ext import db
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
import soc.models.work
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
import soc.models.user
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from soc.models import base
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
import soc.models.linkable
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
from django.utils.translation import ugettext as _
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
class Comment(soc.models.linkable.Linkable):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
  """Model of a comment on a work.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
1711
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    37
  A comment is usually associated with a Work or a Proposal,
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    38
  for example a Document or a Student Proposal, and with a user, the author.
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    39
  There are two types of comment, public (i.e. visible to the student), 
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    40
  or private (i.e. visible to programme/club staff). Neither type are 
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    41
  visible to people who are not connected to the work being commented on.
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
  """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
  #: A required many:1 relationship with a comment entity indicating
1711
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    45
  #: the user who provided that comment.
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
  author = db.ReferenceProperty(reference_class=soc.models.user.User,
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
                                  required=True, collection_name="commented")
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
  #: The rich textual content of this comment
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
  content = db.TextProperty(verbose_name=_('Content'))
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
  #: Indicated if the comment should be visible to the appropriate student
1874
35b65c11d6a1 Some minor style fixes.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1711
diff changeset
    53
  is_public = db.BooleanProperty(verbose_name=_('Public comment'))
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
  #: Date when the comment was added
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
  created = db.DateTimeProperty(auto_now_add=True)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
  #: date when the work was last modified
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
  modified = db.DateTimeProperty(auto_now=True)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
  # indicating wich user last modified the work. Used in displaying Work
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
  modified_by = db.ReferenceProperty(reference_class=soc.models.user.User,
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
                                     required=False,
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
                                     collection_name="modified_comments",
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
                                     verbose_name=_('Modified by'))