20 '"Todd Larsen" <tlarsen@google.com>', |
20 '"Todd Larsen" <tlarsen@google.com>', |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
22 ] |
22 ] |
23 |
23 |
24 from google.appengine.ext import db |
24 from google.appengine.ext import db |
25 from soc.models import base |
|
26 |
25 |
27 class Work(base.ModelWithFieldAttributes): |
26 from django.utils.translation import ugettext_lazy |
28 """Model of a Work created by one or more Authors. |
|
29 |
27 |
30 Work is a "base entity" of other more specific "works" created by "persons". |
28 import polymodel |
31 |
29 |
32 A Work entity participates in the following relationships implemented |
|
33 as a db.ReferenceProperty elsewhere in another db.Model: |
|
34 |
30 |
35 proposal), survey), documentation) |
31 class Work(polymodel.PolyModel): |
36 a 1:1 relationship with each entity containing a more specific type of |
32 """Model of a Work created by one or more Persons in Roles. |
37 "work". These relationships are represented explicitly in the other |
|
38 "work" models by a db.ReferenceProperty named 'work'. The |
|
39 collection_name argument to db.ReferenceProperty should be set to the |
|
40 singular of the entity model name of the other "work" class. The above |
|
41 relationship names correspond, respectively to these Models: |
|
42 Proposal, Survey, Documentation |
|
43 The relationships listed here are mutually exclusive. For example, |
|
44 a Work cannot be both a Proposal and a Survey at the same time. |
|
45 |
33 |
46 persons) a many:many relationship with Persons, stored in a separate |
34 Work is a "base entity" of other more specific "works" created by Persons |
47 WorksPersons model. See the WorksPersons model class for details. |
35 serving in "roles". |
|
36 |
|
37 authors) a many:many relationship with Roles, stored in a separate |
|
38 WorksAuthors model, used to represent authorship of the Work. See |
|
39 the WorksAuthors model class for details. |
48 |
40 |
49 reviews) a 1:many relationship between a Work and the zero or more |
41 reviews) a 1:many relationship between a Work and the zero or more |
50 Reviews of that Work. This relation is implemented as the 'reviews' |
42 Reviews of that Work. This relation is implemented as the 'reviews' |
51 back-reference Query of the Review model 'reviewed' reference. |
43 back-reference Query of the Review model 'reviewed' reference. |
52 """ |
44 """ |
53 |
45 |
54 #: Required field indicating the "title" of the work, which may have |
46 #: Required field indicating the "title" of the work, which may have |
55 #: different uses depending on the specific type of the work. Works |
47 #: different uses depending on the specific type of the work. Works |
56 #: can be indexed, filtered, and sorted by 'title'. |
48 #: can be indexed, filtered, and sorted by 'title'. |
57 title = db.StringProperty(required=True) |
49 title = db.StringProperty(required=True, |
|
50 verbose_name=ugettext_lazy('Title')) |
|
51 title.help_text = ugettext_lazy( |
|
52 'title of the document; often used in the window title') |
58 |
53 |
59 #: large, non-indexed text field used for different purposes, depending |
54 #: optional, indexed plain text field used for different purposes, |
60 #: on the specific type of the work. |
55 #: depending on the specific type of the work |
61 abstract = db.TextProperty() |
56 abstract = db.StringProperty(multiline=True) |
|
57 abstract.help_text = ugettext_lazy( |
|
58 'short abstract, summary, or snippet;' |
|
59 ' 500 characters or less, plain text displayed publicly') |
|
60 |
|
61 #: Required link name, appended to a "path" to form the document URL. |
|
62 #: The combined "path" and link name must be globally unique on the |
|
63 #: site (but, unlike some link names, a Work link name can be reused, |
|
64 #: as long as the combination with the preceding path is unique). |
|
65 link_name = db.StringProperty(required=True, |
|
66 verbose_name=ugettext_lazy('Link name')) |
|
67 link_name.help_text = ugettext_lazy('link name used in URLs') |
|
68 |
|
69 #: short name used in places such as the sidebar menu and breadcrumb trail |
|
70 #: (optional: title will be used if short_name is not present) |
|
71 short_name = db.StringProperty(verbose_name=ugettext_lazy('Short name')) |
|
72 short_name.help_text = ugettext_lazy( |
|
73 'short name used, for example, in the sidebar menu') |
|
74 |
|
75 #: date when the work was created |
|
76 created = db.DateTimeProperty(auto_now_add=True) |
|
77 |
|
78 #: date when the work was last modified |
|
79 modified = db.DateTimeProperty(auto_now=True) |