app/soc/models/group.py
changeset 174 f065ee52d759
child 181 fdd29818a954
equal deleted inserted replaced
173:f5219e0ee998 174:f065ee52d759
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2008 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """This module contains the Group Model."""
       
    18 
       
    19 __authors__ = [
       
    20   '"Todd Larsen" <tlarsen@google.com>',
       
    21 ]
       
    22 
       
    23 from google.appengine.ext import db
       
    24 
       
    25 from django.utils.translation import ugettext_lazy
       
    26 
       
    27 from soc.models import base
       
    28 import soc.models.user
       
    29 
       
    30 
       
    31 class Group(base.ModelWithFieldAttributes):
       
    32   """Common data fields for all groups.
       
    33 
       
    34   A Group entity participates in the following relationships implemented as
       
    35   a db.ReferenceProperty elsewhere in another db.Model:
       
    36 
       
    37    school), club), sponsor), org)
       
    38      a 1:1 relationship with each entity containing a more specific type of
       
    39      Group.  These relationships are represented explicitly in the other
       
    40      "group" models by a db.ReferenceProperty named 'group'.  The
       
    41      collection_name argument to db.ReferenceProperty should be set to the
       
    42      singular of the entity model name of the other "group" class.  The
       
    43      above relationship names correspond, respectively to these Models:
       
    44        School, Club, Sponsor, Organization
       
    45      The relationships listed here are mutually exclusive.  For example,
       
    46      a Group cannot be both a School and a Club at the same time.
       
    47   """
       
    48 
       
    49   #: Required many:1 relationship indicating the founding User of the
       
    50   #: Group (this relationship is needed to keep track of lifetime group
       
    51   #: creation limits, used to prevent spamming, etc.).
       
    52   founder = db.ReferenceProperty(reference_class=soc.models.user.User,
       
    53                                  required=True, collection_name="groups")
       
    54 
       
    55   #: Required organization name; can only be lower ASCII, not UTF-8
       
    56   #: text, because it is used, for example, as part of the shipping
       
    57   #: address.
       
    58   name = db.StringProperty(required=True)
       
    59 
       
    60   #: Optional field used as a display name, such in Group lists displayed
       
    61   #: in the web application.  Should be the entire display name in the
       
    62   #: format the Group would like it displayed. Display names can be any
       
    63   #: valid UTF-8 text.
       
    64   displayname = db.StringProperty()
       
    65 
       
    66   #: Required email address used as the "public" contact mechanism for
       
    67   #: the Group (as opposed to the founder.id email address which is kept
       
    68   #: secret, revealed only to Developers).
       
    69   email = db.EmailProperty(required=True)
       
    70 
       
    71   #: Required home page URL.
       
    72   homepage = db.LinkProperty(required=True)
       
    73 
       
    74   # TODO(pawel.solyga): merge in the (required) mailing address stuff here...
       
    75 
       
    76   # TODO(pawel.solyga): merge in the (optional) shipping address stuff here...
       
    77 
       
    78   #: Required contact phone number that will be, amongst other uses,
       
    79   #: supplied to shippers along with the shipping address; kept private.
       
    80   phone = db.PhoneNumberProperty(required=True)
       
    81