Code Duplication    Length = 22-22 lines in 2 locations

bika/lims/api/__init__.py 2 locations

@@ 835-856 (lines=22) @@
832
    return state
833
834
835
def get_inactive_status(brain_or_object, default="active"):
836
    """Get the `cancellation_state` of an objct
837
838
    :param brain_or_object: A single catalog brain or content object
839
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
840
    :returns: Value of the review_status variable
841
    :rtype: String
842
    """
843
844
    if is_brain(brain_or_object):
845
        state = getattr(brain_or_object, "inactive_state", None)
846
        if state is not None:
847
            return state
848
849
    workflows = get_workflows_for(brain_or_object)
850
    if "bika_inactive_workflow" in workflows:
851
        return get_workflow_status_of(brain_or_object, "inactive_state")
852
853
    state = get_workflow_status_of(brain_or_object)
854
    if state not in ("active", "inactive"):
855
        return default
856
    return state
857
858
859
def is_active(brain_or_object):
@@ 811-832 (lines=22) @@
808
    return get_workflow_status_of(brain_or_object, state_var="review_state")
809
810
811
def get_cancellation_status(brain_or_object, default="active"):
812
    """Get the `cancellation_state` of an object
813
814
    :param brain_or_object: A single catalog brain or content object
815
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
816
    :returns: Value of the review_status variable
817
    :rtype: String
818
    """
819
820
    if is_brain(brain_or_object):
821
        state = getattr(brain_or_object, "cancellation_state", None)
822
        if state is not None:
823
            return state
824
825
    workflows = get_workflows_for(brain_or_object)
826
    if "bika_cancellation_workflow" in workflows:
827
        return get_workflow_status_of(brain_or_object, "cancellation_state")
828
829
    state = get_workflow_status_of(brain_or_object)
830
    if state not in ("active", "inactive"):
831
        return default
832
    return state
833
834
835
def get_inactive_status(brain_or_object, default="active"):