1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# |
3
|
|
|
# This file is part of SENAITE.CORE. |
4
|
|
|
# |
5
|
|
|
# SENAITE.CORE is free software: you can redistribute it and/or modify it under |
6
|
|
|
# the terms of the GNU General Public License as published by the Free Software |
7
|
|
|
# Foundation, version 2. |
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 General Public License for more |
12
|
|
|
# details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License along with |
15
|
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 |
16
|
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17
|
|
|
# |
18
|
|
|
# Copyright 2018-2024 by it's authors. |
19
|
|
|
# Some rights reserved, see README and LICENSE. |
20
|
|
|
|
21
|
|
|
import collections |
22
|
|
|
|
23
|
|
|
from bika.lims import api |
24
|
|
|
from bika.lims import bikaMessageFactory as _ |
25
|
|
|
from bika.lims.utils import get_link_for |
26
|
|
|
from senaite.app.listing import ListingView |
27
|
|
|
from senaite.core.catalog import SETUP_CATALOG |
28
|
|
|
from senaite.core.i18n import translate |
29
|
|
|
from senaite.core.permissions import AddSampleTemplate |
30
|
|
|
|
31
|
|
|
|
32
|
|
View Code Duplication |
class SampleTemplatesView(ListingView): |
|
|
|
|
33
|
|
|
|
34
|
|
|
def __init__(self, context, request): |
35
|
|
|
super(SampleTemplatesView, self).__init__(context, request) |
36
|
|
|
|
37
|
|
|
self.catalog = SETUP_CATALOG |
38
|
|
|
self.show_select_column = True |
39
|
|
|
|
40
|
|
|
self.contentFilter = { |
41
|
|
|
"portal_type": "SampleTemplate", |
42
|
|
|
"sort_on": "sortable_title", |
43
|
|
|
"sort_order": "ascending", |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
self.context_actions = { |
47
|
|
|
_(u"listing_sampletemplates_action_add", default=u"Add"): { |
48
|
|
|
"url": "++add++SampleTemplate", |
49
|
|
|
"permission": AddSampleTemplate, |
50
|
|
|
"icon": "senaite_theme/icon/plus" |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
self.title = translate(_( |
55
|
|
|
u"listing_sampletemplates_title", |
56
|
|
|
default=u"Sample Templates") |
57
|
|
|
) |
58
|
|
|
self.icon = api.get_icon("SampleTemplates", html_tag=False) |
59
|
|
|
|
60
|
|
|
self.columns = collections.OrderedDict(( |
61
|
|
|
("Title", { |
62
|
|
|
"title": _( |
63
|
|
|
u"listing_sampletemplates_column_title", |
64
|
|
|
default=u"Sample Template" |
65
|
|
|
), |
66
|
|
|
"index": "sortable_title"}), |
67
|
|
|
("Description", { |
68
|
|
|
"title": _( |
69
|
|
|
u"listing_sampletemplates_column_description", |
70
|
|
|
default=u"Description" |
71
|
|
|
), |
72
|
|
|
"toggle": True}), |
73
|
|
|
)) |
74
|
|
|
|
75
|
|
|
self.review_states = [ |
76
|
|
|
{ |
77
|
|
|
"id": "default", |
78
|
|
|
"title": _( |
79
|
|
|
u"listing_sampletemplates_state_active", |
80
|
|
|
default=u"Active" |
81
|
|
|
), |
82
|
|
|
"contentFilter": {"is_active": True}, |
83
|
|
|
"columns": self.columns.keys(), |
84
|
|
|
}, { |
85
|
|
|
"id": "inactive", |
86
|
|
|
"title": _( |
87
|
|
|
u"listing_sampletemplates_state_inactive", |
88
|
|
|
default=u"Inactive" |
89
|
|
|
), |
90
|
|
|
"contentFilter": {"is_active": False}, |
91
|
|
|
"columns": self.columns.keys(), |
92
|
|
|
}, { |
93
|
|
|
"id": "all", |
94
|
|
|
"title": _( |
95
|
|
|
u"listing_sampletemplates_state_all", |
96
|
|
|
default=u"All" |
97
|
|
|
), |
98
|
|
|
"contentFilter": {}, |
99
|
|
|
"columns": self.columns.keys(), |
100
|
|
|
}, |
101
|
|
|
] |
102
|
|
|
|
103
|
|
|
def folderitem(self, obj, item, index): |
104
|
|
|
item["replace"]["Title"] = get_link_for(obj) |
105
|
|
|
return item |
106
|
|
|
|