|
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 Products.CMFCore import permissions |
|
23
|
|
|
from bika.lims import senaiteMessageFactory as _ |
|
24
|
|
|
from bika.lims.interfaces import IDeactivable |
|
25
|
|
|
from plone.supermodel import model |
|
26
|
|
|
from senaite.core.catalog import SETUP_CATALOG |
|
27
|
|
|
from senaite.core.content.base import Container |
|
28
|
|
|
from senaite.core.interfaces import ISubGroup |
|
29
|
|
|
from zope import schema |
|
30
|
|
|
from zope.interface import implementer |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
class ISubGroupSchema(model.Schema): |
|
34
|
|
|
"""Schema interface |
|
35
|
|
|
""" |
|
36
|
|
|
|
|
37
|
|
|
title = schema.TextLine( |
|
38
|
|
|
title=_( |
|
39
|
|
|
"title_subgroup_title", |
|
40
|
|
|
default="Name" |
|
41
|
|
|
), |
|
42
|
|
|
required=True, |
|
43
|
|
|
) |
|
44
|
|
|
|
|
45
|
|
|
description = schema.Text( |
|
46
|
|
|
title=_( |
|
47
|
|
|
"title_subgroup_description", |
|
48
|
|
|
default="Description" |
|
49
|
|
|
), |
|
50
|
|
|
required=False, |
|
51
|
|
|
) |
|
52
|
|
|
|
|
53
|
|
|
sort_key = schema.TextLine( |
|
54
|
|
|
title=_( |
|
55
|
|
|
"title_subgroup_sortkey", |
|
56
|
|
|
default="Sort Key" |
|
57
|
|
|
), |
|
58
|
|
|
required=False, |
|
59
|
|
|
) |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
@implementer(ISubGroup, ISubGroupSchema, IDeactivable) |
|
63
|
|
|
class SubGroup(Container): |
|
64
|
|
|
"""Sub Group type |
|
65
|
|
|
""" |
|
66
|
|
|
# Catalogs where this type will be catalogued |
|
67
|
|
|
_catalogs = [SETUP_CATALOG] |
|
68
|
|
|
|
|
69
|
|
|
security = ClassSecurityInfo() |
|
70
|
|
|
|
|
71
|
|
|
@security.protected(permissions.View) |
|
72
|
|
|
def getSortKey(self): |
|
73
|
|
|
accessor = self.accessor("sort_key") |
|
74
|
|
|
return accessor(self) |
|
75
|
|
|
|
|
76
|
|
|
@security.protected(permissions.ModifyPortalContent) |
|
77
|
|
|
def setSortKey(self, value): |
|
78
|
|
|
mutator = self.mutator("sort_key") |
|
79
|
|
|
mutator(self, value) |
|
80
|
|
|
|
|
81
|
|
|
# BBB: AT schema field property |
|
82
|
|
|
SortKey = property(getSortKey, setSortKey) |
|
83
|
|
|
|