|
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 Person Model.""" |
|
18 |
|
19 __authors__ = [ |
|
20 '"Todd Larsen" <tlarsen@google.com>', |
|
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 ] |
|
23 |
|
24 from google.appengine.ext import db |
|
25 |
|
26 from soc import models |
|
27 import soc.models.user |
|
28 |
|
29 |
|
30 class Person(db.Model): |
|
31 """Common data fields for all Roles. |
|
32 |
|
33 A Person can only participate in a single Program. To avoid duplication of |
|
34 data entry, facilities will be available for selecting an existing Person |
|
35 associated with a particular User to be duplicated for participation in a |
|
36 new Program. |
|
37 |
|
38 Some details of a Person are considered "public" information, and nearly |
|
39 all of these are optional (except for givenname, surname, and email). |
|
40 Other details of a Person are kept "private" and are only provided to |
|
41 other Persons in roles that "need to know" this information. How these |
|
42 fields are revealed is usually covered by Program terms of service. |
|
43 |
|
44 A Person entity participates in a number of relationships: |
|
45 |
|
46 author) a 1:1 relationship of Person details for a specific Author. |
|
47 This relation is implemented as the 'author' back-reference Query of |
|
48 the Author model 'person' reference. |
|
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 """ |
|
56 |
|
57 #: A required many:1 relationship that ties (possibly multiple |
|
58 #: entities of) Person details to a unique User. A Person cannot |
|
59 #: exist unassociated from a login identity and credentials. The |
|
60 #: back-reference in the User model is a Query named 'persons'. |
|
61 user = db.ReferenceProperty(reference_class=models.user.User, |
|
62 required=True, |
|
63 collection_name="persons") |
|
64 |
|
65 #==================================================================== |
|
66 # (public) name information |
|
67 #==================================================================== |
|
68 |
|
69 #: Required field storing the parts of the Person's name |
|
70 #: corresponding to the field names; displayed publicly. |
|
71 #: Givenname can only be lower ASCII, not UTF-8 text, because it is |
|
72 #: used, for example, as part of the shipping (mailing) address. |
|
73 givenname = db.StringProperty(required=True) |
|
74 |
|
75 #: Required field storing the parts of the Person's name |
|
76 #: corresponding to the field names; displayed publicly. |
|
77 #: Surname can only be lower ASCII, not UTF-8 text, because it is |
|
78 #: used, for example, as part of the shipping (mailing) address. |
|
79 surname = db.StringProperty(required=True) # last name |
|
80 |
|
81 #: Optional field storing a nickname; displayed publicly. |
|
82 #: Nicknames can be any valid UTF-8 text. |
|
83 nickname = db.StringProperty() |
|
84 |
|
85 #: optional field used as a display name, such as for awards |
|
86 #: certificates. Should be the entire display name in the format |
|
87 #: the Person would like it displayed (could be surname followed by |
|
88 #: given name in some cultures, for example). Display names can be |
|
89 #: any valid UTF-8 text. |
|
90 displayname = db.StringProperty() |
|
91 |
|
92 #==================================================================== |
|
93 # (public) contact information |
|
94 #==================================================================== |
|
95 |
|
96 #: Required field used as the "public" contact mechanism for the |
|
97 #: Person (as opposed to the user.id email address which is |
|
98 #: kept secret). |
|
99 email = db.EmailProperty(required=True) |
|
100 |
|
101 #: Optional field storing Instant Messaging network contact |
|
102 #: information; displayed publicly. |
|
103 im = db.IMProperty() |
|
104 |
|
105 #: Optional field storing a home page URL; displayed publicly. |
|
106 homepage = db.LinkProperty() |
|
107 |
|
108 #: Optional field storing a blog URL; displayed publicly. |
|
109 blog = db.LinkProperty() |
|
110 |
|
111 #: Optional field storing a URL to an image, expected to be a |
|
112 #: personal photo (or cartoon avatar, perhaps); displayed publicly. |
|
113 photo = db.LinkProperty() |
|
114 |
|
115 #: Optional field storing the latitude and longitude provided by |
|
116 #: the Person; displayed publicly. |
|
117 location = db.GeoPtProperty() |
|
118 |
|
119 #==================================================================== |
|
120 # (private) contact information |
|
121 #==================================================================== |
|
122 |
|
123 #: Required field containing residence address; kept private. |
|
124 residence = db.PostalAddressProperty(required=True) |
|
125 |
|
126 #: Optional field containg a separate shipping; kept private. |
|
127 shipping = db.PostalAddressProperty() |
|
128 |
|
129 #: Required field containing a phone number that will be supplied |
|
130 #: to shippers; kept private. |
|
131 phone = db.PhoneNumberProperty(required=True) |
|
132 |
|
133 #==================================================================== |
|
134 # (private) personal information |
|
135 #==================================================================== |
|
136 |
|
137 #: Required field containing the Person's birthdate (for |
|
138 #: determining Program participation eligibility); kept private. |
|
139 birthdate = db.DateProperty(required=True) |
|
140 |
|
141 #: Optional field indicating choice of t-shirt, from XXS to XXXL; |
|
142 #: kept private. |
|
143 tshirtsize = db.StringProperty( |
|
144 choices=set(("XXS", "XS", "S", "M", "L", "XL", "XXL", "XXXL"))) |
|
145 |
|
146 #: Optional field indicating choice of male or t-shirt |
|
147 #: fit; kept private. |
|
148 tshirt_gender = db.StringProperty(choices=set(("male", "female"))) |
|
149 |