app/soc/models/review.py
author Sverre Rabbelier <srabbelier@gmail.com>
Sun, 15 Feb 2009 22:29:22 +0000
changeset 1360 f62c462037b6
parent 1308 35b75ffcbb37
child 1709 5cb1167ff879
permissions -rw-r--r--
Added grouping support to all forms, converted role as example Any field that has the 'group' property set be placed in the specified group. If no such proprty is set, the 'General' group will be used instead. Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
#
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.
22
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
533
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 385
diff changeset
    26
import soc.models.linkable
385
6d410bf49a82 Remove not used imports in models. Fix missing spaces in models when operator not preceded by a space. Add missing ugettext_lazy import to Proposal model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 316
diff changeset
    27
# TODO: Uncomment when Survey model is committed
6d410bf49a82 Remove not used imports in models. Fix missing spaces in models when operator not preceded by a space. Add missing ugettext_lazy import to Proposal model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 316
diff changeset
    28
#import soc.models.survey
533
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 385
diff changeset
    29
import soc.models.reviewer
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
import soc.models.work
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
533
ba3309b2fd30 Move LINK_ID and SCOPE_PATH regular expressions to soc/models/linkable.py.
Todd Larsen <tlarsen@google.com>
parents: 385
diff changeset
    33
class Review(soc.models.linkable.Linkable):
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
  """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
    35
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
  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
    37
  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
    38
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
  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
    40
  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
    41
  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
    42
  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
    43
  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
    44
  the other containing the score.
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
  A Review entity participates in the following relationships implemented 
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
  as a db.ReferenceProperty elsewhere in another db.Model:
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
   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
    50
     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
    51
     Answers) that relates the specific answers to the Survey
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
     questions for a specfic Review instance. This relation is
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
     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
    54
     'review' reference.
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
     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
    57
     define an 'approval_style' string and one or more
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
     'approval_answers'. See the Question and Answer models for
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
     details. All Questions answered in the Review that provide
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
     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
    61
     described approval conditions for the Review to represent 
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
     "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
    63
     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
    64
     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
    65
  """
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
  #: 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
    68
  #: "template" for the Review, containing the Questions that are
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
  #: anwered by the Answers associated with the Review. The
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
  #: 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
    71
  #: 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
    72
  #: Questions in that particular Survey.
244
da80c6519eea Fixed models based on output from graph.py script and comments on
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 181
diff changeset
    73
  # TODO: Uncomment when Survey model is committed
da80c6519eea Fixed models based on output from graph.py script and comments on
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 181
diff changeset
    74
  #survey = db.ReferenceProperty(reference_class=soc.models.survey.Survey,
da80c6519eea Fixed models based on output from graph.py script and comments on
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 181
diff changeset
    75
  #                              required=True, collection_name="reviews")
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
  #: 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
    78
  #: 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
    79
  #: review, report, acceptance, etc. Reviews are the mechanism by
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
  #: 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
    81
  #: 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
    82
  #: which represents all of the annotations attached to that
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
  #: 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
    84
  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
    85
                                  required=True, collection_name="reviews")
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
                                  
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
  #: 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
    88
  #: 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
    89
  #: 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
    90
  #: 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
    91
  #: 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
    92
  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
    93
                                  required=True, collection_name="reviews")
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94