Passed
Push — master ( f42093...226b52 )
by Ramon
04:24
created

bika.lims.interfaces.IClientAwareMixin.getClient()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
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
# 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-2019 by it's authors.
19
# Some rights reserved, see README and LICENSE.
20
21
from zope.interface import Interface
22
23
24
class ISenaiteSiteRoot(Interface):
25
    """Marker interface for the Senaite Site Root
26
    """
27
28
29
class IBikaLIMS(Interface):
30
    """Marker interface that defines a Zope 3 browser layer.
31
32
    N.B. Please use ISenaiteSite interface
33
    """
34
35
36
class ISenaiteSite(IBikaLIMS):
37
    """Marker interface for Zope 3 browser layers.
38
    """
39
40
41
class IAutoGenerateID(Interface):
42
    """Auto-generate ID with ID server
43
    """
44
45
46
class IActionHandlerPool(Interface):
47
    """Marker interface for the ActionHandlerPool utility
48
    """
49
50
51
class IAuditLog(Interface):
52
    """Marker interface for Audit Log
53
    """
54
55
56
class IAuditable(Interface):
57
    """Marker inteface for auditable contents
58
    """
59
60
61
class IDoNotSupportSnapshots(Interface):
62
    """Marker inteface for non-auditable contents
63
    """
64
65
66
class IAuditLogCatalog(Interface):
67
    """Audit Log Catalog
68
    """
69
70
71
class IGenerateID(Interface):
72
    """Marker Interface to generate an ID
73
    """
74
75
76
class IHaveNoBreadCrumbs(Interface):
77
    """Items which do not display breadcrumbs
78
    """
79
80
81
class IClientFolder(Interface):
82
    """Client folder
83
    """
84
85
86
class IClient(Interface):
87
    """Client
88
    """
89
90
91
class IBatchFolder(Interface):
92
    """Batch folder
93
    """
94
95
96
class IBatch(Interface):
97
    """Batch
98
    """
99
100
101
class IBatchLabels(Interface):
102
    """Batch label
103
    """
104
105
106
class IAnalysisRequest(Interface):
107
    """Analysis Request
108
    """
109
110
111
class IAnalysisRequestPartition(Interface):
112
    """Marker interface for Analysis Requests that are also Partitions
113
    """
114
115
116
class IAnalysisRequestRetest(Interface):
117
    """Marker interface for Analysis Requests that are Retests
118
    """
119
120
121
class IAnalysisRequestSecondary(Interface):
122
    """Marker interface for Secondary Analysis Requests
123
    """
124
125
126
class IAnalysisRequestAddView(Interface):
127
    """AR Add view
128
    """
129
130
131
class IAnalysisRequestsFolder(Interface):
132
    """AnalysisRequests Folder
133
    """
134
135
136
class IInvoiceView(Interface):
137
    """Invoice View
138
    """
139
140
141
class IAnalysis(Interface):
142
    """Analysis
143
    """
144
145
146
class IRoutineAnalysis(Interface):
147
    """This adapter distinguishes normal analyses from Duplicates, References,
148
    Rejections, etc.
149
    """
150
151
152
class IAnalysisSpec(Interface):
153
    """Analysis Specs
154
    """
155
156
157
class IDuplicateAnalysis(Interface):
158
    """DuplicateAnalysis
159
    """
160
161
162
class IReferenceAnalysis(Interface):
163
    """Reference Analyses
164
    """
165
166
167
class IRejectAnalysis(Interface):
168
    """This adapter distinguishes normal analyses from Duplicates, References,
169
    Rejections, etc.
170
    """
171
172
173
class IReportFolder(Interface):
174
    """Report folder
175
    """
176
177
# TODO Remove in >v1.3.0
178
class ISample(Interface):
179
    """Sample
180
    """
181
182
183
class ISampleCondition(Interface):
184
    """Sample Condition
185
    """
186
187
188
class ISampleConditions(Interface):
189
    """Sample Conditions
190
    """
191
192
193
class ISampleMatrix(Interface):
194
    """Sample Matrix
195
    """
