Code Duplication    Length = 22-22 lines in 2 locations

bika/lims/api/__init__.py 2 locations

@@ 820-841 (lines=22) @@
817
    return state
818
819
820
def get_inactive_status(brain_or_object, default="active"):
821
    """Get the `cancellation_state` of an objct
822
823
    :param brain_or_object: A single catalog brain or content object
824
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
825
    :returns: Value of the review_status variable
826
    :rtype: String
827
    """
828
829
    if is_brain(brain_or_object):
830
        state = getattr(brain_or_object, "inactive_state", None)
831
        if state is not None:
832
            return state
833
834
    workflows = get_workflows_for(brain_or_object)
835
    if "bika_inactive_workflow" in workflows:
836
        return get_workflow_status_of(brain_or_object, "inactive_state")
837
838
    state = get_workflow_status_of(brain_or_object)
839
    if state not in ("active", "inactive"):
840
        return default
841
    return state
842
843
844
def is_active(brain_or_object):
@@ 796-817 (lines=22) @@
793
    return get_workflow_status_of(brain_or_object, state_var="review_state")
794
795
796
def get_cancellation_status(brain_or_object, default="active"):
797
    """Get the `cancellation_state` of an object
798
799
    :param brain_or_object: A single catalog brain or content object
800
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
801
    :returns: Value of the review_status variable
802
    :rtype: String
803
    """
804
805
    if is_brain(brain_or_object):
806
        state = getattr(brain_or_object, "cancellation_state", None)
807
        if state is not None:
808
            return state
809
810
    workflows = get_workflows_for(brain_or_object)
811
    if "bika_cancellation_workflow" in workflows:
812
        return get_workflow_status_of(brain_or_object, "cancellation_state")
813
814
    state = get_workflow_status_of(brain_or_object)
815
    if state not in ("active", "inactive"):
816
        return default
817
    return state
818
819
820
def get_inactive_status(brain_or_object, default="active"):