app/soc/models/comment.py
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 13 Aug 2009 14:02:22 -0700
changeset 2770 71a5a56cf29e
parent 2588 db306bbda381
permissions -rw-r--r--
Redone the acceptedStudentsExport functionality. The method has been renamed to exportStudentsWithProjects and retrieves the document_name and the new shipping address properties. Also it filters out all invalid projects or projects for wich the scope_path doesn't match the given scope_pa th_start. Also there is no more need to use the argument given to this method when adding the extra columns. The data is now prepared by one loop which uses the key present in the accepted_students dictionary for retrieving the data used by the extra columns.
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.user
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
import soc.models.linkable
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from django.utils.translation import ugettext as _
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
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
class Comment(soc.models.linkable.Linkable):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
  """Model of a comment on a work.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
1711
654c4fb617ea Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1687
diff changeset
    35
  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
    36
  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
    37
  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
    38
  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
    39
  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
    40
  """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
  #: 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
    43
  #: the user who provided that comment.
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
  author = db.ReferenceProperty(reference_class=soc.models.user.User,
2588
db306bbda381 Indention fixes and adding "reference_class=" in ReferenceProperty params.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2398
diff changeset
    45
                                required=True, collection_name="commented")
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
  #: The rich textual content of this comment
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
  content = db.TextProperty(verbose_name=_('Content'))
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
  #: 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
    51
  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
    52
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
  #: Date when the comment was added
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
  created = db.DateTimeProperty(auto_now_add=True)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
  #: date when the work was last modified
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
  modified = db.DateTimeProperty(auto_now=True)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
  # 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
    60
  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
    61
                                     required=False,
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
                                     collection_name="modified_comments",
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
                                     verbose_name=_('Modified by'))