196
197
198
class ISampleMatrices(Interface):
199
    """Sample Matrices
200
    """
201
202
203
class ISamplePartition(Interface):
204
    """Sample
205
    """
206
207
208
class ISamplesFolder(Interface):
209
    """Samples Folder
210
    """
211
212
213
class ISamplingDeviation(Interface):
214
    """Sampling Deviation
215
    """
216
217
218
class ISamplingDeviations(Interface):
219
    """Sampling Deviations
220
    """
221
222
223
class IWorksheetFolder(Interface):
224
    """WorksheetFolder
225
    """
226
227
228
class IWorksheet(Interface):
229
    """Worksheet
230
    """
231
232
233
class IReferenceSample(Interface):
234
    """Reference Sample
235
    """
236
237
238
class IReferenceSamplesFolder(Interface):
239
    """Reference Samples Folder
240
    """
241
242
243
class IReportsFolder(Interface):
244
    """Reports Folder
245
    """
246
247
248
class IInvoice(Interface):
249
    """Invoice
250
    """
251
252
253
class IInvoiceBatch(Interface):
254
    """Invoice Batch
255
    """
256
257
258
class IInvoiceFolder(Interface):
259
    """Invoices Folder
260
    """
261
262
263
class IBikaSetup(Interface):
264
    """Marker interface for the LIMS Setup
265
    """
266
267
268
class IAnalysisCategory(Interface):
269
    """Marker interface for an Analysis Category
270
    """
271
272
273
class IAnalysisCategories(Interface):
274
    """Marker interface for Analysis Categories
275
    """
276
277
278
class IBaseAnalysis(Interface):
279
    """Marker interface for base Analysis
280
    """
281
282
283
class IAnalysisService(Interface):
284
    """Marker interface for Analysis Service
285
    """
286
287
288
class IAnalysisServices(Interface):
289
    """Marker interface for Analysis Services
290
    """
291
292
293
class IAttachmentTypes(Interface):
294
    """Marker interface for Attachment types
295
    """
296
297
298
class ICalculation(Interface):
299
    """Marker interface for a Calculation
300
    """
301
302
303
class ICalculations(Interface):
304
    """Marker interface for Calculations
305
    """
306
307
308
class IContacts(Interface):
309
    """Marker interface for Contacts
310
    """
311
312
313
class IContact(Interface):
314
    """Marker interface for a single Contact
315
    """
316
317
318
class IDepartments(Interface):
319
    """Marker interface for a Departments
320
    """
321
322
323
class IContainers(Interface):
324
    """Marker interface for Containers
325
    """
326
327
328
class IContainerTypes(Interface):
329
    """Marker interface for Container types
330
    """
331
332
333
class IIdentifierTypes(Interface):
334
    """TODO: Remove in senaite.core 1.3.3
335
    """
336
337
338
class IHaveIdentifiers(Interface):
339
    """TODO: Remove in senaite.core 1.3.3
340
    """
341
342
343
class IInstrument(Interface):
344
    """Marker interface for an Instrument
345
    """
346
347
348
class IInstruments(Interface):
349
    """Marker interface for Instruments
350
    """
351
352
353
class IInstrumentType(Interface):
354
    """Marker interface for an instrument type
355
    """
356
357
358
class IInstrumentTypes(Interface):
359
    """Marker interface for instrument types
360
    """
361
362
363
class IInstrumentLocation(Interface):
364
    """A physical place, where instruments can be located
365
    """
366
367
368
class IInstrumentLocations(Interface):
369
    """Physical places, where instruments can be located
370
    """
371
372
373
class IInstrumentCalibration(Interface):
374
    """Instrument Calibration
375
    """
376
377
378
class IInstrumentCertification(Interface):
379
    """Instrument Certification
380
    """
381
382
383
class IInstrumentValidation(Interface):
384
    """Instrument Validation
385
    """
386
387
388
class IAnalysisSpecs(Interface):
389
    """Marker interface for Analysis Specs
390
    """
391
392
393
class IAnalysisProfile(Interface):
394
    """Marker interface for an Analysis Profile
395
    """
