app/soc/models/group_app.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 08 Mar 2009 13:14:28 +0000
changeset 1741 0da1285f5bc0
parent 1629 9ef5ff7a6d8f
child 1877 93dfd2d40c0b
permissions -rw-r--r--
Public reviews are now shown on the public page for the student proposal. The assigned mentor name has been removed from the public page. The student proposal view now uses the new getReviewsForEntity method. Patch by: Lennard de Rijk Reviewed by:to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
1307
091a21cf3627 Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1248
diff changeset
     3
# Copyright 2009 the Melange authors.
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
# 
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
# 
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""This module contains the Group Application Model."""
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
__authors__ = [
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  '"Todd Larsen" <tlarsen@google.com>',
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
]
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
from google.appengine.ext import db
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    26
from django.utils.translation import ugettext
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
import soc.models.document
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
import soc.models.linkable
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
import soc.models.user
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
class GroupApplication(soc.models.linkable.Linkable):
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
  """Common application questions for all groups.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
  Eventually, this will be replaced with a Question/Answer/Quiz/Response
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
  approach.  At that time, existing OrgApplication entities will be migrated
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
  (converted) to their new representations in the Datastore.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
  """
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
  #: Required field that will become the name of the Group in the profile,
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
  #: if the Group Application is accepted.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
  #: See also:  soc.models.group.Group.name
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
  name = db.StringProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    45
      verbose_name=ugettext('Group Name'))
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    46
  name.help_text = ugettext('Complete, formal name of the group.')  
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
  
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
  #: Required many:1 relationship indicating the User who is applying on
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
  #: behalf of the Group.  If the Group Application is accepted, this User
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
  #: will become the founding User of the Group.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51
  #: See also:  soc.models.group.Group.founder
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
  applicant = db.ReferenceProperty(reference_class=soc.models.user.User,
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
    required=True, collection_name='group_apps',
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    54
    verbose_name=ugettext('Applicant'))
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    55
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
  #: Required field indicating the home page URL of the applying Group.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
  #: See also:  soc.models.group.Group.home_page
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
  home_page = db.LinkProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    59
      verbose_name=ugettext('Home Page URL'))
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
  
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
  #: Required email address used as the "public" contact mechanism for
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
  #: the Group (as opposed to the applicant.account email address which is
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
  #: kept secret, revealed only to Developers).
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
  #: See also:  soc.models.group.Group.email
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
  email = db.EmailProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    66
    verbose_name=ugettext('Public Email'))
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
  
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
  #: Required description of the Group.
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
  description = db.TextProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    70
      verbose_name=ugettext('Description'))
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
  why_applying = db.TextProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    73
    verbose_name=ugettext(
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
      'Why is your group applying to participate?'
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
      ' What do you hope to gain by participating?'))
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
1562
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    77
  pub_mailing_list = db.StringProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    78
    verbose_name=ugettext(
789
e55cad180973 Moved the member_template field to app and removed 'optional'
Sverre Rabbelier <srabbelier@gmail.com>
parents: 786
diff changeset
    79
      'What is the main public mailing list for your group?'))
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    80
  pub_mailing_list.help_text = ugettext(
1562
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    81
    'Mailing list email address, URL to sign-up page, etc. If a mailing '
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    82
    'list is not used please specify another method of communication used '
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    83
    'within the group.')
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
1562
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    85
  irc_channel = db.StringProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    86
    verbose_name=ugettext(
789
e55cad180973 Moved the member_template field to app and removed 'optional'
Sverre Rabbelier <srabbelier@gmail.com>
parents: 786
diff changeset
    87
      'Where is the main IRC channel for your group?'))
1562
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    88
  irc_channel.help_text = ugettext('IRC network and channel. If IRC is '
0e1a93e0c54d Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1544
diff changeset
    89
      'not used please write something like not applicable.')
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    90
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    91
  backup_admin = db.ReferenceProperty(reference_class=soc.models.user.User,
1248
f318538394d9 Rename checkHasActiveRole to checkHasActiveRoleForScope
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1232
diff changeset
    92
    required=False, collection_name='group_app_backup_admin',
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    93
    verbose_name=ugettext(
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
      'Please select your backup group administrator.'))
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
  member_criteria = db.TextProperty(required=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
    97
    verbose_name=ugettext(
774
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
      'What criteria do you use to select the members of your group?'
88a827a9b614 Add hard-coded GroupApplication and OrgApplication Models.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
      ' Please be as specific as possible.'))
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
   100
  member_criteria.help_text = ugettext(
1544
5d23f0160fcd Fixed typo in soc/models/group_app.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1503
diff changeset
   101
    'Members include mentors, administrators, and the like.')
892
c3cdb581ffd2 Replaced boolean properties in soc/models/group_app with status property.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 881
diff changeset
   102
1085
0afbdd0905ef Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1080
diff changeset
   103
  # property containing the status of the application
892
c3cdb581ffd2 Replaced boolean properties in soc/models/group_app with status property.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 881
diff changeset
   104
  # completed means that the application has been processed into a real group
1503
c8ebaacc2337 Added pre-rejected choice to GroupApplication.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
   105
  # pre-accepted: used to indicate that the application has been accepted
1232
3bce6205e24e Added pre-accpeted status to group_app.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1229
diff changeset
   106
  # but the group cannot be made yet.
1503
c8ebaacc2337 Added pre-rejected choice to GroupApplication.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
   107
  # pre-rejected: used to indicate that the application has been rejected
c8ebaacc2337 Added pre-rejected choice to GroupApplication.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
   108
  # but the applicant has not been informed yet.
c8ebaacc2337 Added pre-rejected choice to GroupApplication.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
   109
  status = db.StringProperty(required=True,
1232
3bce6205e24e Added pre-accpeted status to group_app.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1229
diff changeset
   110
      choices=['accepted','rejected','ignored','needs review','completed',
1503
c8ebaacc2337 Added pre-rejected choice to GroupApplication.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
   111
          'pre-accepted', 'pre-rejected'],
892
c3cdb581ffd2 Replaced boolean properties in soc/models/group_app with status property.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 881
diff changeset
   112
      default='needs review',
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
   113
      verbose_name=ugettext('Application Status'))
892
c3cdb581ffd2 Replaced boolean properties in soc/models/group_app with status property.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 881
diff changeset
   114
881
1ad41c8d05e9 Added created and last modified timestamps to the group_app model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 795
diff changeset
   115
  # timestamp to record the time on which this application has been created
1ad41c8d05e9 Added created and last modified timestamps to the group_app model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 795
diff changeset
   116
  created_on = db.DateTimeProperty(required=True, auto_now_add=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
   117
      verbose_name=ugettext('Created on'))
881
1ad41c8d05e9 Added created and last modified timestamps to the group_app model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 795
diff changeset
   118
  
1629
9ef5ff7a6d8f Fix too long lines in soc.models.group_app module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1562
diff changeset
   119
  # timestamp to record the time on which this application has been 
9ef5ff7a6d8f Fix too long lines in soc.models.group_app module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1562
diff changeset
   120
  # last modified also changes when the review properties change
881
1ad41c8d05e9 Added created and last modified timestamps to the group_app model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 795
diff changeset
   121
  last_modified_on = db.DateTimeProperty(required=True, auto_now=True,
970
8b5611d5b053 Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents: 936
diff changeset
   122
      verbose_name=ugettext('Last modified on'))