3 # Copyright 2008 the Melange authors.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 """This module contains the Group Model."""
20 '"Todd Larsen" <tlarsen@google.com>',
21 '"Lennard de Rijk" <ljvderijk@gmail.com>',
22 '"Pawel Solyga" <pawel.solyga@gmail.com>',
26 from google
.appengine
.ext
import db
28 from django
.utils
.translation
import ugettext
30 from soc
.models
import countries
32 import soc
.models
.presence
33 import soc
.models
.user
36 class Group(soc
.models
.presence
.Presence
):
37 """Common data fields for all groups.
40 #: Required field storing name of the group.
41 name
= db
.StringProperty(required
=True,
42 verbose_name
=ugettext('Name'))
43 name
.help_text
= ugettext('Complete, formal name of the group.')
45 #: Required field storing short name of the group.
46 #: It can be used for displaying group as sidebar menu item.
47 short_name
= db
.StringProperty(required
=True,
48 verbose_name
=ugettext('Short name'))
49 short_name
.help_text
= ugettext('Short name used for sidebar menu')
51 #: Required many:1 relationship indicating the founding User of the
52 #: Group (this relationship is needed to keep track of lifetime group
53 #: creation limits, used to prevent spamming, etc.).
54 founder
= db
.ReferenceProperty(reference_class
=soc
.models
.user
.User
,
55 required
=True, collection_name
="groups",
56 verbose_name
=ugettext('Registered by'))
58 #: Required field storing a home page URL of the group.
59 home_page
= db
.LinkProperty(required
=True,
60 verbose_name
=ugettext('Home Page URL'))
62 #: Required email address used as the "public" contact mechanism for
63 #: the Group (as opposed to the founder.account email address which is
64 #: kept secret, revealed only to Developers).
65 email
= db
.EmailProperty(required
=True,
66 verbose_name
=ugettext('Email'))
67 email
.help_text
= ugettext(
68 "Enter an email address to be used by would-be members seeking "
69 "additional information. This can be an individual's email address or a "
70 "mailing list address; use whichever will work best for you.")
72 #: Required field storing description of the group.
73 description
= db
.TextProperty(required
=True,
74 verbose_name
=ugettext('Description'))
76 #: Optional public mailing list.
77 pub_mailing_list
= db
.StringProperty(required
=False,
78 verbose_name
=ugettext('Public Mailing List'))
79 pub_mailing_list
.help_text
= ugettext(
80 'Mailing list email address, URL to sign-up page, etc.')
82 #: Optional public IRC channel.
83 irc_channel
= db
.StringProperty(required
=False,
84 verbose_name
=ugettext('Public IRC Channel (and Network)'))
86 #====================================================================
87 # (private) contact information
88 #====================================================================
90 #: Required field containing a group street address.
91 #: Group street address can only be ASCII, not UTF-8 text,
92 #: because, if supplied, it might be used as a shipping address.
93 contact_street
= db
.StringProperty(required
=True,
94 verbose_name
=ugettext('Street address'))
95 contact_street
.help_text
= ugettext(
96 'street number and name, '
97 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
99 #: Required field containing group address city.
100 #: City can only be ASCII, not UTF-8 text, because, if
101 #: supplied, it might be used as a shipping address.
102 contact_city
= db
.StringProperty(required
=True,
103 verbose_name
=ugettext('City'))
104 contact_city
.help_text
= ugettext(
105 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
107 #: Required field containing group address state or province.
108 #: Group state/province can only be ASCII, not UTF-8
109 #: text, because, if supplied, it might be used as a shipping address.
110 contact_state
= db
.StringProperty(
111 verbose_name
=ugettext('State/Province'))
112 contact_state
.help_text
= ugettext(
113 'optional if country/territory does not have states or provinces, '
114 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
116 #: Required field containing address country or territory of the group.
117 contact_country
= db
.StringProperty(required
=True,
118 verbose_name
=ugettext('Country/Territory'),
119 choices
=countries
.COUNTRIES_AND_TERRITORIES
)
121 #: Required field containing address postal code of the group (ZIP code in
122 #: the United States).Postal code can only be ASCII, not UTF-8
123 #: text, because, if supplied, it might be used as a shipping address.
124 contact_postalcode
= db
.StringProperty(required
=True,
125 verbose_name
=ugettext('ZIP/Postal Code'))
126 contact_postalcode
.help_text
= ugettext(
127 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
129 #: Required contact phone number that will be, amongst other uses,
130 #: supplied to shippers along with the shipping address; kept private.
131 phone
= db
.PhoneNumberProperty(required
=True,
132 verbose_name
=ugettext('Phone Number'))
133 phone
.help_text
= ugettext(
134 'include complete international calling number with country code')
135 phone
.example_text
= ugettext(
136 "e.g. 1650253000 for Google's Corp HQ number in the United States")
138 #====================================================================
139 # (private) shipping information
140 #====================================================================
142 #: Optional field containing a group street address.
143 #: Group street address can only be ASCII, not UTF-8 text,
144 #: because, if supplied, it is used as a shipping address.
145 shipping_street
= db
.StringProperty(required
=False,
146 verbose_name
=ugettext('Shipping Street address'))
147 shipping_street
.help_text
= ugettext(
148 'street number and name, '
149 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
151 #: Optional field containing group address city.
152 #: City can only be ASCII, not UTF-8 text, because, if
153 #: supplied, it is used as a shipping address.
154 shipping_city
= db
.StringProperty(required
=False,
155 verbose_name
=ugettext('Shipping City'))
156 shipping_city
.help_text
= ugettext(
157 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
159 #: Optional field containing group address state or province.
160 #: Group state/province can only be ASCII, not UTF-8
161 #: text, because, if supplied, it is used as a shipping address.
162 shipping_state
= db
.StringProperty(
163 verbose_name
=ugettext('Shipping State/Province'))
164 shipping_state
.help_text
= ugettext(
165 'optional if country/territory does not have states or provinces, '
166 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
168 #: Optional field containing address postal code of the group (ZIP code in
169 #: the United States). Postal code can only be ASCII, not UTF-8
170 #: text, because, if supplied, it is used as a shipping address.
171 shipping_postalcode
= db
.StringProperty(required
=False,
172 verbose_name
=ugettext('Shipping ZIP/Postal Code'))
173 shipping_postalcode
.help_text
= ugettext(
174 '<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> characters only')
176 #: Optional field containing address country or territory of the group.
177 shipping_country
= db
.StringProperty(required
=False,
178 verbose_name
=ugettext('Shipping Country/Territory'),
179 choices
=countries
.COUNTRIES_AND_TERRITORIES
)
181 #: Required property showing the current status of the group
182 #: new: the group has not been active yet
183 #: active: the group is active
184 #: inactive: used to mark a group as read-only
185 #: invalid: the group has been marked as removed
186 status
= db
.StringProperty(required
=True, default
='new',
187 choices
=['new', 'active', 'inactive', 'invalid'])