app/soc/models/person.py
changeset 207 8ecc2e4198cd
parent 181 fdd29818a954
child 316 9efdc7bc3565
equal deleted inserted replaced
206:832335761384 207:8ecc2e4198cd
    19 __authors__ = [
    19 __authors__ = [
    20   '"Todd Larsen" <tlarsen@google.com>',
    20   '"Todd Larsen" <tlarsen@google.com>',
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    22 ]
    22 ]
    23 
    23 
       
    24 
    24 from google.appengine.ext import db
    25 from google.appengine.ext import db
       
    26 
       
    27 import polymodel
       
    28 
    25 from django.utils.translation import ugettext_lazy
    29 from django.utils.translation import ugettext_lazy
    26 
    30 
    27 from soc import models
       
    28 from soc.models import base
       
    29 from soc.models import countries
    31 from soc.models import countries
    30 import soc.models.user
    32 import soc.models.user
    31 
    33 
    32 
    34 
    33 class Person(base.ModelWithFieldAttributes):
    35 class Person(polymodel.PolyModel):
    34   """Common data fields for all Roles.
    36   """Common data fields for all persons on the site.
    35 
       
    36   A Person can only participate in a single Program.  To avoid duplication of
       
    37   data entry, facilities will be available for selecting an existing Person
       
    38   associated with a particular User to be duplicated for participation in a
       
    39   new Program.
       
    40 
    37 
    41   Some details of a Person are considered "public" information, and nearly
    38   Some details of a Person are considered "public" information, and nearly
    42   all of these are optional (except for given_name, surname, and email).
    39   all of these are optional (except for given_name, surname, and email).
    43   Other details of a Person are kept "private" and are only provided to
    40   Other details of a Person are kept "private" and are only provided to
    44   other Persons in roles that "need to know" this information.  How these
    41   other Persons in roles that "need to know" this information.  How these
    45   fields are revealed is usually covered by Program terms of service.
    42   fields are revealed is usually covered by Program terms of service.
    46 
       
    47   A Person entity participates in the following relationships implemented
       
    48   as a db.ReferenceProperty elsewhere in another db.Model:
       
    49 
       
    50    docs) a 1:many relationship of documents (Documentation) associated
       
    51      with the Person by Administrators.  This relation is implemented as
       
    52      the 'docs' back-reference Query of the Documentation model 'person'
       
    53      reference.
       
    54 
       
    55    works) a many:many relationship with Works, stored in a separate
       
    56      WorksPersons model.  See the WorksPersons model class for details.
       
    57 
       
    58    contributor) a 1:1 relationship associating a Contributor with generic
       
    59      Person details and capabilities.  This relation is implemented as the
       
    60      'contributor' back-reference Query of the Contributor model 'person'
       
    61      reference.
       
    62 
       
    63    reviewer) a 1:1 relationship associating a Reviewer with generic
       
    64      Person details and capabilities.  This relation is implemented as the
       
    65      'reviewer' back-reference Query of the Reviewer model 'person' reference.
       
    66 
       
    67    admin) a 1:1 relationship associating an Administrator with specific
       
    68      Person details and capabilities.  This relation is implemented as the
       
    69      'admin' back-reference Query of the Administrator model 'person'
       
    70      reference.
       
    71 
       
    72    host) a 1:1 relationship accociating a Host with specific Person
       
    73      Person details and capabilities. This relation is implemented as the
       
    74      'host' back-reference Query of the Host model 'person' reference.
       
    75   """
    43   """
    76 
    44 
    77   #: A required many:1 relationship that ties (possibly multiple
    45   #: A required many:1 relationship that ties (possibly multiple
    78   #: entities of) Person details to a unique User.  A Person cannot
    46   #: entities of) Person details to a unique User.  A Person cannot
    79   #: exist unassociated from a login identity and credentials.  The
    47   #: exist unassociated from a login identity and credentials.  The
    80   #: back-reference in the User model is a Query named 'persons'.
    48   #: back-reference in the User model is a Query named 'persons'.
    81   user = db.ReferenceProperty(reference_class=models.user.User,
    49   user = db.ReferenceProperty(reference_class=soc.models.user.User,
    82                               required=True, collection_name='persons')
    50                               required=True, collection_name='persons')
    83 
    51 
    84   #====================================================================
    52   #====================================================================
    85   #  (public) name information
    53   #  (public) name information
    86   #====================================================================
    54   #====================================================================