cubicweb/devtools/test/data/libpython/cubicweb_i18ntestcube/views.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 08 Mar 2019 11:52:31 +0100
branch3.26
changeset 12487 76f7753e81a2
parent 12486 d189d10e2469
permissions -rw-r--r--
[flake8] fix errors in cubicweb_i18ntestcube/views.py test file
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
9201
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
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
9201
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    21
from cubicweb.web.views import primary, baseviews, uicfg
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    22
from cubicweb.web.views.uicfg import autoform_section as afs
9153
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    23
12487
76f7753e81a2 [flake8] fix errors in cubicweb_i18ntestcube/views.py test file
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12486
diff changeset
    24
9201
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    25
class MyAFS(uicfg.AutoformSectionRelationTags):
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    26
    __select__ = is_instance('ForumThread')
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    27
12487
76f7753e81a2 [flake8] fix errors in cubicweb_i18ntestcube/views.py test file
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12486
diff changeset
    28
12486
d189d10e2469 [test] Pass __module__ upon instantiation of RegistrableInstance
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11460
diff changeset
    29
_myafs = MyAFS(__module__=__name__)
9202
83f73a9746f6 [i18n test] hack to make i18n tests run using a Python interpreter
David Douard <david.douard@logilab.fr>
parents: 9201
diff changeset
    30
9201
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    31
_myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    32
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    33
afs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
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
12487
76f7753e81a2 [flake8] fix errors in cubicweb_i18ntestcube/views.py test file
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12486
diff changeset
    62
9153
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    63
class ForumThreadPrimaryView(primary.PrimaryView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    64
    __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')