author | Todd Larsen <tlarsen@google.com> |
Wed, 01 Oct 2008 00:35:29 +0000 | |
changeset 221 | 9cca97feadaa |
parent 181 | fdd29818a954 |
child 244 | da80c6519eea |
permissions | -rw-r--r-- |
20
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""This module contains the Answer Model.""" |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
__authors__ = [ |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
'"Todd Larsen" <tlarsen@google.com>', |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
from google.appengine.ext import db |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
from soc import models |
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:
54
diff
changeset
|
27 |
from soc.models import base |
20
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
import soc.models.question |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
import soc.models.review |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@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:
54
diff
changeset
|
32 |
class Answer(base.ModelWithFieldAttributes): |
20
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
"""Model of a specific Answer to a Question in a specific Review.""" |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
#: A required many:1 relationship, where each of many Answers is |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
#: a specific answer to a single Question. An Answer must always |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
#: be associated with a Question in order to be interpreted. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
#: It is currently unclear how useful this back-reference will be, |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
#: since the same question could be used in multiple different |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
#: Review "templates". Given this, 'answers' currently only exists |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
#: for completeness. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
question = db.ReferenceProperty(reference_class=models.question.Question, |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
required=True, collection_name="answers") |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
#: A required many:1 relationship, where each of many Answers to |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
#: different Questions represents the answer set of a specific |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
#: Review. The back-reference in the Review model is a Query named |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
#: 'answers' which represents all of the specific answers to |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
#: questions in that Review. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
review = db.ReferenceProperty(reference_class=models.review.Review, |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
required=True, collection_name="answers") |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
#: db.StringProperty storing the "short" answer to the question; |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
#: the interpretation of this value depends on the Question entity |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
#: referred to by 'question'. Answers can be indexed, filtered, and |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
#: sorted by their "short" answer. Depending on the Question type, |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
#: some Answers will use only 'short', some only 'long', some both. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
short = db.StringProperty() |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
#: db.TextProperty storing the "long" answer to the question; |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
#: the interpretation of this value depends on the Question entity |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
#: referred to by 'question'. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
long = db.TextProperty() |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
|
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
#: db.ListProperty of short strings from the list of possible |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
#: picks in the question.pick_choices list. |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
picks = db.ListProperty(item_type=str) |
7a901a99b349
Initial definition of the Answer Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |