devtools/test/data/cubes/i18ntestcube/views.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     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 class MyAFS(uicfg.AutoformSectionRelationTags):
       
    25     __select__ = is_instance('ForumThread')
       
    26 
       
    27 _myafs = MyAFS()
       
    28 
       
    29 _myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
       
    30 
       
    31 afs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
       
    32 
       
    33 
       
    34 class ForumSameETypeListView(baseviews.SameETypeListView):
       
    35     __select__ = baseviews.SameETypeListView.__select__ & is_instance('Forum')
       
    36 
       
    37     def call(self, **kwargs):
       
    38         _ = self._cw._
       
    39         _('Topic'), _('Description')
       
    40         _('Number of threads'), _('Last activity')
       
    41         _('''a long
       
    42 tranlated line
       
    43 hop.''')
       
    44 
       
    45 
       
    46 class ForumLastActivity(view.EntityView):
       
    47     __regid__ = 'forum_last_activity'
       
    48     __select__ = view.EntityView.__select__ & is_instance('Forum')
       
    49 
       
    50 
       
    51 class ForumPrimaryView(primary.PrimaryView):
       
    52     __select__ = primary.PrimaryView.__select__ & is_instance('Forum')
       
    53 
       
    54     def render_entity_attributes(self, entity):
       
    55         _ = self._cw._
       
    56         _('Subject'), _('Created'), _('Answers'),
       
    57         _('Last answered')
       
    58         _('This forum does not have any thread yet.')
       
    59 
       
    60 class ForumThreadPrimaryView(primary.PrimaryView):
       
    61     __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')