def edit_check(user, petition):
    """
    Logic to determine if the user should be able to edit the petition
    Cases when this should be true:
      - User is the author of the petition
      - User is a moderator / admin
    *Note: These cases will be a setting in the future to allow the moderators to choose who
     can / cannot edit a petition
    :param user: The user object
    :param petition: The petition object
    :return: True / False, if the user can edit the current petition.
    """

    # Initially set the edit variable to false.
    edit = False
    # Check if the user is logged in
    if user.is_authenticated:
        # Check if the user's account is active (it may be disabled)
        if user.is_active:
            # Check if the user the author of the petition and the petition must not have already been published.
            if user.id == petition.author.id and petition.status == 0:
                # The user is authenticated, and can edit the petition!
                edit = True
    return edit