app/soc/models/school.py
author Chen Lunpeng <forever.clp@gmail.com>
Sat, 18 Oct 2008 05:59:04 +0000
changeset 381 8b9e8f5d119b
parent 369 2955eff2bf94
child 385 6d410bf49a82
permissions -rw-r--r--
Fixed not working to edit a doc that selected from the docs list view. soc/templates/soc/docs/list/docs_row.html not full updated. Patch by: Chen Lunpeng Review by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
173
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""This module contains the School Model."""
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
__authors__ = [
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  '"Todd Larsen" <tlarsen@google.com>',
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
]
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
369
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    24
from django.utils.translation import ugettext_lazy
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    25
173
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
from google.appengine.ext import db
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
from soc.models import base
316
9efdc7bc3565 Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 208
diff changeset
    29
173
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
import soc.models.group
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
208
e076aee6e90f Take advantage of the Model inheritance provided by polymodel.PolyModel to
Todd Larsen <tlarsen@google.com>
parents: 181
diff changeset
    33
class School(soc.models.group.Group):
173
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
  """Details specific to a School.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
  A School is a specific type of Group that gathers Students together.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
  A School entity participates in the following relationships implemented
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
  as a db.ReferenceProperty elsewhere in another db.Model:
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
   students)  a 1:many relationship of Students attending (or otherwise
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
     belonging to) a School.  This relation is implemented as the 'students'
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
     back-reference Query of the Student model 'school' reference.
f5219e0ee998 First pass (from some old code notes) of a School Model (a form of Group).
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
  """
369
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    45
  
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    46
  #: Type name used in templates
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    47
  TYPE_NAME = ugettext_lazy('School')
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    48
  #: Type short name used for example in urls
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    49
  TYPE_NAME_SHORT = 'school'
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    50
  #: Type plural name used in templates
2955eff2bf94 Replace GROUP_TYPE_PLURAL and GROUP_TYPE_SHORT constants in Group models with more generic TYPE_NAME, TYPE_NAME_SHORT, TYPE_NAME_PLURAL names and apply changes in affected files. Use ugettext_lazy for TYPE_NAME and TYPE_NAME_PLURAL constants. This approach is similar to the upcoming refactor of views.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 344
diff changeset
    51
  TYPE_NAME_PLURAL = ugettext_lazy('Schools')