|
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 _myafs.__module__ = "cubes.i18ntestcube.views" |
|
29 |
|
30 _myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined') |
|
31 |
|
32 wireit_uicfg.wireit_pvs.tag_object_of(('RunChain', 'wiring', 'Wiring'), 'attributes') |
|
33 wireit_uicfg.wireit_afs.tag_object_of(('RunChain', 'wiring', 'Wiring'), 'main', 'hidden') |
|
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 class ForumThreadPrimaryView(primary.PrimaryView): |
|
63 __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread') |