app/soc/models/survey_record_group.py
author James Levy <jamesalexanderlevy@gmail.com>
Sun, 28 Jun 2009 13:18:56 +0200
changeset 2430 c9a5bf5ed3c5
child 2442 dd1f94c3594c
permissions -rw-r--r--
Added SurveyRecordGroup for the use in evaluation surveys. Patch by: James Levy, Daniel Diniz Reviewed by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2430
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     2
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     4
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     8
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    10
#
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    16
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    17
"""SurveyRecordGroup represents a cluster (mentor/student) of SurveyRecords
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    18
for an evaluation period.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    19
"""
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    20
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    21
__authors__ = [
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    22
  '"Daniel Diniz" <ajaksu@gmail.com>',
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    23
  '"James Levy" <jamesalexanderlevy@gmail.com>',
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    24
]
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    25
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    26
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    27
from google.appengine.ext import db
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    28
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    29
from soc.models.survey_record import SurveyRecord
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    30
import soc.models.user
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    31
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    32
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    33
class SurveyRecordGroup(db.Expando):
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    34
  """Because Mentors and Students take different surveys,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    35
  we cannot simply link survey records by a common project and survey.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    36
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    37
  Instead, we establish a SurveyRecordGroup.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    38
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    39
  A SurveyRecordGroup links a group of survey records with a common
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    40
  project, and links back to its records. 
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    41
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    42
  This entity also includes the current project_status at its creation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    43
  This property is used as a filter in lookups and acts as a safeguard
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    44
  against unpredictable behavior. 
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    45
  """
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    46
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    47
  #: Mentor SurveyRecord for this evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    48
  mentor_record = db.ReferenceProperty(SurveyRecord, required=False,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    49
                              collection_name='mentor_record_groups')
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    50
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    51
  #: Student SurveyRecord for this evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    52
  student_record = db.ReferenceProperty(SurveyRecord, required=False,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    53
                              collection_name='student_record_groups')
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    54
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    55
  #: Project for this evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    56
  project = db.ReferenceProperty(soc.models.student_project.StudentProject,
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    57
                                collection_name="survey_record_groups",
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    58
                                required=True)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    59
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    60
  # Status of project at start of evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    61
  initial_status = db.StringProperty(required=True)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    62
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    63
  #: Status of project at end of evaluation.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    64
  final_status = db.StringProperty(required=False)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    65
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    66
  #: Property containing the date that this SurveyRecordGroup was created.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    67
  created = db.DateTimeProperty(auto_now_add=True)
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    68
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    69
  #: Property containing the last date that this SurveyRecordGroup was modified.
c9a5bf5ed3c5 Added SurveyRecordGroup for the use in evaluation surveys.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    70
  modified = db.DateTimeProperty(auto_now=True)