app/soc/models/student.py
author Sverre Rabbelier <srabbelier@gmail.com>
Mon, 02 Nov 2009 16:13:04 +0100
changeset 3071 d11bb8ba0d23
parent 2926 effa1cfb3607
permissions -rw-r--r--
Set new Melange version number to 0-5-20091102 in app.yaml.template.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.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.
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
# 
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
# 
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
1077
8e0a17067b35 docstring fix in soc/models/student.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 207
diff changeset
    17
"""This module contains the Student Model."""
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
__authors__ = [
2926
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    20
  '"Madhusudan.C.S" <madhusudancs@gmail.com>',
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
  '"Todd Larsen" <tlarsen@google.com>',
1989
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
    22
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
1949
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    23
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
]
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
from google.appengine.ext import db
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
1949
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    29
from django.utils.translation import ugettext
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    30
1973
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    31
from soc.models import countries
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    32
1374
ed12ed835755 Redone student model and added student logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    33
import soc.models.role
1383
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    34
import soc.models.school
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
1374
ed12ed835755 Redone student model and added student logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    37
class Student(soc.models.role.Role):
ed12ed835755 Redone student model and added student logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    38
  """Student details for a specific Program.
207
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
  """
1383
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    40
1973
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    41
  school_name = db.StringProperty(required=True, 
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    42
      verbose_name=ugettext('School Name'))
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    43
  school_name.group = ugettext("5. Education")
2165
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    44
  school_name.help_text = ugettext(
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    45
      'Please enter the full name of your school, college or university in'
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    46
      ' this field. Please use the complete formal name of your school, e.g.'
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    47
      ' UC Berekeley instead of Cal or UCB. It would be most wonderful if you'
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    48
      ' could provide your school\'s name in English, as all the program '
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    49
      'administrators speak English as their first language and it will make'
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    50
      ' it much easier for us to assemble program statistics, etc., later if'
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    51
      ' we can easily read the name of your school.')
ab1ff1608258 Add (better) help_text to publish_location and school_name
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1989
diff changeset
    52
1973
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    53
  school_country = db.StringProperty(required=True,
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    54
      verbose_name=ugettext('School Country/Territory'),
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    55
      choices=countries.COUNTRIES_AND_TERRITORIES)
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    56
  school_country.group = ugettext("5. Education")
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    57
2926
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    58
  #: School type can be only High school for GHOP and can be University
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    59
  #: for GSoC.
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    60
  school_type = db.StringProperty(required=False,
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    61
                                  verbose_name=ugettext('School Type'),
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    62
                                  choices=['University', 'High School'])
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    63
  school_type.group = ugettext("5. Education")
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    64
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    65
  major = db.StringProperty(required=False,
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    66
      verbose_name=ugettext('Major Subject'))
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    67
  major.group = ugettext("5. Education")
2926
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    68
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    69
  degree = db.StringProperty(required=False,
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    70
      verbose_name=ugettext('Degree'),
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    71
      choices=['Undergraduate', 'Master', 'PhD'])
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    72
  degree.group = ugettext("5. Education")
2926
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    73
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    74
  #: Property containing the Grade of the student if the school type
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    75
  #: is High School.
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    76
  grade = db.IntegerProperty(required=False,
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    77
                            verbose_name=ugettext('Grade'))
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    78
  grade.group = ugettext("5. Education")
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    79
  grade.help_text = ugettext(
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    80
      'Please enter your grade in the school, e.g. 8 if you are in 8th' 
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    81
      'grade. In some parts of the world it is called as, e.g. 8th'
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    82
      'Standard')
effa1cfb3607 Added school_type and grade property to Student model.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2371
diff changeset
    83
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    84
  expected_graduation = db.IntegerProperty(required=True,
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    85
      verbose_name=ugettext('Expected Graduation Year'))
2371
805400745f57 Changed University Student expected graduation date to be a dynamic dropdown.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2165
diff changeset
    86
  expected_graduation.help_text = ugettext("Pick your expected graduation year")
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    87
  expected_graduation.group = ugettext("5. Education")
1973
31d695f737ac Add school name and school country properties to Student Role. For now we will use this solution, and hopefully soon we will introduce new School model.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1949
diff changeset
    88
1949
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    89
  #: Property to gain insight into where students heard about this program
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    90
  program_knowledge = db.TextProperty(required=True, verbose_name=ugettext(
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    91
      "How did you hear about this program?"))
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    92
  program_knowledge.help_text = ugettext("Please be as "
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    93
      "specific as possible, e.g. blog post (include URL if possible), mailing "
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    94
      "list (please include list address), information session (please include "
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    95
      "location and speakers if you can), etc.")
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    96
  program_knowledge.group = ugettext("4. Private Info")
1980
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    97
1383
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    98
  #: A many:1 relationship that ties multiple Students to the
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    99
  #: School that they attend.
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
   100
  school = db.ReferenceProperty(reference_class=soc.models.school.School,
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
   101
                                required=False, collection_name='students')
1989
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   102
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   103
  can_we_contact_you = db.BooleanProperty(verbose_name=ugettext(
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   104
      'Can we contact you?'))
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   105
  can_we_contact_you.help_text = ugettext(
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   106
      'Please check here if you would not mind being contacted by the Program'
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   107
      ' Administrators for follow up with members of the press who would like'
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   108
      ' to interview you about the program. You will not be contacted unless '
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   109
      ' you successfully complete your project. <br />'
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   110
      '<b>Please note that checking this  box has no effect on your chances'
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   111
      ' of being accepted into the program</b>.')
3fa3384b5378 Added a 'Can we contact you' property
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1980
diff changeset
   112
  can_we_contact_you.group = ugettext("2. Contact Info (Private)")