app/soc/models/survey.py
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 13 Aug 2009 14:02:22 -0700
changeset 2770 71a5a56cf29e
parent 2763 80d625f78176
child 2792 14a62fcf4e02
permissions -rw-r--r--
Redone the acceptedStudentsExport functionality. The method has been renamed to exportStudentsWithProjects and retrieves the document_name and the new shipping address properties. Also it filters out all invalid projects or projects for wich the scope_path doesn't match the given scope_pa th_start. Also there is no more need to use the argument given to this method when adding the extra columns. The data is now prepared by one loop which uses the key present in the accepted_students dictionary for retrieving the data used by the extra columns.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     2
#
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     4
#
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     8
#
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    10
#
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    16
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    17
"""This module contains the Survey models.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    18
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    19
Survey describes meta-information and permissions.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    20
SurveyContent contains the fields (questions) and their metadata.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    21
"""
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    22
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    23
__authors__ = [
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    24
  '"Daniel Diniz" <ajaksu@gmail.com>',
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    25
  '"James Levy" <jamesalexanderlevy@gmail.com>',
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    26
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    27
]
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    28
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    29
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    30
from google.appengine.ext import db
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    31
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    32
from django.utils.translation import ugettext
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    33
2763
80d625f78176 Added base Model for Expando models.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2588
diff changeset
    34
from soc.models.expando_base import ExpandoBase
80d625f78176 Added base Model for Expando models.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2588
diff changeset
    35
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    36
import soc.models.work
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    37
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    38
2501
d612b48e6e12 Added Survey From Field validation.
Daniel Diniz <ajaksu@gmail.com>
parents: 2493
diff changeset
    39
COMMENT_PREFIX = 'comment_for_'
d612b48e6e12 Added Survey From Field validation.
Daniel Diniz <ajaksu@gmail.com>
parents: 2493
diff changeset
    40
d612b48e6e12 Added Survey From Field validation.
Daniel Diniz <ajaksu@gmail.com>
parents: 2493
diff changeset
    41
2763
80d625f78176 Added base Model for Expando models.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2588
diff changeset
    42
class SurveyContent(ExpandoBase):
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    43
  """Fields (questions) and schema representation of a Survey.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    44
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    45
  Each survey content entity consists of properties where names and default
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    46
  values are set by the survey creator as survey fields.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    47
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    48
    schema: A dictionary (as text) storing, for each field:
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    49
      - type
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    50
      - index
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    51
      - order (for choice questions)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    52
      - render (for choice questions)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    53
      - question (free form text question, used as label)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    54
  """
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    55
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    56
  #:Field storing the content of the survey in the form of a dictionary.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    57
  schema = db.TextProperty()
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    58
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    59
  #: Fields storing the created on and last modified on dates.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    60
  created = db.DateTimeProperty(auto_now_add=True)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    61
  modified = db.DateTimeProperty(auto_now=True)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    62
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    63
  def getSurveyOrder(self):
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    64
    """Make survey questions always appear in the same (creation) order.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    65
    """
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    66
    survey_order = {}
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    67
    schema = eval(self.schema)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    68
    for property in self.dynamic_properties():
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    69
      # map out the order of the survey fields
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    70
      index = schema[property]["index"]
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    71
      if index not in survey_order:
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    72
        survey_order[index] = property
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    73
      else:
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    74
        # Handle duplicated indexes
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    75
        survey_order[max(survey_order) + 1] = property
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    76
    return survey_order
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    77
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    78
  def orderedProperties(self):
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    79
    """Helper for View.get_fields(), keep field order.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    80
    """
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    81
    properties = []
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    82
    survey_order = self.getSurveyOrder().items()
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    83
    for position,key in survey_order:
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    84
      properties.insert(position, key)
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    85
    return properties
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    86
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    87
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    88
class Survey(soc.models.work.Work):
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    89
  """Model of a Survey.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    90
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    91
  This model describes meta-information and permissions.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    92
  The actual questions of the survey are contained
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    93
  in the SurveyContent entity.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    94
  """
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    95
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    96
  URL_NAME = 'survey'
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    97
  # euphemisms like "student" and "mentor" should be used if possible
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    98
  SURVEY_ACCESS = ['admin', 'restricted', 'member', 'user']
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
    99
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   100
  # these are GSoC specific, so eventually we can subclass this
