|
1 #!/usr/bin/python2.5 |
|
2 # |
|
3 # Copyright 2008 the Melange authors. |
|
4 # |
|
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 |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
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. |
|
16 |
|
17 """This module contains the Answer Model.""" |
|
18 |
|
19 __authors__ = [ |
|
20 '"Todd Larsen" <tlarsen@google.com>', |
|
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 ] |
|
23 |
|
24 from google.appengine.ext import db |
|
25 |
|
26 from soc import models |
|
27 import soc.models.question |
|
28 import soc.models.review |
|
29 |
|
30 |
|
31 class Answer(db.Model): |
|
32 """Model of a specific Answer to a Question in a specific Review.""" |
|
33 |
|
34 #: A required many:1 relationship, where each of many Answers is |
|
35 #: a specific answer to a single Question. An Answer must always |
|
36 #: be associated with a Question in order to be interpreted. |
|
37 #: It is currently unclear how useful this back-reference will be, |
|
38 #: since the same question could be used in multiple different |
|
39 #: Review "templates". Given this, 'answers' currently only exists |
|
40 #: for completeness. |
|
41 question = db.ReferenceProperty(reference_class=models.question.Question, |
|
42 required=True, collection_name="answers") |
|
43 |
|
44 #: A required many:1 relationship, where each of many Answers to |
|
45 #: different Questions represents the answer set of a specific |
|
46 #: Review. The back-reference in the Review model is a Query named |
|
47 #: 'answers' which represents all of the specific answers to |
|
48 #: questions in that Review. |
|
49 review = db.ReferenceProperty(reference_class=models.review.Review, |
|
50 required=True, collection_name="answers") |
|
51 |
|
52 #: db.StringProperty storing the "short" answer to the question; |
|
53 #: the interpretation of this value depends on the Question entity |
|
54 #: referred to by 'question'. Answers can be indexed, filtered, and |
|
55 #: sorted by their "short" answer. Depending on the Question type, |
|
56 #: some Answers will use only 'short', some only 'long', some both. |
|
57 short = db.StringProperty() |
|
58 |
|
59 #: db.TextProperty storing the "long" answer to the question; |
|
60 #: the interpretation of this value depends on the Question entity |
|
61 #: referred to by 'question'. |
|
62 long = db.TextProperty() |
|
63 |
|
64 #: db.ListProperty of short strings from the list of possible |
|
65 #: picks in the question.pick_choices list. |
|
66 picks = db.ListProperty(item_type=str) |
|
67 |