app/soc/models/student.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 21 Mar 2009 16:19:42 +0000
changeset 1980 db7c98580008
parent 1973 31d695f737ac
child 1989 3fa3384b5378
permissions -rw-r--r--
Added fields requested in Issue 392 to Student Model. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
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__ = [
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  '"Todd Larsen" <tlarsen@google.com>',
1949
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    21
  '"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
    22
]
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
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
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
    26
1949
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    27
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
    28
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
    29
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
    30
1374
ed12ed835755 Redone student model and added student logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    31
import soc.models.role
1383
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    32
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
    33
8ecc2e4198cd Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
1374
ed12ed835755 Redone student model and added student logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    35
class Student(soc.models.role.Role):
ed12ed835755 Redone student model and added student logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    36
  """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
    37
  """
1383
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    38
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
    39
  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
    40
      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
    41
  school_name.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
    42
  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
    43
      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
    44
      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
    45
  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
    46
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    47
  major = db.StringProperty(required=True,
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    48
      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
    49
  major.group = ugettext("5. Education")
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    50
  # TODO add more degrees because this should be used in GHOP as well
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    51
  degree = db.StringProperty(required=True,
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    52
      verbose_name=ugettext('Degree'),
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    53
      choices=['Undergraduate', 'Master', 'PhD'])
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    54
  degree.group = ugettext("5. Education")
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    55
  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
    56
      verbose_name=ugettext('Expected Graduation Year'))
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    57
  expected_graduation.help_text = ugettext("Year in integer format only!")
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    58
  expected_graduation.example_text = ugettext('Year only, for example "2012"')
db7c98580008 Added fields requested in Issue 392 to Student Model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1973
diff changeset
    59
  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
    60
1949
bcc52df68367 Added "How did you hear about this program?" to Student Profile.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1383
diff changeset
    61
  #: 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
    62
  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
    63
      "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
    64
  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
    65
      "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
    66
      "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
    67
      "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
    68
  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
    69
1383
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    70
  #: 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
    71
  #: School that they attend.
18383d2e5a5b Students now have a reference to school again.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1374
diff changeset
    72
  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
    73
                                required=False, collection_name='students')