396
397
398
class IAnalysisProfiles(Interface):
399
    """Marker interface for analysis profiles
400
    """
401
402
403
class IARTemplate(Interface):
404
    """Marker interface for an AR Template
405
    """
406
407
408
class IARTemplates(Interface):
409
    """Marker interface for AR templates
410
    """
411
412
413
class ILaboratory(Interface):
414
    """Marker interface for Laboratory
415
    """
416
417
418
class ILabContacts(Interface):
419
    """Marker interface for Lab contacts
420
    """
421
422
423
class ILabContact(Interface):
424
    """Marker interface for a lab contact
425
    """
426
427
428
class IManufacturer(Interface):
429
    """Marker interface for Manufacturer
430
    """
431
432
433
class IManufacturers(Interface):
434
    """Marker interface for Manufacturers
435
    """
436
437
438
class IMethods(Interface):
439
    """Marker interface for Methods
440
    """
441
442
443
class IMethod(Interface):
444
    """Marker interface for Method
445
    """
446
447
448
class IMultifile(Interface):
449
    """Marker interface for a Multifile
450
    """
451
452
453
class ILabProducts(Interface):
454
    """Marker interface for Lab Products
455
    """
456
457
458
class ISamplePoint(Interface):
459
    """Marker interface for a Sample Point
460
    """
461
462
463
class ISamplePoints(Interface):
464
    """Marker interface for Sample Points
465
    """
466
467
468
class IStorageLocation(Interface):
469
    """Marker interface for a Storage Location
470
    """
471
472
473
class IStorageLocations(Interface):
474
    """Marker interface for Storage Location
475
    """
476
477
478
class ISampleType(Interface):
479
    """Marker interface for a Sample Type
480
    """
481
482
483
class ISampleTypes(Interface):
484
    """Marker interface for Sample Types
485
    """
486
487
488
class ISamplingRoundTemplates(Interface):
489
    """Marker interface for Sampling Round Templates
490
    """
491
492
493
class ISamplingRoundTemplate(Interface):
494
    """Marker interface for a Sampling Round Template
495
    """
496
497
498
class ISupplier(Interface):
499
    """Marker interface for a Supplier
500
    """
501
502
503
class ISuppliers(Interface):
504
    """Marker interface for Suplliers
505
    """
506
507
508
class ISupplyOrder(Interface):
509
    """Marker interface for a Supplier Order
510
    """
511
512
513
class ISupplyOrderFolder(Interface):
514
    """Marker interface for Supply Order Folder
515
    """
516
517
518
class ISubGroups(Interface):
519
    """Sub-groups configuration folder
520
    """
521
522
523
class ISubGroup(Interface):
524
    """Sub-Group
525
    """
526
527
528
class IPreservations(Interface):
529
    """Marker interface for Preservations
530
    """
531
532
533
class IReferenceDefinitions(Interface):
534
    """Marker interface for Reference Definitions
535
    """
536
537
538
class IWorksheetTemplates(Interface):
539
    """Marker interface for Worksheet Templates
540
    """
541
542
543
class IBikaCatalog(Interface):
544
    """Marker interface for bika_catalog
545
    """
546
547
548
class IBikaAnalysisCatalog(Interface):
549
    """Marker interface for bika_analysis_catalog
550
    """
551
552
553
class IBikaSetupCatalog(Interface):
554
    """Marker interface for bika_setup_catalog
555
    """
556
557
558
class IBikaCatalogAnalysisRequestListing(Interface):
559
    """Marker interface for bika_catalog_analysisrequest_listing
560
    """
561
562
563
class IBikaCatalogAutoImportLogsListing(Interface):
564
    """Marker interface for bika_catalog_autoimportlogs_listing
565
    """
566
567
568
class IBikaCatalogWorksheetListing(Interface):
569
    """Marker interface for bika_catalog_worksheet_listing
570
    """
571
572
573
class IBikaCatalogReport(Interface):
574
    """Marker interface for bika_catalog_report
575
    """
576
577
578
class IIdServer(Interface):
579
    """Marker Interface for ID server
580
    """
