-
Notifications
You must be signed in to change notification settings - Fork 1
/
ws_neutral_views.py
70 lines (52 loc) · 2.36 KB
/
ws_neutral_views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: UTF-8 -*-
# Copyright (C) 2010 Hervé Cauwelier <[email protected]>
# Copyright (C) 2010 Taverne Sylvain <[email protected]>
# Copyright (C) 2010-2011 Henry Obein <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import from itools
from itools.core import freeze, merge_dicts
from itools.database import PhraseQuery
from itools.gettext import MSG
# Import from ikaaro
from ikaaro.autoform import SelectWidget, TextWidget
from ikaaro.datatypes import Multilingual
from ikaaro.resource_views import DBResource_Edit
# Import from itws
from rss import BaseRSS
from section_views import SectionViews_Enumerate
from views import EditView
class NeutralWS_RSS(BaseRSS):
excluded_formats = freeze(['rssfeeds'])
def get_base_query(self, resource, context):
query = BaseRSS.get_base_query(self, resource, context)
query.append(PhraseQuery('workflow_state', 'public'))
return query
class NeutralWS_Edit(EditView, DBResource_Edit):
def _get_widgets(self, resource, context):
return freeze(DBResource_Edit._get_widgets(self, resource, context)
+ [SelectWidget('view', title=MSG(u'View'),
has_empty_option=False),
TextWidget('breadcrumb_title', title=MSG(u'Breadcrumb title'))])
def _get_schema(self, resource, context):
return freeze(merge_dicts(
DBResource_Edit._get_schema(self, resource, context),
view=SectionViews_Enumerate,
breadcrumb_title=Multilingual))
def action(self, resource, context, form):
self.check_edit_conflict(resource, context, form)
if context.edit_conflict:
return
EditView.action(self, resource, context, form)
return DBResource_Edit.action(self, resource, context, form)