Completed
Branch master (9edffc)
by Jordi
04:36
created

SamplePartition.Title()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 1
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
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable schema does not seem to be defined.
Loading history...
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