cubicweb/devtools/test/data/cubes/i18ntestcube/views.py
branch3.26
changeset 12706 7ed069414b27
parent 12487 76f7753e81a2
equal deleted inserted replaced
12705:e5e4b6de1800 12706:7ed069414b27
       
     1 # copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This program is free software: you can redistribute it and/or modify it under
       
     5 # the terms of the GNU Lesser General Public License as published by the Free
       
     6 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     7 # any later version.
       
     8 #
       
     9 # This program is distributed in the hope that it will be useful, but WITHOUT
       
    10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
       
    12 # details.
       
    13 #
       
    14 # You should have received a copy of the GNU Lesser General Public License along
       
    15 # with this program. If not, see <http://www.gnu.org/licenses/>.
       
    16 
       
    17 """cubicweb-forum views/forms/actions/components for web ui"""
       
    18 
       
    19 from cubicweb import view
       
    20 from cubicweb.predicates import is_instance
       
    21 from cubicweb.web.views import primary, baseviews, uicfg
       
    22 from cubicweb.web.views.uicfg import autoform_section as afs
       
    23 
       
    24 
       
    25 class MyAFS(uicfg.AutoformSectionRelationTags):
       
    26     __select__ = is_instance('ForumThread')
       
    27 
       
    28 
       
    29 _myafs = MyAFS(__module__=__name__)
       
    30 
       
    31 _myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
       
    32 
       
    33 afs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
       
    34 
       
    35 
       
    36 class ForumSameETypeListView(baseviews.SameETypeListView):
       
    37     __select__ = baseviews.SameETypeListView.__select__ & is_instance('Forum')
       
    38 
       
    39     def call(self, **kwargs):
       
    40         _ = self._cw._
       
    41         _('Topic'), _('Description')
       
    42         _('Number of threads'), _('Last activity')
       
    43         _('''a long
       
    44 tranlated line
       
    45 hop.''')
       
    46 
       
    47 
       
    48 class ForumLastActivity(view.EntityView):
       
    49     __regid__ = 'forum_last_activity'
       
    50     __select__ = view.EntityView.__select__ & is_instance('Forum')
       
    51 
       
    52 
       
    53 class ForumPrimaryView(primary.PrimaryView):
       
    54     __select__ = primary.PrimaryView.__select__ & is_instance('Forum')
       
    55 
       
    56     def render_entity_attributes(self, entity):
       
    57         _ = self._cw._
       
    58         _('Subject'), _('Created'), _('Answers'),
       
    59         _('Last answered')
       
    60         _('This forum does not have any thread yet.')
       
    61 
       
    62 
       
    63 class ForumThreadPrimaryView(primary.PrimaryView):
       
    64     __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')