-
Notifications
You must be signed in to change notification settings - Fork 1
/
buttons.py
136 lines (89 loc) · 3.05 KB
/
buttons.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# -*- coding: UTF-8 -*-
# Copyright (C) 2010 Hervé Cauwelier <[email protected]>
# Copyright (C) 2018 Nicolas Deram <[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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Import from the Standard Library
# Import from itools
from itools.core import proto_property
from itools.gettext import MSG
# Import from ikaaro
from ikaaro.buttons import BrowseButton, Button
from ikaaro.utils import make_stl_template
class CreateButton(Button):
access = True
title = None
css = 'button-create'
class ExportODSButton(BrowseButton):
access = 'is_allowed_to_edit'
name = 'export'
title = MSG(u"Export this list in OpenDocument Format (ODS)")
class ExportXLSButton(ExportODSButton):
name = 'export_xls'
title = MSG(u"Export this list in XLS Format")
class AddUsersButton(Button):
access = 'is_allowed_to_edit'
name = "add_users"
title = MSG(u"Add Users")
class SaveButton(Button):
access = 'is_allowed_to_edit'
title = MSG(u"Save")
id = "form-submit"
@proto_property
def show(cls):
if cls.readonly:
return False
return super(SaveButton, cls).show
class Link(Button):
id = None
href = None
onclick = None
class InputControlLink(Link):
access = 'is_allowed_to_view'
id = "button-control"
class_icon_css = 'fa-cog'
href = ";send"
content = MSG(u"Input Control")
class PagePrintLink(Link):
access = 'is_allowed_to_view'
id = "button-page-print"
class_icon_css = 'fa-print'
href = "?view=print"
title = MSG(u"Print (in a new window)")
onclick = "return popup(this.href, 800, 600)"
content = MSG(u"Print this page")
class FormPrintLink(PagePrintLink):
id = "button-form-print"
href = ";print?view=print"
content = MSG(u"Print Form")
class Remove_BrowseButton(Button):
access = 'is_allowed_to_remove'
confirm = MSG(u'Are you sure?')
css = 'btn btn-danger'
icon_class = 'fa-trash-alt fa-white'
name = 'remove'
title = MSG(u'Delete')
template = make_stl_template("""
<button name="${action}" class="${css}" value="${name}"
onclick="${onclick}">
<i class="fa ${icon_class}"/> ${title}
</button>""")
@proto_property
def show(self):
context = self.context
for item in self.items:
if context.is_access_allowed(item, self):
return True
return False