-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheditorial.py
75 lines (62 loc) · 2.62 KB
/
editorial.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
71
72
73
74
# -*- coding: UTF-8 -*-
# Copyright (C) 2010 Sylvain Taverne <[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 merge_dicts
from itools.datatypes import String
from itools.gettext import MSG
from itools.xapian import AndQuery, OrQuery, NotQuery, PhraseQuery
from itools.xml import XMLParser
# Import from ikaaro
from ikaaro.buttons import RemoveButton, RenameButton
from ikaaro.folder_views import Folder_BrowseContent
class Shop_EditorialView(Folder_BrowseContent):
"""
To delete on 0.62
"""
access = 'is_allowed_to_edit'
title = MSG(u'View')
search_template = '/ui/backoffice/editorial_view.xml'
table_actions = [RemoveButton, RenameButton]
table_columns = [
('checkbox', None),
('icon', None),
('name', MSG(u'Name')),
('title', MSG(u'Title')),
('format', MSG(u'Format')),
('workflow_state', MSG(u'State')),
]
def get_query_schema(self):
return merge_dicts(Folder_BrowseContent.get_query_schema(self),
sort_by=String(default='format'))
def get_items(self, resource, context, *args):
path = str(resource.parent.get_canonical_path())
query = [
PhraseQuery('parent_path', path),
NotQuery(PhraseQuery('name', '404')),
OrQuery(PhraseQuery('format', 'shop-section'),
PhraseQuery('format', 'products-feed'),
PhraseQuery('format', 'webpage'),
PhraseQuery('format', 'news-folder'))]
return context.root.search(AndQuery(*query))
def get_item_value(self, resource, context, item, column):
brain, item_resource = item
if column == 'name':
link = '%s/%s' % (resource.get_property('shop_uri'),
brain.name)
return XMLParser(
"<a href='%s' target='_blank'>%s</a>" % (link, brain.name))
return Folder_BrowseContent.get_item_value(self, resource,
context, item, column)