app/soc/models/review.py
author Sverre Rabbelier <srabbelier@gmail.com>
Wed, 05 Nov 2008 23:32:59 +0000
changeset 443 94568ac6e3e1
parent 385 6d410bf49a82
child 533 ba3309b2fd30
permissions -rw-r--r--
Implements base.Logic functions in home_settings, site_settings and work This patch implements the base.Logic funtions needed for making logic/key_name.py obsolete. This patch defines the needed functions in home_settings, site_settings and work. All modules in logic/models now have these functions defined. logic/models/site_settings.py now inherits from logic/models/home_settings.py because of their similar connection in the corresponding models. Please note that the self._keyName for these two modules still points to logic/key_name.py since entity_type is still used in views/home.py. A partial_path and link_name were added to HomeSettings as requested by SRabbelier.
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
#
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
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
    26
# 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
    27
#import soc.models.survey
22
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.
244
da80c6519eea Fixed models based on output from graph.py script and comments on
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 181
diff changeset
    72
  # 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
    73
  #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
    74
  #                              required=True, collection_name="reviews")
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
  #: 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
    77
  #: 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
    78
  #: review, report, acceptance, etc. Reviews are the mechanism by
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
  #: 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
    80
  #: 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
    81
  #: which represents all of the annotations attached to that
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
  #: 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
    83
  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
    84
                                  required=True, collection_name="reviews")
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    85
                                  
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
  #: 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
    87
  #: 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
    88
  #: 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
    89
  #: 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
    90
  #: 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
    91
  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
    92
                                  required=True, collection_name="reviews")
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93