3 # Copyright 2008 the Melange authors.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 """This module contains the Work Model."""
20 '"Todd Larsen" <tlarsen@google.com>',
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>',
25 from google
.appengine
.ext
import db
27 from django
.utils
.translation
import ugettext
29 import soc
.models
.linkable
30 import soc
.models
.user
33 class Work(soc
.models
.linkable
.Linkable
):
34 """Model of a Work created by one or more Persons in Roles.
36 Work is a "base entity" of other more specific "works" created by Persons
39 reviews) a 1:many relationship between a Work and the zero or more
40 Reviews of that Work. This relation is implemented as the 'reviews'
41 back-reference Query of the Review model 'reviewed' reference.
44 #: Required 1:1 relationship indicating the User who initially authored the
45 #: Work (this relationship is needed to keep track of lifetime document
46 #: creation limits, used to prevent spamming, etc.).
47 author
= db
.ReferenceProperty(reference_class
=soc
.models
.user
.User
,
49 collection_name
="created_documents",
50 verbose_name
=ugettext('Created by'))
52 #: Required field indicating the "title" of the work, which may have
53 #: different uses depending on the specific type of the work. Works
54 #: can be indexed, filtered, and sorted by 'title'.
55 title
= db
.StringProperty(required
=True,
56 verbose_name
=ugettext('Title'))
57 title
.help_text
= ugettext(
58 'title of the document; often used in the window title')
60 #: short name used in places such as the sidebar menu and breadcrumb trail
61 #: (optional: title will be used if short_name is not present)
62 short_name
= db
.StringProperty(verbose_name
=ugettext('Short name'))
63 short_name
.help_text
= ugettext(
64 'short name used, for example, in the sidebar menu')
66 #: Required db.TextProperty containing the contents of the Work.
67 #: The content is only to be displayed to Persons in Roles eligible to
68 #: view them (which may be anyone, for example, with the site front page).
69 content
= db
.TextProperty(verbose_name
=ugettext('Content'))
71 #: date when the work was created
72 created
= db
.DateTimeProperty(auto_now_add
=True)
74 #: date when the work was last modified
75 modified
= db
.DateTimeProperty(auto_now
=True)
77 # indicating wich user last modified the work. Used in displaying Work
78 modified_by
= db
.ReferenceProperty(reference_class
=soc
.models
.user
.User
,
80 collection_name
="modified_documents",
81 verbose_name
=ugettext('Modified by'))
84 """Alias 'title' Property as 'name' for use in common templates.