author | Sverre Rabbelier <srabbelier@gmail.com> |
Thu, 09 Apr 2009 22:04:47 +0000 | |
changeset 2137 | 3d5692ae414c |
parent 2074 | 5c75312566d5 |
child 2398 | 3ea483cf4d59 |
permissions | -rw-r--r-- |
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 |
import soc.models.linkable |
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 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
from django.utils.translation import ugettext as _ |
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 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
class Comment(soc.models.linkable.Linkable): |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
"""Model of a comment on a work. |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
|
1711
654c4fb617ea
Updated the docstring for the Comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1687
diff
changeset
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
""" |
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 |
#: 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
|
44 |
#: the user who provided that comment. |
1678
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
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
|
46 |
required=True, collection_name="commented") |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
#: The rich textual content of this comment |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
content = db.TextProperty(verbose_name=_('Content')) |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
#: 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
|
52 |
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
|
53 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
#: Date when the comment was added |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
created = db.DateTimeProperty(auto_now_add=True) |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
#: date when the work was last modified |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
modified = db.DateTimeProperty(auto_now=True) |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
|
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
# 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
|
61 |
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
|
62 |
required=False, |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
collection_name="modified_comments", |
80411f57f31a
Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
verbose_name=_('Modified by')) |