author | Todd Larsen <tlarsen@google.com> |
Fri, 18 Jul 2008 18:22:23 +0000 | |
changeset 54 | 03e267d67478 |
parent 16 | soc/models/work.py@300f7606e100 |
child 181 | fdd29818a954 |
permissions | -rw-r--r-- |
16
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2 |
# |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
4 |
# |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
8 |
# |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
10 |
# |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
16 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
17 |
"""This module contains the Work Model.""" |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
18 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
19 |
__authors__ = [ |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
20 |
'"Todd Larsen" <tlarsen@google.com>', |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
22 |
] |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
23 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
24 |
from google.appengine.ext import db |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
25 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
26 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
27 |
class Work(db.Model): |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
28 |
"""Model of a Work created by one or more Authors. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
29 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
30 |
Work is a "base entity" of other more specific "works" created by "authors". |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
31 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
32 |
A Work entity participates in the following relationships implemented |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
33 |
as a db.ReferenceProperty elsewhere in another db.Model: |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
34 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
35 |
proposal), survey), documentation) |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
36 |
a 1:1 relationship with each entity containing a more specific type of |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
37 |
"work". These relationships are represented explicitly in the other |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
38 |
"work" models by a db.ReferenceProperty named 'work'. The |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
39 |
collection_name argument to db.ReferenceProperty should be set to the |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
40 |
singular of the entity model name of the other "work" class. The above |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
41 |
relationship names correspond, respectively to these Models: |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
42 |
Proposal, Survey, Documentation |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
43 |
The relationships listed here are mutually exclusive. For example, |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
44 |
a Work cannot be both a Proposal and a Survey at the same time. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
45 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
46 |
authors) a many:many relationship with Authors, stored in a separate |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
47 |
WorksAuthors model. See the WorksAuthors model class for details. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
48 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
49 |
reviews) a 1:many relationship between a Work and the zero or more |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
50 |
Reviews of that Work. This relation is implemented as the 'reviews' |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
51 |
back-reference Query of the Review model 'reviewed' reference. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
52 |
""" |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
53 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
54 |
#: Required field indicating the "title" of the work, which may have |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
55 |
#: different uses depending on the specific type of the work. Works |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
56 |
#: can be indexed, filtered, and sorted by 'title'. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
57 |
title = db.StringProperty(required=True) |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
58 |
|
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
59 |
#: large, non-indexed text field used for different purposes, depending |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
60 |
#: on the specific type of the work. |
300f7606e100
Initial definition of the Work Model.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
61 |
abstract = db.TextProperty() |