<commit_before>package controllers.s_self_employment

import play.api.mvc._
import models.view.CachedClaim
import models.domain._
import models.view.Navigable
import play.api.i18n.Lang
import models.view.ClaimHandling.ClaimResult
import controllers.mappings.Mappings._

object SelfEmployment extends Controller with CachedClaim with Navigable {
  def completed = claimingWithCheck {implicit claim =>  implicit request =>  lang =>
    redirect(lang)
  }

  def completedSubmit = claimingWithCheck { implicit claim =>  implicit request =>  lang =>
    redirect(lang)
  }

  def presentConditionally(c: => ClaimResult, lang: Lang)(implicit claim: Claim, request: Request[AnyContent]): ClaimResult = {
    val beenInPreview = claim.previouslySavedClaim.isDefined
    val emp = claim.questionGroup[Employment].getOrElse(Employment())
    //Lazy because they are going to be lazily evaluated on usage only if we've been in preview.
    lazy val previousEmp = claim.previouslySavedClaim.get.questionGroup[Employment]
    lazy val previousSEValue = previousEmp.get.beenSelfEmployedSince1WeekBeforeClaim
    val SEValue = emp.beenSelfEmployedSince1WeekBeforeClaim

    if (models.domain.SelfEmployment.visible && (!beenInPreview || beenInPreview && SEValue == yes && previousSEValue == no)) c
    else redirect(lang)
  }

  private def redirect(lang: Lang)(implicit claim: Claim, request: Request[AnyContent]): ClaimResult =
    claim -> Redirect(controllers.s_employment.routes.GBeenEmployed.present())
}<commit_msg>DE963 - Problem with check your answers flow logic when changing self employment. Since we can't change that section yet, the conflictive logic has been removed and marked as to be reviewed on the story that handles the enablement of changing self employment from check your answers.<commit_after>package controllers.s_self_employment

import play.api.Logger
import play.api.mvc._
import models.view.CachedClaim
import models.domain._
import models.view.Navigable
import play.api.i18n.Lang
import models.view.ClaimHandling.ClaimResult
import controllers.mappings.Mappings._

object SelfEmployment extends Controller with CachedClaim with Navigable {
  def completed = claimingWithCheck {implicit claim =>  implicit request =>  lang =>
    redirect(lang)
  }

  def completedSubmit = claimingWithCheck { implicit claim =>  implicit request =>  lang =>
    redirect(lang)
  }

  def presentConditionally(c: => ClaimResult, lang: Lang)(implicit claim: Claim, request: Request[AnyContent]): ClaimResult = {
    val beenInPreview = claim.previouslySavedClaim.isDefined
    val emp = claim.questionGroup[Employment].getOrElse(Employment())
    //Lazy because they are going to be lazily evaluated on usage only if we've been in preview.
    lazy val previousEmp = claim.previouslySavedClaim.get.questionGroup[Employment]
    lazy val previousSEValue = previousEmp.get.beenSelfEmployedSince1WeekBeforeClaim
    val SEValue = emp.beenSelfEmployedSince1WeekBeforeClaim
                                                 //This part of the condition has been removed due to review on user story about enabling changing employment/self-employment on check your answers
    if (models.domain.SelfEmployment.visible ) c //&& (!beenInPreview || beenInPreview && SEValue == yes && previousSEValue == no)) c
    else redirect(lang)
  }

  private def redirect(lang: Lang)(implicit claim: Claim, request: Request[AnyContent]): ClaimResult =
    claim -> Redirect(controllers.s_employment.routes.GBeenEmployed.present())
}
{'fraction_non_alphanumeric': 0.08091168091168091, 'fraction_numerical': 0.0031339031339031338, 'mean_word_length': 4.644694533762058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7586802', 'n_tokens_mistral': 962, 'n_tokens_neox': 925, 'n_words': 286}