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-- |
22
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""This module contains the Review Model.""" |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
__authors__ = [ |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
'"Todd Larsen" <tlarsen@google.com>', |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
from google.appengine.ext import db |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
from soc import models |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
import soc.models.survey |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
import soc.models.work |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
import soc.models.reviewer |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
class Review(db.Model): |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
"""Model of a review of a Proposal or a Task. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
A Review entity is a specific instance of a completed Survey, collecting |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
the Answers to the Questions that are found in that Survey. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
Reviews are also used to implement comments and scoring annotations |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
to Proposals and Tasks. For example, a commment attached to a |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
Proposal is a Review with the Answer to a single "question" (with |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
that answer being the comment itself). A scoring evaluation might |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
be made up of Answers to two "questions", one containg the comment |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
the other containing the score. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
A Review entity participates in the following relationships implemented |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
as a db.ReferenceProperty elsewhere in another db.Model: |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
answers) A 1:many relationship (but not required, since initially |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
none of the Questions to be answered by a Review will have |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
Answers) that relates the specific answers to the Survey |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
questions for a specfic Review instance. This relation is |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
implemented as a back-reference Query of the Answer model |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
'review' reference. |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
Some (zero or more) of the Questions answered by a Review may |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
define an 'approval_style' string and one or more |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
'approval_answers'. See the Question and Answer models for |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
details. All Questions answered in the Review that provide |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
non-empty 'approval_style' and 'approval_answers' must meet the |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
described approval conditions for the Review to represent |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
"approval" (or a "positive outcome" or a "passing grade", so to |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
speak). Most Reviews answer Questions in a Survey that contains |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
only a single "approval" question (if they contain one at all). |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
""" |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
#: A required many:1 relationship with a Survey which acts as a |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
#: "template" for the Review, containing the Questions that are |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
#: anwered by the Answers associated with the Review. The |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
#: back-reference in the Survey model is a Query named 'reviews' |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
#: which represents all of the Reviews that contains Answers to the |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
#: Questions in that particular Survey. |
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
|
72 |
survey = db.ReferenceProperty(reference_class=soc.models.survey.Survey, |
22
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
required=True, collection_name="reviews") |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
#: A required many:1 relationship with a Work, where the Review |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
#: answers are attached to the Work as a comment, evaluation, |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
#: review, report, acceptance, etc. Reviews are the mechanism by |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
78 |
#: which non-authors of the Work make annotations to it. The |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
#: back-reference in the Work model is a Query named 'reviews' |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
#: which represents all of the annotations attached to that |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
81 |
#: particular work. |
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
|
82 |
reviewed = db.ReferenceProperty(reference_class=soc.models.work.Work, |
22
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
83 |
required=True, collection_name="reviews") |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
84 |
|
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
85 |
#: A required many:1 relationship with a Reviewer entity indicating |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
#: the "author" of the actual answers for a specific Review |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
87 |
#: instance. The back-reference in the Reviewer model is a Query |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
88 |
#: named 'reviews' which represents all of the Reviews by that |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
89 |
#: particular Reviewer. |
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
|
90 |
reviewer = db.ReferenceProperty(reference_class=soc.models.reviewer.Reviewer, |
22
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
91 |
required=True, collection_name="reviews") |
7142ac62b885
Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |