app/soc/models/review.py
changeset 1709 5cb1167ff879
parent 1308 35b75ffcbb37
child 1757 0f909179ccf2
equal deleted inserted replaced
1708:1aff33e33613 1709:5cb1167ff879
    17 """This module contains the Review Model."""
    17 """This module contains the Review Model."""
    18 
    18 
    19 __authors__ = [
    19 __authors__ = [
    20   '"Todd Larsen" <tlarsen@google.com>',
    20   '"Todd Larsen" <tlarsen@google.com>',
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
       
    22   '"Lennard de Rijk" <ljvderijk@gmail.com>',
    22 ]
    23 ]
    23 
    24 
    24 from google.appengine.ext import db
    25 from google.appengine.ext import db
    25 
    26 
    26 import soc.models.linkable
    27 import soc.models.comment
    27 # TODO: Uncomment when Survey model is committed
       
    28 #import soc.models.survey
       
    29 import soc.models.reviewer
       
    30 import soc.models.work
       
    31 
    28 
    32 
    29 class Review(soc.models.comment.Comment):
    33 class Review(soc.models.linkable.Linkable):
    30   """Model of a Review.
    34   """Model of a review of a Proposal or a Task.
       
    35 
       
    36   A Review entity is a specific instance of a completed Survey, collecting
       
    37   the Answers to the Questions that are found in that Survey.
       
    38 
       
    39   Reviews are also used to implement comments and scoring annotations
       
    40   to Proposals and Tasks. For example, a commment attached to a
       
    41   Proposal is a Review with the Answer to a single "question" (with
       
    42   that answer being the comment itself).  A scoring  evaluation might
       
    43   be made up of Answers to two "questions", one containg the comment
       
    44   the other containing the score.
       
    45 
       
    46   A Review entity participates in the following relationships implemented 
       
    47   as a db.ReferenceProperty elsewhere in another db.Model:
       
    48 
       
    49    answers) A 1:many relationship (but not required, since initially
       
    50      none of the Questions to be answered by a Review will have
       
    51      Answers) that relates the specific answers to the Survey
       
    52      questions for a specfic Review instance. This relation is
       
    53      implemented as a back-reference Query of the Answer model
       
    54      'review' reference.
       
    55 
       
    56      Some (zero or more) of the Questions answered by a Review may
       
    57      define an 'approval_style' string and one or more
       
    58      'approval_answers'. See the Question and Answer models for
       
    59      details. All Questions answered in the Review that provide
       
    60      non-empty 'approval_style' and 'approval_answers' must meet the
       
    61      described approval conditions for the Review to represent 
       
    62      "approval" (or a "positive outcome" or a "passing grade", so to
       
    63      speak). Most Reviews answer Questions in a Survey that contains
       
    64      only a single "approval" question (if they contain one at all).
       
    65   """
    31   """
    66 
    32 
    67   #: A required many:1 relationship with a Survey which acts as a
    33   #: the score given by the reviewer
    68   #: "template" for the Review, containing the Questions that are
    34   score = db.IntegerProperty(required=True, default=0)
    69   #: anwered by the Answers associated with the Review. The
       
    70   #: back-reference in the Survey model is a Query named 'reviews'
       
    71   #: which represents all of the Reviews that contains Answers to the
       
    72   #: Questions in that particular Survey.
       
    73   # TODO: Uncomment when Survey model is committed
       
    74   #survey = db.ReferenceProperty(reference_class=soc.models.survey.Survey,
       
    75   #                              required=True, collection_name="reviews")
       
    76 
    35 
    77   #: A required many:1 relationship with a Work, where the Review
    36   #: An optional reference property to a reviewer so the information
    78   #: answers are attached to the Work as a comment, evaluation,
    37   #: from the Role can be used as well
    79   #: review, report, acceptance, etc. Reviews are the mechanism by
    38   reviewer = db.ReferenceProperty(reference_class=soc.models.role.Role,
    80   #: which non-authors of the Work make annotations to it. The
    39                                   required=False, collection_name="reviews")
    81   #: back-reference in the Work model is a Query named 'reviews'
       
    82   #: which represents all of the annotations attached to that
       
    83   #: particular work.
       
    84   reviewed = db.ReferenceProperty(reference_class=soc.models.work.Work, 
       
    85                                   required=True, collection_name="reviews")
       
    86                                   
       
    87   #: A required many:1 relationship with a Reviewer entity indicating
       
    88   #: the "author" of the actual answers for a specific Review
       
    89   #: instance. The back-reference in the Reviewer model is a Query
       
    90   #: named 'reviews' which represents all of the Reviews by that
       
    91   #: particular Reviewer.
       
    92   reviewer = db.ReferenceProperty(reference_class=soc.models.reviewer.Reviewer,
       
    93                                   required=True, collection_name="reviews")
       
    94 
    40 
       
    41   def author_name(self):
       
    42     """Property as 'author_name' for use in common templates.
       
    43     """
       
    44     if self.reviewer:
       
    45       return self.reviewer.name()
       
    46     else:
       
    47       return self.author.name