app/soc/models/role.py
changeset 970 8b5611d5b053
parent 913 db38e7680d1c
child 1046 7e10c0654dfb
equal deleted inserted replaced
969:b12de918d660 970:8b5611d5b053
    23 ]
    23 ]
    24 
    24 
    25 
    25 
    26 from google.appengine.ext import db
    26 from google.appengine.ext import db
    27 
    27 
    28 from django.utils.translation import ugettext_lazy
    28 from django.utils.translation import ugettext
    29 
    29 
    30 from soc.models import countries
    30 from soc.models import countries
    31 
    31 
    32 import soc.models.linkable
    32 import soc.models.linkable
    33 import soc.models.user
    33 import soc.models.user
    83   #: Required field storing the parts of the Role's name
    83   #: Required field storing the parts of the Role's name
    84   #: corresponding to the field names; displayed publicly.
    84   #: corresponding to the field names; displayed publicly.
    85   #: given_name can only be lower ASCII, not UTF-8 text, because it is
    85   #: given_name can only be lower ASCII, not UTF-8 text, because it is
    86   #: used, for example, as part of the shipping (mailing) address.
    86   #: used, for example, as part of the shipping (mailing) address.
    87   given_name = db.StringProperty(required=True,
    87   given_name = db.StringProperty(required=True,
    88       verbose_name=ugettext_lazy('First (given) name'))
    88       verbose_name=ugettext('First (given) name'))
    89   given_name.help_text = ugettext_lazy('lower ASCII characters only')
    89   given_name.help_text = ugettext('lower ASCII characters only')
    90 
    90 
    91   #: Required field storing the parts of the Role's name
    91   #: Required field storing the parts of the Role's name
    92   #: corresponding to the field names; displayed publicly.
    92   #: corresponding to the field names; displayed publicly.
    93   #: Surname can only be lower ASCII, not UTF-8 text, because it is
    93   #: Surname can only be lower ASCII, not UTF-8 text, because it is
    94   #: used, for example, as part of the shipping (mailing) address.
    94   #: used, for example, as part of the shipping (mailing) address.
    95   surname = db.StringProperty(
    95   surname = db.StringProperty(
    96       required=True,
    96       required=True,
    97       verbose_name=ugettext_lazy('Last (family) name'))
    97       verbose_name=ugettext('Last (family) name'))
    98   surname.help_text = ugettext_lazy('lower ASCII characters only')
    98   surname.help_text = ugettext('lower ASCII characters only')
    99 
    99 
   100   #: Optional field used as a display name, such as for awards
   100   #: Optional field used as a display name, such as for awards
   101   #: certificates. Should be the entire display name in the format
   101   #: certificates. Should be the entire display name in the format
   102   #: the Role would like it displayed (could be surname followed by
   102   #: the Role would like it displayed (could be surname followed by
   103   #: given name in some cultures, for example). Display names can be
   103   #: given name in some cultures, for example). Display names can be
   104   #: any valid UTF-8 text.
   104   #: any valid UTF-8 text.
   105   display_name = db.StringProperty(
   105   display_name = db.StringProperty(
   106       verbose_name=ugettext_lazy('Display Name'))
   106       verbose_name=ugettext('Display Name'))
   107   display_name.help_text = ugettext_lazy(
   107   display_name.help_text = ugettext(
   108       'Optional field used as a display name, such as for awards '
   108       'Optional field used as a display name, such as for awards '
   109       'certificates. Should be the entire display name in the format '
   109       'certificates. Should be the entire display name in the format '
   110       'the person would like it displayed (could be family name followed '
   110       'the person would like it displayed (could be family name followed '
   111       'by given name in some cultures, for example). Display names can be '
   111       'by given name in some cultures, for example). Display names can be '
   112       'any valid UTF-8 text.')
   112       'any valid UTF-8 text.')
   118   #: Required field used as the 'public' contact mechanism for the
   118   #: Required field used as the 'public' contact mechanism for the
   119   #: Role (as opposed to the user.account email address which is
   119   #: Role (as opposed to the user.account email address which is
   120   #: kept secret).
   120   #: kept secret).
   121   email = db.EmailProperty(
   121   email = db.EmailProperty(
   122       required=True,
   122       required=True,
   123       verbose_name=ugettext_lazy('Email Address'))
   123       verbose_name=ugettext('Email Address'))
   124 
   124 
   125   #: Optional field storing Instant Messaging network; displayed publicly.
   125   #: Optional field storing Instant Messaging network; displayed publicly.
   126   im_network = db.StringProperty(
   126   im_network = db.StringProperty(
   127       verbose_name=ugettext_lazy('IM Network'))
   127       verbose_name=ugettext('IM Network'))
   128   im_network.help_text = ugettext_lazy(
   128   im_network.help_text = ugettext(
   129       'examples: irc:irc.freenode.org xmpp:gmail.com/Home')
   129       'examples: irc:irc.freenode.org xmpp:gmail.com/Home')
   130 
   130 
   131   #: Optional field storing Instant Messaging handle; displayed publicly.
   131   #: Optional field storing Instant Messaging handle; displayed publicly.
   132   im_handle = db.StringProperty(
   132   im_handle = db.StringProperty(
   133       verbose_name=ugettext_lazy('IM Handle'))
   133       verbose_name=ugettext('IM Handle'))
   134   im_handle.help_text = ugettext_lazy(
   134   im_handle.help_text = ugettext(
   135       'personal identifier, such as: screen name, IRC nick, user name')
   135       'personal identifier, such as: screen name, IRC nick, user name')
   136 
   136 
   137   #: Optional field storing a home page URL; displayed publicly.
   137   #: Optional field storing a home page URL; displayed publicly.
   138   home_page = db.LinkProperty(
   138   home_page = db.LinkProperty(
   139       verbose_name=ugettext_lazy('Home Page URL'))
   139       verbose_name=ugettext('Home Page URL'))
   140 
   140 
   141   #: Optional field storing a blog URL; displayed publicly.
   141   #: Optional field storing a blog URL; displayed publicly.
   142   blog = db.LinkProperty(
   142   blog = db.LinkProperty(
   143       verbose_name=ugettext_lazy('Blog URL'))
   143       verbose_name=ugettext('Blog URL'))
   144 
   144 
   145   #: Optional field storing a URL to an image, expected to be a
   145   #: Optional field storing a URL to an image, expected to be a
   146   #: personal photo (or cartoon avatar, perhaps); displayed publicly.
   146   #: personal photo (or cartoon avatar, perhaps); displayed publicly.
   147   photo_url = db.LinkProperty(
   147   photo_url = db.LinkProperty(
   148       verbose_name=ugettext_lazy('Thumbnail Photo URL'))
   148       verbose_name=ugettext('Thumbnail Photo URL'))
   149   photo_url.help_text = ugettext_lazy(
   149   photo_url.help_text = ugettext(
   150       'URL of 64x64 pixel thumbnail image')
   150       'URL of 64x64 pixel thumbnail image')
   151 
   151 
   152   #: Optional field storing the latitude provided by the Role; displayed
   152   #: Optional field storing the latitude provided by the Role; displayed
   153   #: publicly.
   153   #: publicly.
   154   latitude = db.FloatProperty(
   154   latitude = db.FloatProperty(
   155       verbose_name=ugettext_lazy('Latitude'))
   155       verbose_name=ugettext('Latitude'))
   156   latitude.help_text = ugettext_lazy(
   156   latitude.help_text = ugettext(
   157       'decimal degrees northerly (N), use minus sign (-) for southerly (S)')
   157       'decimal degrees northerly (N), use minus sign (-) for southerly (S)')
   158 
   158 
   159   #: Optional field storing the longitude provided by the Role; displayed
   159   #: Optional field storing the longitude provided by the Role; displayed
   160   #: publicly.
   160   #: publicly.
   161   longitude = db.FloatProperty(
   161   longitude = db.FloatProperty(
   162       verbose_name=ugettext_lazy('Longitude'))
   162       verbose_name=ugettext('Longitude'))
   163   longitude.help_text = ugettext_lazy(
   163   longitude.help_text = ugettext(
   164       'decimal degrees easterly (E), use minus sign (-) for westerly (W)')
   164       'decimal degrees easterly (E), use minus sign (-) for westerly (W)')
   165 
   165 
   166   #====================================================================
   166   #====================================================================
   167   # (private) contact information
   167   # (private) contact information
   168   #====================================================================
   168   #====================================================================
   169 
   169 
   170   #: Required field containing residence street address; kept private.
   170   #: Required field containing residence street address; kept private.
   171   #: Residence street address can only be lower ASCII, not UTF-8 text, because
   171   #: Residence street address can only be lower ASCII, not UTF-8 text, because
   172   #: it may be used as a shipping address.
   172   #: it may be used as a shipping address.
   173   res_street = db.StringProperty(required=True,
   173   res_street = db.StringProperty(required=True,
   174       verbose_name=ugettext_lazy('Street address'))
   174       verbose_name=ugettext('Street address'))
   175   res_street.help_text = ugettext_lazy(
   175   res_street.help_text = ugettext(
   176       'street number and name, lower ASCII characters only')
   176       'street number and name, lower ASCII characters only')
   177 
   177 
   178   #: Required field containing residence address city; kept private.
   178   #: Required field containing residence address city; kept private.
   179   #: Residence city can only be lower ASCII, not UTF-8 text, because it
   179   #: Residence city can only be lower ASCII, not UTF-8 text, because it
   180   #: may be used as a shipping address.
   180   #: may be used as a shipping address.
   181   res_city = db.StringProperty(required=True,
   181   res_city = db.StringProperty(required=True,
   182       verbose_name=ugettext_lazy('City'))
   182       verbose_name=ugettext('City'))
   183   res_city.help_text = ugettext_lazy('lower ASCII characters only')
   183   res_city.help_text = ugettext('lower ASCII characters only')
   184 
   184 
   185   #: Optional field containing residence address state or province; kept
   185   #: Optional field containing residence address state or province; kept
   186   #: private.  Residence state/province can only be lower ASCII, not UTF-8
   186   #: private.  Residence state/province can only be lower ASCII, not UTF-8
   187   #: text, because it may be used as a shipping address.
   187   #: text, because it may be used as a shipping address.
   188   res_state = db.StringProperty(
   188   res_state = db.StringProperty(
   189       verbose_name=ugettext_lazy('State/Province'))
   189       verbose_name=ugettext('State/Province'))
   190   res_state.help_text = ugettext_lazy(
   190   res_state.help_text = ugettext(
   191       'optional if country/territory does not have states or provinces, '
   191       'optional if country/territory does not have states or provinces, '
   192       'lower ASCII characters only')
   192       'lower ASCII characters only')
   193 
   193 
   194   #: Required field containing residence address country or territory; kept
   194   #: Required field containing residence address country or territory; kept
   195   #: private.
   195   #: private.
   196   res_country = db.StringProperty(required=True,
   196   res_country = db.StringProperty(required=True,
   197       verbose_name=ugettext_lazy('Country/Territory'),
   197       verbose_name=ugettext('Country/Territory'),
   198       choices=countries.COUNTRIES_AND_TERRITORIES)
   198       choices=countries.COUNTRIES_AND_TERRITORIES)
   199 
   199 
   200   #: Required field containing residence address postal code (ZIP code in
   200   #: Required field containing residence address postal code (ZIP code in
   201   #: the United States); kept private.  Residence postal code can only be
   201   #: the United States); kept private.  Residence postal code can only be
   202   #: lower ASCII, not UTF-8 text, because it may be used as a shipping address.
   202   #: lower ASCII, not UTF-8 text, because it may be used as a shipping address.
   203   res_postalcode = db.StringProperty(required=True,
   203   res_postalcode = db.StringProperty(required=True,
   204       verbose_name=ugettext_lazy('ZIP/Postal Code'))
   204       verbose_name=ugettext('ZIP/Postal Code'))
   205   res_postalcode.help_text = ugettext_lazy('lower ASCII characters only')
   205   res_postalcode.help_text = ugettext('lower ASCII characters only')
   206 
   206 
   207   #: Optional field containing a separate shipping street address; kept
   207   #: Optional field containing a separate shipping street address; kept
   208   #: private.  If shipping address is not present in its entirety, the
   208   #: private.  If shipping address is not present in its entirety, the
   209   #: residence address will be used instead.  Shipping street address can only
   209   #: residence address will be used instead.  Shipping street address can only
   210   #: be lower ASCII, not UTF-8 text, because, if supplied, it is used as a
   210   #: be lower ASCII, not UTF-8 text, because, if supplied, it is used as a
   211   #: shipping address.
   211   #: shipping address.
   212   ship_street = db.StringProperty(
   212   ship_street = db.StringProperty(
   213       verbose_name=ugettext_lazy('Shipping Street address'))
   213       verbose_name=ugettext('Shipping Street address'))
   214   ship_street.help_text = ugettext_lazy(
   214   ship_street.help_text = ugettext(
   215       'street number and name, lower ASCII characters only')
   215       'street number and name, lower ASCII characters only')
   216 
   216 
   217   #: Optional field containing shipping address city; kept private.
   217   #: Optional field containing shipping address city; kept private.
   218   #: Shipping city can only be lower ASCII, not UTF-8 text, because, if
   218   #: Shipping city can only be lower ASCII, not UTF-8 text, because, if
   219   #: supplied, it is used as a shipping address.
   219   #: supplied, it is used as a shipping address.
   220   ship_city = db.StringProperty(
   220   ship_city = db.StringProperty(
   221       verbose_name=ugettext_lazy('Shipping City'))
   221       verbose_name=ugettext('Shipping City'))
   222   ship_city.help_text = ugettext_lazy('lower ASCII characters only')
   222   ship_city.help_text = ugettext('lower ASCII characters only')
   223 
   223 
   224   #: Optional field containing shipping address state or province; kept
   224   #: Optional field containing shipping address state or province; kept
   225   #: private.  Shipping state/province can only be lower ASCII, not UTF-8
   225   #: private.  Shipping state/province can only be lower ASCII, not UTF-8
   226   #: text, because, if supplied, it is used as a shipping address.
   226   #: text, because, if supplied, it is used as a shipping address.
   227   ship_state = db.StringProperty(
   227   ship_state = db.StringProperty(
   228       verbose_name=ugettext_lazy('Shipping State/Province'))
   228       verbose_name=ugettext('Shipping State/Province'))
   229   ship_state.help_text = ugettext_lazy(
   229   ship_state.help_text = ugettext(
   230       'optional if country/territory does not have states or provinces, '
   230       'optional if country/territory does not have states or provinces, '
   231       'lower ASCII characters only')
   231       'lower ASCII characters only')
   232 
   232 
   233   #: Optional field containing shipping address country or territory; kept
   233   #: Optional field containing shipping address country or territory; kept
   234   #: private.
   234   #: private.
   235   ship_country = db.StringProperty(
   235   ship_country = db.StringProperty(
   236       verbose_name=ugettext_lazy('Shipping Country/Territory'),
   236       verbose_name=ugettext('Shipping Country/Territory'),
   237       choices=countries.COUNTRIES_AND_TERRITORIES)
   237       choices=countries.COUNTRIES_AND_TERRITORIES)
   238 
   238 
   239   #: Optional field containing shipping address postal code (ZIP code in
   239   #: Optional field containing shipping address postal code (ZIP code in
   240   #: the United States); kept private.  Shipping postal code can only be
   240   #: the United States); kept private.  Shipping postal code can only be
   241   #: lower ASCII, not UTF-8 text, because, if supplied, it is used as a
   241   #: lower ASCII, not UTF-8 text, because, if supplied, it is used as a
   242   #: shipping address.
   242   #: shipping address.
   243   ship_postalcode = db.StringProperty(
   243   ship_postalcode = db.StringProperty(
   244       verbose_name=ugettext_lazy('Shipping ZIP/Postal Code'))
   244       verbose_name=ugettext('Shipping ZIP/Postal Code'))
   245   ship_postalcode.help_text = ugettext_lazy('lower ASCII characters only')
   245   ship_postalcode.help_text = ugettext('lower ASCII characters only')
   246 
   246 
   247   #: Required field containing a phone number that will be supplied
   247   #: Required field containing a phone number that will be supplied
   248   #: to shippers; kept private.
   248   #: to shippers; kept private.
   249   phone = db.PhoneNumberProperty(
   249   phone = db.PhoneNumberProperty(
   250       required=True,
   250       required=True,
   251       verbose_name=ugettext_lazy('Phone Number'))
   251       verbose_name=ugettext('Phone Number'))
   252   phone.help_text = ugettext_lazy(
   252   phone.help_text = ugettext(
   253       'include complete international calling number with country code')
   253       'include complete international calling number with country code')
   254 
   254 
   255   #====================================================================
   255   #====================================================================
   256   # (private) personal information
   256   # (private) personal information
   257   #====================================================================
   257   #====================================================================
   258 
   258 
   259   #: Required field containing the Role's birthdate (for
   259   #: Required field containing the Role's birthdate (for
   260   #: determining Program participation eligibility); kept private.
   260   #: determining Program participation eligibility); kept private.
   261   birth_date = db.DateProperty(
   261   birth_date = db.DateProperty(
   262       required=True,
   262       required=True,
   263       verbose_name=ugettext_lazy('Birth Date'))
   263       verbose_name=ugettext('Birth Date'))
   264   birth_date.help_text = ugettext_lazy(
   264   birth_date.help_text = ugettext(
   265       'required for determining program eligibility')
   265       'required for determining program eligibility')
   266 
   266 
   267   #: Optional field indicating choice of t-shirt, from XXS to XXXL;
   267   #: Optional field indicating choice of t-shirt, from XXS to XXXL;
   268   #: kept private.
   268   #: kept private.
   269   tshirt_size = db.StringProperty(
   269   tshirt_size = db.StringProperty(
   270       verbose_name=ugettext_lazy('T-shirt Size'),
   270       verbose_name=ugettext('T-shirt Size'),
   271       choices=('XXS', 'XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'))
   271       choices=('XXS', 'XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'))
   272 
   272 
   273   #: Optional field indicating choice of t-shirt fit; kept private.
   273   #: Optional field indicating choice of t-shirt fit; kept private.
   274   tshirt_style = db.StringProperty(
   274   tshirt_style = db.StringProperty(
   275       verbose_name=ugettext_lazy('T-shirt Style'),
   275       verbose_name=ugettext('T-shirt Style'),
   276       choices=('male', 'female'))
   276       choices=('male', 'female'))
   277 
   277 
   278   #: field storing whether User has agreed to the Role-specific Terms of
   278   #: field storing whether User has agreed to the Role-specific Terms of
   279   #: Service. (Not a required field because some Roles may not have special
   279   #: Service. (Not a required field because some Roles may not have special
   280   #: Terms of Service.)
   280   #: Terms of Service.)
   281   agrees_to_tos = db.BooleanProperty(
   281   agrees_to_tos = db.BooleanProperty(
   282       verbose_name=ugettext_lazy('Agrees to ToS'))
   282       verbose_name=ugettext('Agrees to ToS'))
   283   agrees_to_tos.help_text = ugettext_lazy(
   283   agrees_to_tos.help_text = ugettext(
   284       'Indicates that the user agrees to the Terms of Service for this Role.')
   284       'Indicates that the user agrees to the Terms of Service for this Role.')
   285 
   285 
   286   #: field storing the state of this role
   286   #: field storing the state of this role
   287   #: Active means that this role can exercise all it's privileges.
   287   #: Active means that this role can exercise all it's privileges.
   288   #: Invalid mean that this role cannot exercise it's privileges.
   288   #: Invalid mean that this role cannot exercise it's privileges.
   290   #: privileges but should be able to see the data. For instance when a program
   290   #: privileges but should be able to see the data. For instance when a program
   291   #: has been marked inactive an Organization Admin should still be able to see
   291   #: has been marked inactive an Organization Admin should still be able to see
   292   #: the student applications.
   292   #: the student applications.
   293   state = db.StringProperty(default='active',
   293   state = db.StringProperty(default='active',
   294       choices=['active','invalid','inactive'],
   294       choices=['active','invalid','inactive'],
   295       verbose_name=ugettext_lazy('State of this Role'))
   295       verbose_name=ugettext('State of this Role'))
   296   state.help_text = ugettext_lazy(
   296   state.help_text = ugettext(
   297       'Indicates the state of the role concerning which privileges may be used')
   297       'Indicates the state of the role concerning which privileges may be used')
   298 
   298 
   299 
   299 
   300   def name(self):
   300   def name(self):
   301     """Alias 'display_name' Property as 'name' for use in common templates.
   301     """Alias 'display_name' Property as 'name' for use in common templates.