Passed
Push — master ( 354e15...69376c )
by Jordi
04:34
created

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