Code Duplication    Length = 22-22 lines in 2 locations

bika/lims/api/__init__.py 2 locations

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