|
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
|
|
|
from AccessControl import ClassSecurityInfo |
|
22
|
|
|
from bika.lims import senaiteMessageFactory as _ |
|
23
|
|
|
from bika.lims.interfaces import IDeactivable |
|
24
|
|
|
from senaite.core.catalog import SETUP_CATALOG |
|
25
|
|
|
from senaite.core.content.base import Container |
|
26
|
|
|
from senaite.core.interfaces import IStorageLocation |
|
27
|
|
|
from zope import schema |
|
28
|
|
|
from zope.interface import implementer |
|
29
|
|
|
from plone.supermodel import model |
|
30
|
|
|
from Products.CMFCore import permissions |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
class IStorageLocationSchema(model.Schema): |
|
34
|
|
|
"""Schema interface |
|
35
|
|
|
""" |
|
36
|
|
|
|
|
37
|
|
|
title = schema.TextLine( |
|
38
|
|
|
title=_( |
|
39
|
|
|
"title_storagelocation_title", |
|
40
|
|
|
default="Address", |
|
41
|
|
|
), |
|
42
|
|
|
required=True, |
|
43
|
|
|
) |
|
44
|
|
|
|
|
45
|
|
|
description = schema.Text( |
|
46
|
|
|
title=_( |
|
47
|
|
|
"title_storagelocation_description", |
|
48
|
|
|
default="Description", |
|
49
|
|
|
), |
|
50
|
|
|
required=False, |
|
51
|
|
|
) |
|
52
|
|
|
|
|
53
|
|
|
site_title = schema.TextLine( |
|
54
|
|
|
title=_( |
|
55
|
|
|
"title_storagelocation_site_title", |
|
56
|
|
|
default="Site Title" |
|
57
|
|
|
), |
|
58
|
|
|
description=_( |
|
59
|
|
|
"description_storagelocation_site_title", |
|
60
|
|
|
default="Title of the site", |
|
61
|
|
|
), |
|
62
|
|
|
required=False, |
|
63
|
|
|
) |
|
64
|
|
|
|
|
65
|
|
|
site_code = schema.TextLine( |
|
66
|
|
|
title=_( |
|
67
|
|
|
"title_storagelocation_site_code", |
|
68
|
|
|
default="Site Code", |
|
69
|
|
|
), |
|
70
|
|
|
description=_( |
|
71
|
|
|
"description_storagelocation_site_code", |
|
72
|
|
|
default="Code for the site", |
|
73
|
|
|
), |
|
74
|
|
|
required=False, |
|
75
|
|
|
) |
|
76
|
|
|
|
|
77
|
|
|
site_description = schema.TextLine( |
|
78
|
|
|
title=_( |
|
79
|
|
|
"title_storagelocation_site_description", |
|
80
|
|
|
default="Site Description", |
|
81
|
|
|
), |
|
82
|
|
|
description=_( |
|
83
|
|
|
"description_storagelocation_site_description", |
|
84
|
|
|
default="Description of the site", |
|
85
|
|
|
), |
|
86
|
|
|
required=False, |
|
87
|
|
|
) |
|
88
|
|
|
|
|
89
|
|
|
location_title = schema.TextLine( |
|
90
|
|
|
title=_( |
|
91
|
|
|
"title_storagelocation_location_title", |
|
92
|
|
|
default="Location Title", |
|
93
|
|
|
), |
|
94
|
|
|
description=_( |
|
95
|
|
|
"description_storagelocation_location_title", |
|
96
|
|
|
default="Title of location", |
|
97
|
|
|
), |
|
98
|
|
|
required=False, |
|
99
|
|
|
) |
|
100
|
|
|
|
|
101
|
|
|
location_code = schema.TextLine( |
|
102
|
|
|
title=_( |
|
103
|
|
|
"title_storagelocation_location_code", |
|
104
|
|
|
default="Location Code", |
|
105
|
|
|
), |
|
106
|
|
|
description=_( |
|
107
|
|
|
"description_storagelocation_location_code", |
|
108
|
|
|
default="Code for the location", |
|
109
|
|
|
), |
|
110
|
|
|
required=False, |
|
111
|
|
|
) |
|
112
|
|
|
|
|
113
|
|
|
location_description = schema.TextLine( |
|
114
|
|
|
title=_( |
|
115
|
|
|
"title_storagelocation_location_description", |
|
116
|
|
|
default="Location Description", |
|
117
|
|
|
), |
|
118
|
|
|
description=_( |
|
119
|
|
|
"description_storagelocation_location_description", |
|
120
|
|
|
default="Description of the location", |
|
121
|
|
|
), |
|
122
|
|
|
required=False, |
|
123
|
|
|
) |
|
124
|
|
|
|
|
125
|
|
|
location_type = schema.TextLine( |
|
126
|
|
|
title=_( |
|
127
|
|
|
"title_storagelocation_location_type", |
|
128
|
|
|
default="Location Type", |
|
129
|
|
|
), |
|
130
|
|
|
description=_( |
|
131
|
|
|
"description_storagelocation_location_type", |
|
132
|
|
|
default="Type of location", |
|
133
|
|
|
), |
|
134
|
|
|
required=False, |
|
135
|
|
|
) |
|
136
|
|
|
|
|
137
|
|
|
shelf_title = schema.TextLine( |
|
138
|
|
|
title=_( |
|
139
|
|
|
"title_storagelocation_shelf_title", |
|
140
|
|
|
default="Shelf Title", |
|
141
|
|
|
), |
|
142
|
|
|
description=_( |
|
143
|
|
|
"description_storagelocation_shelf_title", |
|
144
|
|
|
default="Title of the shelf", |
|
145
|
|
|
), |
|
146
|
|
|
required=False, |
|
147
|
|
|
) |
|
148
|
|
|
|
|
149
|
|
|
shelf_code = schema.TextLine( |
|
150
|
|
|
title=_( |
|
151
|
|
|
"title_storagelocation_shelf_code", |
|
152
|
|
|
default="Shelf Code", |
|
153
|
|
|
), |
|
154
|
|
|
description=_( |
|
155
|
|
|
"description_storagelocation_shelf_code", |
|
156
|
|
|
default="Code the the shelf", |
|
157
|
|
|
), |
|
158
|
|
|
required=False, |
|
159
|
|
|
) |
|
160
|
|
|
|
|
161
|
|
|
shelf_description = schema.TextLine( |
|
162
|
|
|
title=_( |
|
163
|
|
|
"title_storagelocation_shelf_description", |
|
164
|
|
|
default="Shelf Description", |
|
165
|
|
|
), |
|
166
|
|
|
description=_( |
|
167
|
|
|
"description_storagelocation_shelf_description", |
|
168
|
|
|
default="Description of the shelf", |
|
169
|
|
|
), |
|
170
|
|
|
required=False, |
|
171
|
|
|
) |
|
172
|
|
|
|
|
173
|
|
|
|
|
174
|
|
|
@implementer(IStorageLocation, IStorageLocationSchema, IDeactivable) |
|
175
|
|
|
class StorageLocation(Container): |
|
176
|
|
|
"""Storage Location |
|
177
|
|
|
""" |
|
178
|
|
|
# Catalogs where this type will be catalogued |
|
179
|
|
|
_catalogs = [SETUP_CATALOG] |
|
180
|
|
|
|
|
181
|
|
|
security = ClassSecurityInfo() |
|
182
|
|
|
|
|
183
|
|
|
@security.protected(permissions.View) |
|
184
|
|
|
def getSiteTitle(self): |
|
185
|
|
|
accessor = self.accessor("site_title") |
|
186
|
|
|
return accessor(self) |
|
187
|
|
|
|
|
188
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
189
|
|
|
def setSiteTitle(self, value): |
|
190
|
|
|
mutator = self.mutator("site_title") |
|
191
|
|
|
mutator(self, value) |
|
192
|
|
|
|
|
193
|
|
|
# BBB: AT schema field property |
|
194
|
|
|
SiteTitle = property(getSiteTitle, setSiteTitle) |
|
195
|
|
|
|
|
196
|
|
|
@security.protected(permissions.View) |
|
197
|
|
|
def getSiteCode(self): |
|
198
|
|
|
accessor = self.accessor("site_code") |
|
199
|
|
|
return accessor(self) |
|
200
|
|
|
|
|
201
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
202
|
|
|
def setSiteCode(self, value): |
|
203
|
|
|
mutator = self.mutator("site_code") |
|
204
|
|
|
mutator(self, value) |
|
205
|
|
|
|
|
206
|
|
|
# BBB: AT schema field property |
|
207
|
|
|
SiteCode = property(getSiteCode, setSiteCode) |
|
208
|
|
|
|
|
209
|
|
|
@security.protected(permissions.View) |
|
210
|
|
|
def getSiteDescription(self): |
|
211
|
|
|
accessor = self.accessor("site_description") |
|
212
|
|
|
return accessor(self) |
|
213
|
|
|
|
|
214
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
215
|
|
|
def setSiteDescription(self, value): |
|
216
|
|
|
mutator = self.mutator("site_description") |
|
217
|
|
|
mutator(self, value) |
|
218
|
|
|
|
|
219
|
|
|
# BBB: AT schema field property |
|
220
|
|
|
SiteDescription = property(getSiteDescription, setSiteDescription) |
|
221
|
|
|
|
|
222
|
|
|
@security.protected(permissions.View) |
|
223
|
|
|
def getLocationTitle(self): |
|
224
|
|
|
accessor = self.accessor("location_title") |
|
225
|
|
|
return accessor(self) |
|
226
|
|
|
|
|
227
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
228
|
|
|
def setLocationTitle(self, value): |
|
229
|
|
|
mutator = self.mutator("location_title") |
|
230
|
|
|
mutator(self, value) |
|
231
|
|
|
|
|
232
|
|
|
# BBB: AT schema field property |
|
233
|
|
|
LocationTitle = property(getLocationTitle, setLocationTitle) |
|
234
|
|
|
|
|
235
|
|
|
@security.protected(permissions.View) |
|
236
|
|
|
def getLocationCode(self): |
|
237
|
|
|
accessor = self.accessor("location_code") |
|
238
|
|
|
return accessor(self) |
|
239
|
|
|
|
|
240
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
241
|
|
|
def setLocationCode(self, value): |
|
242
|
|
|
mutator = self.mutator("location_code") |
|
243
|
|
|
mutator(self, value) |
|
244
|
|
|
|
|
245
|
|
|
# BBB: AT schema field property |
|
246
|
|
|
LocationCode = property(getLocationCode, setLocationCode) |
|
247
|
|
|
|
|
248
|
|
|
@security.protected(permissions.View) |
|
249
|
|
|
def getLocationDescription(self): |
|
250
|
|
|
accessor = self.accessor("location_description") |
|
251
|
|
|
return accessor(self) |
|
252
|
|
|
|
|
253
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
254
|
|
|
def setLocationDescription(self, value): |
|
255
|
|
|
mutator = self.mutator("location_description") |
|
256
|
|
|
mutator(self, value) |
|
257
|
|
|
|
|
258
|
|
|
# BBB: AT schema field property |
|
259
|
|
|
LocationDescription = property(getLocationDescription, |
|
260
|
|
|
setLocationDescription) |
|
261
|
|
|
|
|
262
|
|
|
@security.protected(permissions.View) |
|
263
|
|
|
def getLocationType(self): |
|
264
|
|
|
accessor = self.accessor("location_type") |
|
265
|
|
|
return accessor(self) |
|
266
|
|
|
|
|
267
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
268
|
|
|
def setLocationType(self, value): |
|
269
|
|
|
mutator = self.mutator("location_type") |
|
270
|
|
|
mutator(self, value) |
|
271
|
|
|
|
|
272
|
|
|
# BBB: AT schema field property |
|
273
|
|
|
LocationType = property(getLocationType, setLocationType) |
|
274
|
|
|
|
|
275
|
|
|
@security.protected(permissions.View) |
|
276
|
|
|
def getShelfTitle(self): |
|
277
|
|
|
accessor = self.accessor("shelf_title") |
|
278
|
|
|
return accessor(self) |
|
279
|
|
|
|
|
280
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
281
|
|
|
def setShelfTitle(self, value): |
|
282
|
|
|
mutator = self.mutator("shelf_title") |
|
283
|
|
|
mutator(self, value) |
|
284
|
|
|
|
|
285
|
|
|
# BBB: AT schema field property |
|
286
|
|
|
ShelfTitle = property(getShelfTitle, setShelfTitle) |
|
287
|
|
|
|
|
288
|
|
|
@security.protected(permissions.View) |
|
289
|
|
|
def getShelfCode(self): |
|
290
|
|
|
accessor = self.accessor("shelf_code") |
|
291
|
|
|
return accessor(self) |
|
292
|
|
|
|
|
293
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
294
|
|
|
def setShelfCode(self, value): |
|
295
|
|
|
mutator = self.mutator("shelf_code") |
|
296
|
|
|
mutator(self, value) |
|
297
|
|
|
|
|
298
|
|
|
# BBB: AT schema field property |
|
299
|
|
|
ShelfCode = property(getShelfCode, setShelfCode) |
|
300
|
|
|
|
|
301
|
|
|
@security.protected(permissions.View) |
|
302
|
|
|
def getShelfDescription(self): |
|
303
|
|
|
accessor = self.accessor("shelf_description") |
|
304
|
|
|
return accessor(self) |
|
305
|
|
|
|
|
306
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
307
|
|
|
def setShelfDescription(self, value): |
|
308
|
|
|
mutator = self.mutator("shelf_description") |
|
309
|
|
|
mutator(self, value) |
|
310
|
|
|
|
|
311
|
|
|
# BBB: AT schema field property |
|
312
|
|
|
ShelfDescription = property(getShelfDescription, setShelfDescription) |
|
313
|
|
|
|