class CompetitionSetupController {

    @PostMapping("/{competitionId}/section/{sectionPath}/edit")
    public String setSectionAsIncomplete(@PathVariable(COMPETITION_ID_KEY) long competitionId,
                                         @PathVariable(SECTION_PATH_KEY) String sectionPath) {
        CompetitionSetupSection section = CompetitionSetupSection.fromPath(sectionPath);
        if (section == null) {
            LOG.error("Invalid section path specified: " + sectionPath);
            return DASHBOARD_REDIRECT;
        }

        CompetitionResource competition = competitionRestService.getCompetitionById(competitionId).getSuccess();

        if (section.preventEdit(competition)) {
            return DASHBOARD_REDIRECT;
        }

        if (!competitionSetupService.hasInitialDetailsBeenPreviouslySubmitted(competitionId) && section != CompetitionSetupSection.INITIAL_DETAILS) {
            return "redirect:/competition/setup/" + competition.getId();
        }

        return competitionSetupRestService.markSectionIncomplete(competitionId, section).handleSuccessOrFailure(
                failure -> "redirect:/competition/setup/" + competition.getId(),
                success -> {
                    if (!competition.isSetupAndLive()) {
                        competitionSetupService.setCompetitionAsCompetitionSetup(competitionId);
                    }
                    return "redirect:/competition/setup/" + competitionId + "/section/" + section.getPostMarkIncompletePath();
                }
        );
    }

}