581
582
    def generate_id(self, portal_type, batch_size=None):
583
        """Generate a new id for 'portal_type'
584
        """
585
586
587
class IReferenceWidgetVocabulary(Interface):
588
    """Return values for reference widgets in AR contexts
589
    """
590
591
    def __call__(**kwargs):
592
        """Call method
593
        """
594
595
596
class IDisplayListVocabulary(Interface):
597
    """Make vocabulary from catalog query.
598
599
    Return a DisplayList.
600
    kwargs are added to contentFilter.
601
    """
602
603
    def __call__(**kwargs):
604
        """Call method
605
        """
606
607
608
class IFieldIcons(Interface):
609
    """Used to signal an analysis result out of range alert
610
    """
611
612
    def __call__(self, result=None, **kwargs):
613
        """Returns a dictionary: with the keys 'field', 'icon', 'message'.
614
615
        If result is specified, it's checked instead of the database.  This
616
        is for form validations.
617
618
        Analysis range checkers can include a 'specification' in kwargs to
619
        override the spec derived from the context. It should be a dict
620
        w/ 'min', 'max', and 'error' keys.
621
        """
622
623
624
class IResultOutOfRange(Interface):
625
    """Any code which wants to check some condition and flag an Analysis as
626
    out of range, uses this interface
627
    """
628
    def __call(result=None):
629
        """The adapter must return a dictionary to indicate range out of bounds:
630
        {
631
         out_of_range: boolean - the result is out of bounds,
632
         acceptable: boolean - the result is in acceptable error margin,
633
         spec_values: dict - the min/max/error values for the failed spec
634
        }
635
636
        If the adapter returns a value that resolves to boolean False, the
637
        analysis is assumed not to have triggered the out of range conditions
638
639
        If a result is present in the request, it is passed here to be checked.
640
        if result is None, the value from the database is checked.
641
642
        """
643
644
645
class IATWidgetVisibility(Interface):
646
    """Adapter to modify the default list of fields to show on each view.
647
648
    Archetypes uses a widget attribute called 'visible' to decide which fields
649
    are editable or viewable in different contexts (view and edit).
650
651
    This adapter lets you create/use arbitrary keys in the field.widget.visible
652
    attribute, or or any other condition to decide if a particular field is
653
    displayed or not.
654
655
    an attribute named 'sort', if present, is an integer.
656
    It is used to allow some adapters to take preference over others.
657
    It's default is '1000', other lower values will take preference over higher
658
    values.
659
    """
660
661
    def __call__(widget, instance, mode, vis_dict, default=None, field=None):
662
        """Returns the visibility attribute for this particular field, in the
663
        current context.
664
665
        :arg field: the AT schema field object
666
        :arg mode: 'edit', 'view', or some custom mode, eg 'add', 'secondary'
667
        :arg vis_dict: the original schema value of field.widget.visible
668
        :arg default: value returned by the base Archetypes.Widget.isVisible
669
670
        In default Archetypes the value for the attribute on the field may
671
        either be a dict with a mapping for edit and view::
672
673
            visible = { 'edit' :'hidden', 'view': 'invisible' }
674
675
        Or a single value for all modes::
676
677
            True/1:  'visible'
678
            False/0: 'invisible'
679
            -1:      'hidden'
680
681
        visible: The field is shown in the view/edit screen
682
        invisible: The field is skipped when rendering the visVisibleiew/edit
683
                   screen
684
        hidden: The field is added as <input type="hidden" />
685
        The default state is 'visible'.
686
687
        The default rules are always applied, but any IATWidgetVisibility
688
        adapters found are called and permitted to modify the value.
689
        """
690
691
692
class ISetupDataSetList(Interface):
693
    """Allow products to register distributed setup datasets (xlsx files).
694
695
    Each ISetupDataSetList adapter returns a list of values to be included in
696
    the load_setup_data view
697
    """
698
699
700
class IJSONReadExtender(Interface):
701
    """This interface allows an adapter to modify an object's data before
702
    it is sent to the HTTP response.
703
    """
