app/soc/models/student_proposal.py
author Lennard de Rijk <ljvderijk@gmail.com>
Mon, 24 Aug 2009 18:44:41 +0200
changeset 2793 8c88226b27e7
parent 1837 27428cd5b98f
permissions -rw-r--r--
Set default taking access for GradingProjectSurvey to org. This will allow Mentors and Org Admins to take GradingProjectSurveys in case that an Org Admin has no Mentor roles.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     2
#
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     4
#
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     8
# 
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    10
# 
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    16
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    17
"""This module contains the Student Proposal Model.
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    18
"""
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    19
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    20
__authors__ = [
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    21
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    22
]
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    23
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    24
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
from google.appengine.ext import db
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    26
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
from django.utils.translation import ugettext
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
import soc.models.linkable
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
import soc.models.mentor
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
import soc.models.organization
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    32
import soc.models.program
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    33
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
1608
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    35
# define the [min_score, max_score] and the name for the RankList
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    36
DEF_SCORE = [-1000, 1000]
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    37
DEF_RANKER_NAME = 'student_app_ranker'
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    38
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    39
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
class StudentProposal(soc.models.linkable.Linkable):
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    41
  """Model for a student proposal used in the GSoC workflow.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
  """
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    43
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    44
  #: Required field indicating the "title" of the proposal
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    45
  title = db.StringProperty(required=True,
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    46
      verbose_name=ugettext('Title'))
1837
27428cd5b98f Minor textual changes in the StudentProposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1788
diff changeset
    47
  title.help_text = ugettext('Title of the proposal')
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    48
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    49
  #: required, text field used for different purposes,
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    50
  #: depending on the specific type of the proposal
1788
f7665077a54f StudentProposal abstract is now a text property to support more then 500 bytes.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1779
diff changeset
    51
  abstract = db.TextProperty(required=True)
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    52
  abstract.help_text = ugettext(
1837
27428cd5b98f Minor textual changes in the StudentProposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1788
diff changeset
    53
      'Short abstract, summary, or snippet;'
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    54
      ' 500 characters or less, plain text displayed publicly')
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    55
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    56
  #: Required field containing the content of the proposal.
1568
cdbe6e86506c StudentProposal content is now a TextProperty.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1421
diff changeset
    57
  content = db.TextProperty(required=True)
1657
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    58
  content.help_text = ugettext('This contains your actual proposal')
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    59
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    60
  #: an URL linking to more information about this students proposal
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    61
  additional_info = db.URLProperty(required=False)
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    62
  additional_info.help_text = ugettext(
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    63
      'Link to a resource containing more information about your proposal')
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    64
1657
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    65
  #: A property containing which mentor has assigned himself to this proposal.
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    66
  #: Only a proposal with an assigned mentor can be turned into 
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    67
  #: a accepted proposal. A proposal can only have one mentor.
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    68
  mentor = db.ReferenceProperty(reference_class=soc.models.mentor.Mentor,
1657
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    69
                                required=False, 
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    70
                                collection_name='student_proposals')
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    71
1608
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    72
  #: A property containing a list of possible Mentors for this proposal
1622
1ecd37ddc145 Fixed early line ending in StudentProposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1608
diff changeset
    73
  possible_mentors = db.ListProperty(item_type=db.Key, default=[])
1608
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    74
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    75
  #: the current score of this proposal, used to determine which proposals
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    76
  #: should be assigned a project slot.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    77
  score = db.IntegerProperty(required=True, default=0)
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    78
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    79
  #: the status of this proposal
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    80
  #: new : the proposal has not been ranked/scored yet
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    81
  #: pending: the proposal is in the process of being ranked/scored
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    82
  #: accepted: the proposal has been assigned a project slot
1779
cdd11aa8dbc7 Org admins can mark a StudentProposal as invalid if they for any reason find it ineligible.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1657
diff changeset
    83
  #: rejected: the proposal has not been assigned a slot
cdd11aa8dbc7 Org admins can mark a StudentProposal as invalid if they for any reason find it ineligible.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1657
diff changeset
    84
  #: invalid: the student or org admin marked this as an invalid proposal.
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    85
  status = db.StringProperty(required=True, default='new',
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    86
      choices=['new', 'pending', 'accepted', 'rejected', 'invalid'])
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    87
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    88
  #: organization to which this proposal is directed
1657
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    89
  org = db.ReferenceProperty(
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    90
      reference_class=soc.models.organization.Organization,
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    91
      required=True, collection_name='student_proposals')
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    92
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    93
  #: program in which this proposal has been created
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    94
  program = db.ReferenceProperty(reference_class=soc.models.program.Program,
1657
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    95
                                 required=True, 
77832a2171af Fix too long lines and indentions in soc.models.student_proposal module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1622
diff changeset
    96
                                 collection_name='student_proposals')
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    97
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    98
  #: date when the proposal was created
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    99
  created_on = db.DateTimeProperty(required=True, auto_now_add=True)
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   100
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
   101
  #: date when the proposal was last modified, should be set manually on edit
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
   102
  last_modified_on = db.DateTimeProperty(required=True, auto_now_add=True)