Passed
Push — master ( e83033...10ce0d )
by Ramon
05:04 queued 01:01
created

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