app/soc/models/review.py
author Sverre Rabbelier <srabbelier@gmail.com>
Sun, 19 Apr 2009 17:42:44 +0000
changeset 2246 c29272f640b0
parent 1757 0f909179ccf2
child 3006 e74c4d37a61a
permissions -rw-r--r--
Tweak the 'load balancing' algorithm In order to reduce contention we randomly skipped jobs, but this caused many jobs to end up stopping early. Now instead we keep on going until we time out (also increased the chance of doing work). 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>',
1709
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    22
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
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
1757
0f909179ccf2 Some minor style fixes.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1709
diff changeset
    25
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
from google.appengine.ext import db
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
1709
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    28
import soc.models.comment
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
1757
0f909179ccf2 Some minor style fixes.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1709
diff changeset
    30
1709
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    31
class Review(soc.models.comment.Comment):
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    32
  """Model of a Review.
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
  """
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
1709
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    35
  #: the score given by the reviewer
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    36
  score = db.IntegerProperty(required=True, default=0)
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    37
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    38
  #: An optional reference property to a reviewer so the information
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    39
  #: from the Role can be used as well
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    40
  reviewer = db.ReferenceProperty(reference_class=soc.models.role.Role,
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    41
                                  required=False, collection_name="reviews")
22
7142ac62b885 Initial definition of the Review Model.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
1709
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    43
  def author_name(self):
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    44
    """Property as 'author_name' for use in common templates.
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    45
    """
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    46
    if self.reviewer:
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    47
      return self.reviewer.name()
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    48
    else:
5cb1167ff879 Redone the Review model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    49
      return self.author.name