app/soc/models/student_proposal.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Wed, 04 Mar 2009 17:28:02 +0000
changeset 1627 425dccf4f652
parent 1622 1ecd37ddc145
child 1657 77832a2171af
permissions -rw-r--r--
Style and too long lines fixes in soc.models.role module. Patch by: Pawel Solyga Reviewed by: to-be-reviewed
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'))
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
  title.help_text = ugettext(
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    48
      'title of the proposal')
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    49
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    50
  #: required, text field used for different purposes,
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    51
  #: depending on the specific type of the proposal
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    52
  abstract = db.StringProperty(required=True, multiline=True)
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    53
  abstract.help_text = ugettext(
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    54
      'short abstract, summary, or snippet;'
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    55
      ' 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
    56
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    57
  #: 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
    58
  content = db.TextProperty(required=True)
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    59
  content.help_text = ugettext(
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    60
      'This contains your actual proposal')
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    61
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    62
  #: 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
    63
  additional_info = db.URLProperty(required=False)
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    64
  additional_info.help_text = ugettext(
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    65
      '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
    66
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    67
  #: A property containing which mentor has assigned himself to this proposal
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    68
  #: Only a proposal with an assigned mentor can be turned into a accepted proposal
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    69
  #: A proposal can only have one mentor
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    70
  mentor = db.ReferenceProperty(reference_class=soc.models.mentor.Mentor,
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    71
                              required=False, collection_name='student_proposals')
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    72
1608
ddef5428d3c9 Added a possible_mentors property to the StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1568
diff changeset
    73
  #: 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
    74
  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
    75
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    76
  #: 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
    77
  #: should be assigned a project slot.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    78
  score = db.IntegerProperty(required=True, default=0)
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    79
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    80
  #: the status of this proposal
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    81
  #: 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
    82
  #: 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
    83
  #: accepted: the proposal has been assigned a project slot
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    84
  #: rejected: the proposal has not been assigned a slot or the organization
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    85
  #: does not want this proposal.
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    86
  #: invalid: the student or developer marked this as an invalid proposal.
1421
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    87
  status = db.StringProperty(required=True, default='new',
7602d41f0ed8 Made some changes to StudentProposal.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1412
diff changeset
    88
      choices=['new', 'pending', 'accepted', 'rejected', 'invalid'])
1412
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    89
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    90
  #: organization to which this proposal is directed
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    91
  org = db.ReferenceProperty(reference_class=soc.models.organization.Organization,
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    92
                              required=True, collection_name='student_proposals')
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    93
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    94
  #: 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
    95
  program = db.ReferenceProperty(reference_class=soc.models.program.Program,
fa274dd2f476 First go at the student proposal model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    96
                              required=True, collection_name='student_proposals')
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)