704
705
    def __call__(obj_data):
706
        """obj_data is the current python dictionary that will go to json.
707
        it should be modified in place, there is no need to return a value.
708
        """
709
710
711
class ISetupDataImporter(Interface):
712
    """ISetupDataImporter adapters are responsible for importing sections of
713
    the load_setup_data xlsx workbooks.
714
    """
715
716
717
class IARImportFolder(Interface):
718
    """Marker interface for a folder that contains ARImports
719
    """
720
721
722
class IARImport(Interface):
723
    """Marker interface for an ARImport
724
    """
725
726
727
class IPricelist(Interface):
728
    """Folder view marker for Pricelist
729
    """
730
731
732
class IPricelistFolder(Interface):
733
    """Folder view marker for PricelistFolder instance
734
    """
735
736
737
class IProductivityReport(Interface):
738
    """Reports are enumerated manually in reports/*.pt - but addional reports
739
    can be added to this list by extension packages using this adapter.
740
741
    The adapter must return a dictionary:
742
743
    {
744
     title: text (i18n translated),
745
     description: text (i18n translated),
746
     query_form: html <fieldset> of controls used to enter report
747
                 parameters (excluding <form> tags and <submit> button)
748
     module: The name of the module containing a class named "Report"
749
             an instance of this class will be used to create the report
750
    }
751
    """
752
753
754
class IAdministrationReport(Interface):
755
    """Reports are enumerated manually in reports/*.pt - but addional reports
756
    can be added to this list by extension packages using this adapter.
757
758
    The adapter must return a dictionary:
759
760
    {
761
     title: text (i18n translated),
762
     description: text (i18n translated),
763
     query_form: html <fieldset> of controls used to enter report
764
                 parameters (excluding <form> tags and <submit> button)
765
     module: The name of the module containing a class named "Report"
766
             an instance of this class will be used to create the report
767
    }
768
    """
769
770
771
class IHeaderTableFieldRenderer(Interface):
772
    """
773
    Allows an adapter to return the HTML content of the rendered field view,
774
    in header_table listings. The adapter must be registered with
775
    name=FieldName.
776
777
    If the field is a Reference, and the user has View permission on the
778
    target object, the field is rendered as <a href="absolute_url">Title</a>.
779
780
    If no adapter is found, and the field is not a reference, it is rendered
781
    with the normal AT field view machine.
782
783
    In a ZCML somewhere:
784
785
        <adapter
786
          for="bika.lims.interfaces.IAnalysisRequest"
787
          factory="package.module.spanner"
788
          provides="bika.lims.interfaces.IHeaderTableFieldRenderer"
789
          name="NameOfArchetypesField"
790
        />
791
792
    and the callable:
793
794
        class spanner:
795
            def __init__(self, context):
796
                self.context = context
797
            def __call__(self, field):
798
                field_content = field.get(self.context)
799
                return "<span>%"+field_content+"</span>"
800
801
    """
802
803
    def __call__(field):
804
        """
805
        Accepts an Archetypes Field, returns HTML.
806
        """
807
808
809
class IReflexRule(Interface):
810
    """Marker interface for a Reflex Rule
811
    """
812
813
814
class IReflexRuleFolder(Interface):
815
    """Marker interface for the Reflex Rule Folder
816
    """
817
818
819
class IDepartment(Interface):
820
    """Marker interface for a Department
821
    """
822
823
824
class IProxyField(Interface):
825
    """A field that proxies transparently to the field of another object.
826
    Mainly needed for AnalysisRequest fields that are actually stored on the
827
    Sample.
828
    """
829
830
831
class IRemarksField(Interface):
832
    """An append-only TextField which saves information about each edit
833
    """
834
835
836
class IARAnalysesField(Interface):
837
    """A field that manages AR Analyses
838
    """
839
840
841
class IFrontPageAdapter(Interface):
842
    """Front Page Url Finder Adapter's Interface
843
    """
844
845
    def get_front_page_url(self):
846
        """Get url of necessary front-page
847
        """
