app/soc/models/work.py
changeset 970 8b5611d5b053
parent 621 21aea6e45a9d
child 1091 0e648c690bb7
equal deleted inserted replaced
969:b12de918d660 970:8b5611d5b053
    22 ]
    22 ]
    23 
    23 
    24 
    24 
    25 from google.appengine.ext import db
    25 from google.appengine.ext import db
    26 
    26 
    27 from django.utils.translation import ugettext_lazy
    27 from django.utils.translation import ugettext
    28 
    28 
    29 import soc.models.linkable
    29 import soc.models.linkable
    30 import soc.models.user
    30 import soc.models.user
    31 
    31 
    32 
    32 
    45   #: Work (this relationship is needed to keep track of lifetime document
    45   #: Work (this relationship is needed to keep track of lifetime document
    46   #: creation limits, used to prevent spamming, etc.).
    46   #: creation limits, used to prevent spamming, etc.).
    47   author = db.ReferenceProperty(reference_class=soc.models.user.User,
    47   author = db.ReferenceProperty(reference_class=soc.models.user.User,
    48                                 required=True,
    48                                 required=True,
    49                                 collection_name="created_documents",
    49                                 collection_name="created_documents",
    50                                 verbose_name=ugettext_lazy('Created by'))
    50                                 verbose_name=ugettext('Created by'))
    51 
    51 
    52   #: Required field indicating the "title" of the work, which may have
    52   #: Required field indicating the "title" of the work, which may have
    53   #: different uses depending on the specific type of the work. Works
    53   #: different uses depending on the specific type of the work. Works
    54   #: can be indexed, filtered, and sorted by 'title'.
    54   #: can be indexed, filtered, and sorted by 'title'.
    55   title = db.StringProperty(required=True,
    55   title = db.StringProperty(required=True,
    56       verbose_name=ugettext_lazy('Title'))
    56       verbose_name=ugettext('Title'))
    57   title.help_text = ugettext_lazy(
    57   title.help_text = ugettext(
    58       'title of the document; often used in the window title')
    58       'title of the document; often used in the window title')
    59 
    59 
    60   #: short name used in places such as the sidebar menu and breadcrumb trail
    60   #: short name used in places such as the sidebar menu and breadcrumb trail
    61   #: (optional: title will be used if short_name is not present)
    61   #: (optional: title will be used if short_name is not present)
    62   short_name = db.StringProperty(verbose_name=ugettext_lazy('Short name'))
    62   short_name = db.StringProperty(verbose_name=ugettext('Short name'))
    63   short_name.help_text = ugettext_lazy(
    63   short_name.help_text = ugettext(
    64       'short name used, for example, in the sidebar menu')
    64       'short name used, for example, in the sidebar menu')
    65 
    65 
    66   #: Required db.TextProperty containing the contents of the Work.
    66   #: Required db.TextProperty containing the contents of the Work.
    67   #: The content is only to be displayed to Persons in Roles eligible to
    67   #: The content is only to be displayed to Persons in Roles eligible to
    68   #: view them (which may be anyone, for example, with the site front page).
    68   #: view them (which may be anyone, for example, with the site front page).
    69   content = db.TextProperty(verbose_name=ugettext_lazy('Content'))
    69   content = db.TextProperty(verbose_name=ugettext('Content'))
    70   
    70   
    71   #: date when the work was created
    71   #: date when the work was created
    72   created = db.DateTimeProperty(auto_now_add=True)
    72   created = db.DateTimeProperty(auto_now_add=True)
    73   
    73   
    74   #: date when the work was last modified
    74   #: date when the work was last modified
    76   
    76   
    77   # indicating wich user last modified the work. Used in displaying Work
    77   # indicating wich user last modified the work. Used in displaying Work
    78   modified_by = db.ReferenceProperty(reference_class=soc.models.user.User,
    78   modified_by = db.ReferenceProperty(reference_class=soc.models.user.User,
    79                                      required=True,
    79                                      required=True,
    80                                      collection_name="modified_documents",
    80                                      collection_name="modified_documents",
    81                                      verbose_name=ugettext_lazy('Modified by'))
    81                                      verbose_name=ugettext('Modified by'))
    82 
    82 
    83   # TODO: some sort of access control preferences are needed at this basic
    83   # TODO: some sort of access control preferences are needed at this basic
    84   #   level.  Works need to be restrict-able to:
    84   #   level.  Works need to be restrict-able to:
    85   #    * the authors only
    85   #    * the authors only
    86   #    * the administrators of the Groups that the authors are in
    86   #    * the administrators of the Groups that the authors are in
    92 
    92 
    93   #: field storing whether a link to the Work should be featured in
    93   #: field storing whether a link to the Work should be featured in
    94   #: the sidebar menu (and possibly elsewhere); FAQs, Terms of Service,
    94   #: the sidebar menu (and possibly elsewhere); FAQs, Terms of Service,
    95   #: and the like are examples of "featured" Works
    95   #: and the like are examples of "featured" Works
    96   is_featured = db.BooleanProperty(
    96   is_featured = db.BooleanProperty(
    97       verbose_name=ugettext_lazy('Is Featured'))
    97       verbose_name=ugettext('Is Featured'))
    98   is_featured.help_text = ugettext_lazy(
    98   is_featured.help_text = ugettext(
    99       'Field used to indicate if a Work should be featured, for example,'
    99       'Field used to indicate if a Work should be featured, for example,'
   100       ' in the sidebar menu.')
   100       ' in the sidebar menu.')
   101 
   101 
   102   def name(self):
   102   def name(self):
   103     """Alias 'title' Property as 'name' for use in common templates.
   103     """Alias 'title' Property as 'name' for use in common templates.