|
1 # -*- coding: utf-8 -*- |
|
2 # copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
3 # contact http://www.logilab.fr -- mailto:contact@logilab.fr |
|
4 # |
|
5 # This program is free software: you can redistribute it and/or modify it under |
|
6 # the terms of the GNU Lesser General Public License as published by the Free |
|
7 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
8 # any later version. |
|
9 # |
|
10 # This program is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
13 # details. |
|
14 # |
|
15 # You should have received a copy of the GNU Lesser General Public License along |
|
16 # with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
|
18 """cubicweb-forum schema""" |
|
19 |
|
20 from yams.buildobjs import (String, RichString, EntityType, |
|
21 RelationDefinition, SubjectRelation) |
|
22 from yams.reader import context |
|
23 |
|
24 class Forum(EntityType): |
|
25 topic = String(maxsize=50, required=True, unique=True) |
|
26 description = RichString() |
|
27 |
|
28 class ForumThread(EntityType): |
|
29 __permissions__ = { |
|
30 'read': ('managers', 'users'), |
|
31 'add': ('managers', 'users'), |
|
32 'update': ('managers', 'owners'), |
|
33 'delete': ('managers', 'owners') |
|
34 } |
|
35 title = String(required=True, fulltextindexed=True, maxsize=256) |
|
36 content = RichString(required=True, fulltextindexed=True) |
|
37 in_forum = SubjectRelation('Forum', cardinality='1*', inlined=True, |
|
38 composite='object') |
|
39 class interested_in(RelationDefinition): |
|
40 subject = 'CWUser' |
|
41 object = ('ForumThread', 'Forum') |
|
42 |
|
43 class nosy_list(RelationDefinition): |
|
44 subject = ('Forum', 'ForumThread') |
|
45 object = 'CWUser' |