forked from senaite/senaite.core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysisrequest_catalog.py
140 lines (131 loc) · 4.17 KB
/
analysisrequest_catalog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# -*- coding: utf-8 -*-
#
# This file is part of SENAITE.CORE
#
# Copyright 2018 by it's authors.
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
from zope.interface import implements
from App.class_init import InitializeClass
from bika.lims.catalog.bika_catalog_tool import BikaCatalogTool
from bika.lims.interfaces import IBikaCatalogAnalysisRequestListing
from bika.lims.catalog.catalog_basic_template import BASE_CATALOG_INDEXES
from bika.lims.catalog.catalog_basic_template import BASE_CATALOG_COLUMNS
# Using a variable to avoid plain strings in code
CATALOG_ANALYSIS_REQUEST_LISTING = 'bika_catalog_analysisrequest_listing'
# Defining the indexes for this catalog
_indexes_dict = {
# TODO: Can be removed? Same as id
'sortable_title': 'FieldIndex',
'getClientUID': 'FieldIndex',
'getSampleUID': 'FieldIndex',
'cancellation_state': 'FieldIndex',
'getBatchUID': 'FieldIndex',
'getDateSampled': 'DateIndex',
'getSamplingDate': 'DateIndex',
'getDateReceived': 'DateIndex',
'getDateVerified': 'DateIndex',
'getDatePublished': 'DateIndex',
'getSampler': 'FieldIndex',
'getReceivedBy': 'FieldIndex',
'getDepartmentUIDs': 'KeywordIndex',
'getPrinted': 'FieldIndex',
'getProvince': 'FieldIndex',
'getDistrict': 'FieldIndex',
'getClientSampleID': 'FieldIndex',
'getSampleID': 'FieldIndex',
# To sort in lists
'getClientTitle': 'FieldIndex',
'getPrioritySortkey': 'FieldIndex',
'assigned_state': 'FieldIndex',
# Searchable Text Index by wildcards
# http://zope.readthedocs.io/en/latest/zope2book/SearchingZCatalog.html#textindexng
'listing_searchable_text': 'TextIndexNG3',
}
# Defining the columns for this catalog
_columns_list = [
'getCreatorFullName',
'getCreatorEmail',
'getPhysicalPath',
'getSampleUID',
# Used to print the ID of the Sample in lists
'getSampleID',
# Used to create add an anchor to Sample ID that redirects to
# the Sample view.
'getSampleURL',
'getClientOrderNumber',
'getClientReference',
'getClientSampleID',
'getSampler',
'getSamplerFullName',
'getSamplerEmail',
'getBatchUID',
# Used to print the ID of the Batch in lists
'getBatchID',
'getBatchURL',
'getClientUID',
'getClientTitle',
'getClientURL',
'getContactUID',
'getContactUsername',
'getContactEmail',
'getContactURL',
'getContactFullName',
'getSampleTypeUID',
'getSampleTypeTitle',
'getSamplePointUID',
'getSamplePointTitle',
'getStorageLocationUID',
'getStorageLocationTitle',
'getSamplingDate',
'getDateSampled',
'getDateReceived',
'getDateVerified',
'getDatePublished',
'getDistrict',
'getProfilesUID',
'getProfilesURL',
'getProfilesTitle',
'getProfilesTitleStr',
'getProvince',
'getTemplateUID',
'getTemplateURL',
'getTemplateTitle',
'getAnalysesNum',
'getPrinted',
'getSamplingDeviationTitle',
'getPrioritySortkey',
# TODO: This should be updated through a clock
'getLate',
'getInvoiceExclude',
'getHazardous',
'getSamplingWorkflowEnabled',
'getDepartmentUIDs',
'assigned_state',
]
# Adding basic indexes
_base_indexes_copy = BASE_CATALOG_INDEXES.copy()
_indexes_dict.update(_base_indexes_copy)
# Adding basic columns
_base_columns_copy = BASE_CATALOG_COLUMNS[:]
_columns_list += _base_columns_copy
# Defining the types for this catalog
_types_list = ['AnalysisRequest', ]
bika_catalog_analysisrequest_listing_definition = {
# This catalog contains the metacolumns to list
# analysisrequests in bikalisting
CATALOG_ANALYSIS_REQUEST_LISTING: {
'types': _types_list,
'indexes': _indexes_dict,
'columns': _columns_list,
}
}
class BikaCatalogAnalysisRequestListing(BikaCatalogTool):
"""
Catalog to list analysis requests in BikaListing
"""
implements(IBikaCatalogAnalysisRequestListing)
def __init__(self):
BikaCatalogTool.__init__(self, CATALOG_ANALYSIS_REQUEST_LISTING,
'Bika Catalog Analysis Request Listing',
'BikaCatalogAnalysisRequestListing')
InitializeClass(BikaCatalogAnalysisRequestListing)