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.view import ListingView |
27
|
|
|
from senaite.core.catalog import SETUP_CATALOG |
28
|
|
|
from senaite.core.i18n import translate |
29
|
|
|
from senaite.core.permissions import AddAnalysisProfile |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
class AnalysisProfilesView(ListingView): |
33
|
|
|
"""Controlpanel Listing for Analysis Profiles |
34
|
|
|
""" |
35
|
|
|
|
36
|
|
|
def __init__(self, context, request): |
37
|
|
|
super(AnalysisProfilesView, self).__init__(context, request) |
38
|
|
|
|
39
|
|
|
self.catalog = SETUP_CATALOG |
40
|
|
|
self.show_select_column = True |
41
|
|
|
|
42
|
|
|
self.contentFilter = { |
43
|
|
|
"portal_type": "AnalysisProfile", |
44
|
|
|
"sort_on": "sortable_title", |
45
|
|
|
"sort_order": "ascending", |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
self.context_actions = { |
49
|
|
|
_(u"listing_analysisprofiles_action_add", default=u"Add"): { |
50
|
|
|
"url": "++add++AnalysisProfile", |
51
|
|
|
"permission": AddAnalysisProfile, |
52
|
|
|
"icon": "senaite_theme/icon/plus" |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
self.title = translate(_( |
57
|
|
|
u"listing_analysisprofiles_title", |
58
|
|
|
default=u"Analysis Profiles") |
59
|
|
|
) |
60
|
|
|
self.icon = api.get_icon("AnalysisProfiles", html_tag=False) |
61
|
|
|
|
62
|
|
|
self.columns = collections.OrderedDict(( |
63
|
|
|
("Title", { |
64
|
|
|
"title": _( |
65
|
|
|
u"listing_analysisprofiles_column_title", |
66
|
|
|
default=u"Profile" |
67
|
|
|
), |
68
|
|
|
"index": "sortable_title", |
69
|
|
|
}), |
70
|
|
|
("Description", { |
71
|
|
|
"title": _( |
72
|
|
|
u"listing_analysisprofiles_column_description", |
73
|
|
|
default=u"Description" |
74
|
|
|
), |
75
|
|
|
"index": "Description", |
76
|
|
|
"toggle": True, |
77
|
|
|
}), |
78
|
|
|
("ProfileKey", { |
79
|
|
|
"title": _( |
80
|
|
|
u"listing_analysisprofiles_column_profilekey", |
81
|
|
|
default=u"Profile Key" |
82
|
|
|
), |
83
|
|
|
"sortable": False, |
84
|
|
|
"toggle": True, |
85
|
|
|
}), |
86
|
|
|
)) |
87
|
|
|
|
88
|
|
|
self.review_states = [ |
89
|
|
|
{ |
90
|
|
|
"id": "default", |
91
|
|
|
"title": _( |
92
|
|
|
u"listing_analysisprofiles_state_active", |
93
|
|
|
default=u"Active" |
94
|
|
|
), |
95
|
|
|
"contentFilter": {"is_active": True}, |
96
|
|
|
"columns": self.columns.keys(), |
97
|
|
|
}, { |
98
|
|
|
"id": "inactive", |
99
|
|
|
"title": _( |
100
|
|
|
u"listing_analysisprofiles_state_inactive", |
101
|
|
|
default=u"Inactive" |
102
|
|
|
), |
103
|
|
|
"contentFilter": {'is_active': False}, |
104
|
|
|
"columns": self.columns.keys(), |
105
|
|
|
}, { |
106
|
|
|
"id": "all", |
107
|
|
|
"title": _( |
108
|
|
|
u"listing_analysisprofiles_state_all", |
109
|
|
|
default=u"All" |
110
|
|
|
), |
111
|
|
|
"contentFilter": {}, |
112
|
|
|
"columns": self.columns.keys(), |
113
|
|
|
}, |
114
|
|
|
] |
115
|
|
|
|
116
|
|
|
def folderitem(self, obj, item, index): |
117
|
|
|
obj = api.get_object(obj) |
118
|
|
|
item["replace"]["Title"] = get_link_for(obj) |
119
|
|
|
item["ProfileKey"] = obj.getProfileKey() |
120
|
|
|
return item |
121
|
|
|
|