848
849
850
class INumberGenerator(Interface):
851
    """A utility to generates unique numbers by key
852
    """
853
854
855
class ITopRightHTMLComponentsHook(Interface):
856
    """Marker interface to hook html components in bikalisting
857
    """
858
859
860
class ITopLeftHTMLComponentsHook(Interface):
861
    """Marker interface to hook html components in bikalisting
862
    """
863
864
865
class ITopWideHTMLComponentsHook(Interface):
866
    """Marker interface to hook html components in bikalisting
867
    """
868
869
870
class IGetDefaultFieldValueARAddHook(Interface):
871
    """Marker interface to hook default
872
    """
873
874
875
class IGetStickerTemplates(Interface):
876
    """Marker interface to get stickers for a specific content type.
877
878
    An IGetStickerTemplates adapter should return a result with the
879
    following format:
880
881
    :return: [{'id': <template_id>,
882
             'title': <template_title>}, ...]
883
    """
884
885
886
class IARReport(Interface):
887
    """Marker interface for published AR Reports
888
    """
889
890
891
class ICancellable(Interface):
892
    """Marker for those objects that can be cancelled (have state "cancelled")
893
    """
894
895
896
class IDeactivable(Interface):
897
    """Marker for those objects that can be deactivated (have state "inactive")
898
    """
899
900
901
class IWorkflowActionAdapter(Interface):
902
    """Marker for adapters in charge of processing workflow action requests
903
    from views
904
    """
905
906
907
class IWorkflowActionUIDsAdapter(IWorkflowActionAdapter):
908
    """Marker for adapters in charge of processing workflow action requests
909
    from views, but meant for redirection only
910
    """
911
912
913
class IVerified(Interface):
914
    """Marker interface for verified objects
915
    """
916
917
918
class ISubmitted(Interface):
919
    """Marker interface for submitted objects
920
    """
921
922
923
class IReceived(Interface):
924
    """Marker interface for received objects
925
    """
926
927
928
class IInternalUse(Interface):
929
    """Marker interface for objects only lab personnel must have access
930
    """
931
932
933
class IDetachedPartition(Interface):
934
    """Marker interface for samples that have been detached from its primary
935
    """
936
937
938
class IGuardAdapter(Interface):
939
    """Marker interface for guard adapters
940
    """
941
942
    def guard(self, transition):
943
        """Return False if you want to block the transition
944
        """
945
946
947
class IAddSampleFieldsFlush(Interface):
948
    """Marker interface for field dependencies flush for Add Sample form
949
    """
950
951
    def get_flush_settings(self):
952
        """Returns a dict where the key is the name of the field and the value
953
        is an array dependencies as field names
954
        """
955
956
957
class IAddSampleObjectInfo(Interface):
958
    """Marker interface for objects metadata mapping
959
    """
960
961
    def get_object_info(self):
962
        """Returns the dict representation of the context object for its
963
        correct consumption by Sample Add form:
964
965
        {'id': <id_of_the_object>,
966
         'uid': <uid_of_the_object>,
967
         'title': <title_of_the_object>,
968
         'filter_queries': {
969
             <dependent_field_name>: {
970
                 <catalog_index>: <criteria>
971
             }
972
         },
973
         'field_values': {
974
             <dependent_field_name>: {
975
                <uid>: <dependent_uid>,
976
                <title>: <dependent_title>
977
            }
978
         }
979
980
        Besides the basic keys (id, uid, title), two additional keys can be
981
        provided:
982
        - filter_queries: contains the filter queries for other fields to be
983
          applied when the value of current field changes.
984
        - field_values: contains default values for other fields to be applied
985
          when the value of the current field changes.
986
        """
987
988
989
class IClientAwareMixin(Interface):
990
    """Marker interface for objects that can be bound to a Client, either
991
    because they can be added inside a Client folder or because it can be
992
    assigned through a Reference field
993
    """
994
995
    def getClient(self):
996
        """Returns the client this object is bound to, if any
997
        """
998
999
    def getClientUID(self):
1000
        """Returns the client UID this object is bound to, if any
1001
        """
1002