devtools/test/data/cubes/i18ntestcube/views.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Jul 2013 10:06:06 +0200
branchstable
changeset 9201 b0f6e8c14e7f
parent 9153 devtools/test/data/cubes/i18ntestcube/views/primary.py@bc1b8e77d6ce
child 9202 83f73a9746f6
permissions -rw-r--r--
[i18ncube] fix crash due to duplicated messages in generated schema.pot Add a test case and fix regression introduced in e713c47a993d. Relates to #2811282
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
9201
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    24
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
    25
    __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
    26
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    27
_myafs = MyAFS()
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    28
_myafs.__module__ = "cubes.i18ntestcube.views"
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    29
_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
    30
b0f6e8c14e7f [i18ncube] fix crash due to duplicated messages in generated schema.pot
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9153
diff changeset
    31
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
    32
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    33
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    34
class ForumSameETypeListView(baseviews.SameETypeListView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    35
    __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
    36
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    37
    def call(self, **kwargs):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    38
        _ = self._cw._
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    39
        _('Topic'), _('Description')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    40
        _('Number of threads'), _('Last activity')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    41
        _('''a long
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    42
tranlated line
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    43
hop.''')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    44
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    45
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    46
class ForumLastActivity(view.EntityView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    47
    __regid__ = 'forum_last_activity'
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    48
    __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
    49
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    50
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    51
class ForumPrimaryView(primary.PrimaryView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    52
    __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
    53
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    54
    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
    55
        _ = self._cw._
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    56
        _('Subject'), _('Created'), _('Answers'),
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    57
        _('Last answered')
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    58
        _('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
    59
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    60
class ForumThreadPrimaryView(primary.PrimaryView):
bc1b8e77d6ce [test/devctl] add a test case for i18ncube command
David Douard <david.douard@logilab.fr>
parents:
diff changeset
    61
    __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')