2501
d612b48e6e12 Added Survey From Field validation.
Daniel Diniz <ajaksu@gmail.com>
parents: 2493
diff changeset
   101
  SURVEY_TAKING_ACCESS = ['student',
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   102
                          'mentor',
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   103
                          'org_admin',
2525
7df431ddcfd3 Remove public role type from SURVEY_TAKING_ACCESS in Survey model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2501
diff changeset
   104
                          'user']
7df431ddcfd3 Remove public role type from SURVEY_TAKING_ACCESS in Survey model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2501
diff changeset
   105
  
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   106
  GRADE_OPTIONS = {'midterm':['mid_term_passed', 'mid_term_failed'],
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   107
                   'final':['final_passed', 'final_failed'],
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   108
                   'N/A':[] }
2442
dd1f94c3594c Start on adding ProjectSurvey and GradingProjectSurvey.
Daniel Diniz <ajaksu@gmail.com>
parents: 2440
diff changeset
   109
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   110
  prefix = db.StringProperty(default='program', required=True,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   111
      choices=['site', 'club', 'sponsor', 'program', 'org', 'user'],
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   112
      verbose_name=ugettext('Prefix'))
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   113
  prefix.help_text = ugettext(
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   114
      'Indicates the prefix of the survey,'
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   115
      ' determines which access scheme is used.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   116
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   117
  #: Field storing the required access to read this survey.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   118
  read_access = db.StringProperty(default='restricted', required=True,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   119
      choices=SURVEY_ACCESS,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   120
      verbose_name=ugettext('Survey Read Access'))
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   121
  read_access.help_text = ugettext(
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   122
      'Indicates who can read the results of this survey.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   123
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   124
  #: Field storing the required access to write to this survey.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   125
  write_access = db.StringProperty(default='admin', required=True,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   126
      choices=SURVEY_ACCESS,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   127
      verbose_name=ugettext('Survey Write Access'))
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   128
  write_access.help_text = ugettext(
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   129
      'Indicates who can edit this survey.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   130
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   131
  #: Field storing the required access to write to this survey.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   132
  taking_access = db.StringProperty(default='student', required=True,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   133
      choices=SURVEY_TAKING_ACCESS,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   134
      verbose_name=ugettext('Survey Taking Access'))
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   135
  taking_access.help_text = ugettext(
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   136
      'Indicates who can take this survey. '
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   137
      'Student/Mentor options are for Midterms and Finals.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   138
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   139
  #: Field storing whether a link to the survey should be featured in
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   140
  #: the sidebar menu (and possibly elsewhere); FAQs, Terms of Service,
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   141
  #: and the like are examples of "featured" survey.
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   142
  is_featured = db.BooleanProperty(
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   143
      verbose_name=ugettext('Is Featured'))
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   144
  is_featured.help_text = ugettext(
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   145
      'Field used to indicate if a Survey should be featured, for example,'
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   146
      ' in the sidebar menu.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   147
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   148
  #: Date at which the survey becomes available for taking.
2440
05c430d1c147 Renamed opening to survey_start and deadline to survey_end.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2428
diff changeset
   149
  survey_start = db.DateTimeProperty(required=False)
05c430d1c147 Renamed opening to survey_start and deadline to survey_end.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2428
diff changeset
   150
  survey_start.help_text = ugettext(
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   151
      'Indicates a date before which this survey'
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   152
      ' cannot be taken or displayed.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   153
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   154
  #: Deadline for taking survey.
2440
05c430d1c147 Renamed opening to survey_start and deadline to survey_end.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2428
diff changeset
   155
  survey_end = db.DateTimeProperty(required=False)
05c430d1c147 Renamed opening to survey_start and deadline to survey_end.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2428
diff changeset
   156
  survey_end.help_text = ugettext(
2428
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   157
      'Indicates a date after which this survey'
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   158
      ' cannot be taken.')
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   159
8ca9f32d3fc4 Added Survey and SurveyContent model.
James Levy <jamesalexanderlevy@gmail.com>
parents:
diff changeset
   160
  #: Referenceproperty that specifies the content of this survey.
2588
db306bbda381 Indention fixes and adding "reference_class=" in ReferenceProperty params.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2525
diff changeset
   161
  survey_content = db.ReferenceProperty(reference_class=SurveyContent,
db306bbda381 Indention fixes and adding "reference_class=" in ReferenceProperty params.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2525
diff changeset
   162
                                        collection_name="survey_parent")