author | Lennard de Rijk <ljvderijk@gmail.com> |
Thu, 02 Jul 2009 15:40:37 +0200 | |
changeset 2488 | 69ce84f4c1da |
parent 1416 | 6c94a1531ead |
child 2957 | f6515daaf000 |
permissions | -rw-r--r-- |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
# |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
17 |
"""This module contains the Document Model.""" |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
|
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
__authors__ = [ |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
1091
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
22 |
] |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
24 |
|
1091
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
25 |
from google.appengine.ext import db |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
26 |
|
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
27 |
from django.utils.translation import ugettext |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
28 |
|
1416
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
29 |
import soc.models.linkable |
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
30 |
import soc.models.work |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
31 |
|
181
fdd29818a954
Remove Author model (use Person instead). Update models after removing Author. Add new Sponsor, Organization models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
141
diff
changeset
|
32 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
33 |
class Document(soc.models.work.Work): |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
34 |
"""Model of a Document. |
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
35 |
|
206
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
36 |
Document is used for things like FAQs, front page text, etc. |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
37 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
38 |
The specific way that the properties and relations inherited from Work |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
39 |
are used with a Document are described below. |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
40 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
41 |
work.title: the title of the Document |
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
42 |
|
832335761384
Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents:
181
diff
changeset
|
43 |
work.reviews: reviews of the Document by Reviewers |
141
e120c24b89e2
Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
44 |
|
351
b37fc4c1e189
Eliminate the Work.abstract property and move the Document.content property
Todd Larsen <tlarsen@google.com>
parents:
342
diff
changeset
|
45 |
work.content: the rich-text contents of the Document |
b37fc4c1e189
Eliminate the Work.abstract property and move the Document.content property
Todd Larsen <tlarsen@google.com>
parents:
342
diff
changeset
|
46 |
""" |
936
b3e1e0c9649c
Enable pick links for all the references we have
Sverre Rabbelier <srabbelier@gmail.com>
parents:
385
diff
changeset
|
47 |
|
b3e1e0c9649c
Enable pick links for all the references we have
Sverre Rabbelier <srabbelier@gmail.com>
parents:
385
diff
changeset
|
48 |
URL_NAME = 'document' |
1310
a3f654f30fbc
Make document ACL's a constant
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
49 |
DOCUMENT_ACCESS = ['admin', 'restricted', 'member', 'user'] |
936
b3e1e0c9649c
Enable pick links for all the references we have
Sverre Rabbelier <srabbelier@gmail.com>
parents:
385
diff
changeset
|
50 |
|
1095
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
51 |
#: field storing the prefix of this document |
1134
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
52 |
prefix = db.StringProperty(default='user', required=True, |
1262
e2e5b7798746
Changed document to also filter on the prefix when getting the documents for a scope.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1191
diff
changeset
|
53 |
choices=['site', 'club', 'sponsor', 'program', 'org', 'user'], |
1095
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
54 |
verbose_name=ugettext('Prefix')) |
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
55 |
prefix.help_text = ugettext( |
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
56 |
'Indicates the prefix of the document,' |
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
57 |
' determines which access scheme is used.') |
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
58 |
|
1134
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
59 |
#: field storing the required access to read this document |
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
60 |
read_access = db.StringProperty(default='public', required=True, |
1310
a3f654f30fbc
Make document ACL's a constant
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
61 |
choices=DOCUMENT_ACCESS + ['public'], |
1134
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
62 |
verbose_name=ugettext('Read Access')) |
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
63 |
read_access.help_text = ugettext( |
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
64 |
'Indicates the state of the document, ' |
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
65 |
'determines the access scheme.') |
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
66 |
|
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
67 |
#: field storing the required access to write to this document |
1191
bb530ca58bc5
Fixed default value for write_access in Document model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1141
diff
changeset
|
68 |
write_access = db.StringProperty(default='admin', required=True, |
1310
a3f654f30fbc
Make document ACL's a constant
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
69 |
choices=DOCUMENT_ACCESS, |
1134
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
70 |
verbose_name=ugettext('Write Access')) |
493e7b5d3ab2
Final changes to the document model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1095
diff
changeset
|
71 |
write_access.help_text = ugettext( |
1095
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
72 |
'Indicates the state of the document, ' |
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
73 |
'determines the access scheme.') |
0122dc66e5d2
Add access control to document model and view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1091
diff
changeset
|
74 |
|
1091
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
75 |
#: field storing whether a link to the Document should be featured in |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
76 |
#: the sidebar menu (and possibly elsewhere); FAQs, Terms of Service, |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
77 |
#: and the like are examples of "featured" Document |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
78 |
is_featured = db.BooleanProperty( |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
79 |
verbose_name=ugettext('Is Featured')) |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
80 |
is_featured.help_text = ugettext( |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
81 |
'Field used to indicate if a Work should be featured, for example,' |
0e648c690bb7
Moved is_featured property to Document
Sverre Rabbelier <srabbelier@gmail.com>
parents:
936
diff
changeset
|
82 |
' in the sidebar menu.') |
1416
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
83 |
|
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
84 |
#: Reference to Document containing the contents of the "/home" page |
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
85 |
home_for = db.ReferenceProperty( |
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
86 |
reference_class=soc.models.linkable.Linkable, |
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
87 |
collection_name='home_docs') |
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
88 |
home_for.help_text = ugettext( |
6c94a1531ead
Add an home_for reference property
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1310
diff
changeset
|
89 |
'The Precense this document is the home document for.') |