1
|
|
|
# -*- coding: utf-8 -*-
|
2
|
|
|
#
|
3
|
|
|
# This file is part of SENAITE.CORE
|
4
|
|
|
#
|
5
|
|
|
# Copyright 2018 by it's authors.
|
6
|
|
|
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
|
7
|
|
|
|
8
|
|
|
from AccessControl import ClassSecurityInfo
|
9
|
|
|
from Products.ATContentTypes.lib.historyaware import HistoryAwareMixin
|
10
|
|
|
from Products.Archetypes.public import BaseContent
|
11
|
|
|
from Products.Archetypes.public import BooleanField
|
12
|
|
|
from Products.Archetypes.public import DateTimeField
|
13
|
|
|
from Products.Archetypes.public import ReferenceField
|
14
|
|
|
from Products.Archetypes.public import Schema
|
15
|
|
|
from Products.Archetypes.public import StringField
|
16
|
|
|
from Products.Archetypes.public import registerType
|
17
|
|
|
from Products.CMFPlone.utils import safe_unicode
|
18
|
|
|
from bika.lims.browser.fields import DurationField
|
19
|
|
|
from bika.lims.browser.fields import UIDReferenceField
|
20
|
|
|
from bika.lims.config import PROJECTNAME
|
21
|
|
|
from bika.lims.content.bikaschema import BikaSchema
|
22
|
|
|
from bika.lims.interfaces import ISamplePartition
|
23
|
|
|
from zope.interface import implements
|
24
|
|
|
|
25
|
|
|
schema = BikaSchema.copy() + Schema((
|
26
|
|
|
ReferenceField('Container',
|
27
|
|
|
allowed_types=('Container',),
|
28
|
|
|
relationship='SamplePartitionContainer',
|
29
|
|
|
required=1,
|
30
|
|
|
multiValued=0,
|
31
|
|
|
),
|
32
|
|
|
ReferenceField('Preservation',
|
33
|
|
|
allowed_types=('Preservation',),
|
34
|
|
|
relationship='SamplePartitionPreservation',
|
35
|
|
|
required=0,
|
36
|
|
|
multiValued=0,
|
37
|
|
|
),
|
38
|
|
|
BooleanField('Separate',
|
39
|
|
|
default=False
|
40
|
|
|
),
|
41
|
|
|
UIDReferenceField('Analyses',
|
42
|
|
|
allowed_types=('Analysis',),
|
43
|
|
|
required=0,
|
44
|
|
|
multiValued=1,
|
45
|
|
|
),
|
46
|
|
|
DateTimeField('DatePreserved',
|
47
|
|
|
),
|
48
|
|
|
StringField('Preserver',
|
49
|
|
|
searchable=True
|
50
|
|
|
),
|
51
|
|
|
DurationField('RetentionPeriod',
|
52
|
|
|
),
|
53
|
|
|
)
|
54
|
|
|
)
|
55
|
|
|
|
56
|
|
|
schema['title'].required = False
|
57
|
|
|
|
58
|
|
|
|
59
|
|
|
class SamplePartition(BaseContent, HistoryAwareMixin):
|
60
|
|
|
implements(ISamplePartition)
|
61
|
|
|
security = ClassSecurityInfo()
|
62
|
|
|
displayContentsTab = False
|
63
|
|
|
schema = schema
|
|
|
|
|
64
|
|
|
|
65
|
|
|
_at_rename_after_creation = True
|
66
|
|
|
|
67
|
|
|
def _renameAfterCreation(self, check_auto_id=False):
|
68
|
|
|
from bika.lims.idserver import renameAfterCreation
|
69
|
|
|
renameAfterCreation(self)
|
70
|
|
|
|
71
|
|
|
def Title(self):
|
72
|
|
|
""" Return the Sample ID as title """
|
73
|
|
|
return safe_unicode(self.getId()).encode('utf-8')
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
registerType(SamplePartition, PROJECTNAME)
|
77
|
|
|
|