devtools/test/data/cubes/i18ntestcube/views.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Jul 2013 08:23:17 +0200
branchstable
changeset 9199 f66e2d331f4b
parent 9153 devtools/test/data/cubes/i18ntestcube/views/primary.py@bc1b8e77d6ce
permissions -rw-r--r--
[i18n test] simplify test cube a bit by only providing a views module, no package
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9153
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     1
# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     3
#
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     4
# This program is free software: you can redistribute it and/or modify it under
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     5
# the terms of the GNU Lesser General Public License as published by the Free
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     6
# Software Foundation, either version 2.1 of the License, or (at your option)
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     7
# any later version.
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     8
#
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
     9
# This program is distributed in the hope that it will be useful, but WITHOUT
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    11
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    12
# details.
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    13
#
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    14
# You should have received a copy of the GNU Lesser General Public License along
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    15
# with this program. If not, see <http://www.gnu.org/licenses/>.
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    16
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    17
"""cubicweb-forum views/forms/actions/components for web ui"""
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    18
9199
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    19
from cubicweb import view
9153
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    20
from cubicweb.predicates import is_instance
9199
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    21
from cubicweb.web.views import primary, baseviews, uicfg
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    22
from cubicweb.web.views.uicfg import autoform_section as afs
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    23
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    24
class MyAFS(uicfg.AutoformSectionRelationTags):
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    25
    __select__ = is_instance('ForumThread')
9153
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    26
9199
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    27
_myafs = MyAFS()
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    28
_myafs.__module__ = "cubes.i18ntestcube.views"
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    29
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    30
_myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    31
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    32
wireit_uicfg.wireit_pvs.tag_object_of(('RunChain', 'wiring', 'Wiring'), 'attributes')
f66e2d331f4b [i18n test] simplify test cube a bit by only providing a views module, no package
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    33
wireit_uicfg.wireit_afs.tag_object_of(('RunChain', 'wiring', 'Wiring'), 'main', 'hidden')
9153
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    34
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    35
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    36
class ForumSameETypeListView(baseviews.SameETypeListView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    37
    __select__ = baseviews.SameETypeListView.__select__ & is_instance('Forum')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    38
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    39
    def call(self, **kwargs):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    40
        _ = self._cw._
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    41
        _('Topic'), _('Description')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    42
        _('Number of threads'), _('Last activity')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    43
        _('''a long
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    44
tranlated line
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    45
hop.''')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    46
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    47
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    48
class ForumLastActivity(view.EntityView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    49
    __regid__ = 'forum_last_activity'
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    50
    __select__ = view.EntityView.__select__ & is_instance('Forum')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    51
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    52
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    53
class ForumPrimaryView(primary.PrimaryView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    54
    __select__ = primary.PrimaryView.__select__ & is_instance('Forum')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    55
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    56
    def render_entity_attributes(self, entity):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    57
        _ = self._cw._
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    58
        _('Subject'), _('Created'), _('Answers'),
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    59
        _('Last answered')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    60
        _('This forum does not have any thread yet.')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    61
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    62
class ForumThreadPrimaryView(primary.PrimaryView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    63
    __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')