From 5fefe38e60d03cc0f9a3da04a2f8ad82142a59cb Mon Sep 17 00:00:00 2001 From: Ben Stephenson Date: Tue, 3 Jan 2017 16:27:31 +0000 Subject: [PATCH 1/2] Capture campaign referrer at signup and remove from assistance details model. --- app/binders/UniqueIdentifierBinder.scala | 2 +- app/config/frontendAppConfig.scala | 2 +- app/config/frontendGlobal.scala | 2 +- app/config/frontendWiring.scala | 2 +- .../AllocationExchangeObjects.scala | 2 +- app/connectors/ApplicationClient.scala | 43 +++++++++---------- app/connectors/ExchangeObjects.scala | 10 ++--- app/connectors/SchemeClient.scala | 2 +- app/connectors/UserManagementClient.scala | 2 +- .../addresslookup/AddressLookupClient.scala | 2 +- .../addresslookup/AddressRecord.scala | 2 +- .../exchange/ProgressResponse.scala | 2 +- app/connectors/package.scala | 2 +- app/controllers/ActivationController.scala | 2 +- app/controllers/Application.scala | 2 +- app/controllers/AssistanceController.scala | 26 ++++------- app/controllers/BaseController.scala | 2 +- app/controllers/FastTrackApplication.scala | 2 +- app/controllers/HomeController.scala | 2 +- app/controllers/LandingPageController.scala | 2 +- app/controllers/LockAccountController.scala | 2 +- app/controllers/OnlineTestController.scala | 2 +- app/controllers/PasswordResetController.scala | 2 +- app/controllers/QuestionnaireController.scala | 2 +- .../ReviewApplicationController.scala | 2 +- app/controllers/SchemeController.scala | 2 +- app/controllers/SignInController.scala | 2 +- app/controllers/SignUpController.scala | 20 ++++++--- .../SubmitApplicationController.scala | 2 +- .../test/AddressLookupController.scala | 2 +- app/filters/CookiePolicyFilter.scala | 2 +- app/forms/ActivateAccountform.scala | 2 +- app/forms/AlternateLocationsForm.scala | 2 +- app/forms/AssistanceForm.scala | 10 ++--- app/forms/GeneralDetailsForm.scala | 2 +- app/forms/LockAccountForm.scala | 2 +- app/forms/Mappings.scala | 2 +- .../QuestionnaireDiversityInfoForm.scala | 2 +- .../QuestionnaireEducationInfoForm.scala | 2 +- .../QuestionnaireOccupationInfoForm.scala | 2 +- app/forms/RequestResetPasswordForm.scala | 2 +- app/forms/ResetPasswordForm.scala | 2 +- app/forms/SchemeLocationPreferenceForm.scala | 2 +- app/forms/SignInForm.scala | 2 +- app/forms/SignUpForm.scala | 10 +++-- app/forms/WithdrawApplicationForm.scala | 2 +- app/forms/package.scala | 2 +- app/helpers/CSRFieldConstructor.scala | 2 +- app/helpers/NotificationType.scala | 2 +- app/mappings/Address.scala | 2 +- app/mappings/DayMonthYear.scala | 2 +- app/mappings/PhoneNumberMapping.scala | 2 +- app/mappings/PostCodeMapping.scala | 2 +- app/models/AdjustmentTypes.scala | 2 +- app/models/ApplicationData.scala | 2 +- app/models/AssistanceTypes.scala | 2 +- app/models/CampaignReferrers.scala | 2 +- app/models/CookiePolicy.scala | 2 +- app/models/Employee.scala | 2 +- app/models/Ethnicity.scala | 2 +- app/models/Gender.scala | 2 +- app/models/Nationalities.scala | 2 +- app/models/Occupations.scala | 2 +- app/models/OrganizationSize.scala | 2 +- app/models/Progress.scala | 2 +- app/models/SecurityUser.scala | 2 +- app/models/SexOrientation.scala | 2 +- app/models/Supervise.scala | 2 +- app/models/UniqueIdentifier.scala | 2 +- app/models/WithdrawReasons.scala | 2 +- app/models/frameworks/Location.scala | 2 +- .../LocationAndSchemeSelection.scala | 2 +- app/models/frameworks/Region.scala | 2 +- app/models/page/DashboardPage.scala | 2 +- app/models/services/UserCacheService.scala | 2 +- app/models/services/UserService.scala | 2 +- app/security/CsrCredentialsProvider.scala | 2 +- app/security/Roles.scala | 2 +- app/security/SecureActions.scala | 2 +- app/security/SecurityEnvironment.scala | 2 +- app/security/SignInUtils.scala | 2 +- app/views/application/assistance.scala.html | 18 -------- app/views/registration/signup.scala.html | 18 +++++++- conf/application.conf | 4 +- conf/silhouette.conf | 2 +- 85 files changed, 152 insertions(+), 159 deletions(-) diff --git a/app/binders/UniqueIdentifierBinder.scala b/app/binders/UniqueIdentifierBinder.scala index 0cc3386..7f2c8a0 100644 --- a/app/binders/UniqueIdentifierBinder.scala +++ b/app/binders/UniqueIdentifierBinder.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/config/frontendAppConfig.scala b/app/config/frontendAppConfig.scala index 51f1545..db3bf68 100644 --- a/app/config/frontendAppConfig.scala +++ b/app/config/frontendAppConfig.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/config/frontendGlobal.scala b/app/config/frontendGlobal.scala index 87dbceb..cb34668 100644 --- a/app/config/frontendGlobal.scala +++ b/app/config/frontendGlobal.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/config/frontendWiring.scala b/app/config/frontendWiring.scala index 21f9a1b..f367e34 100644 --- a/app/config/frontendWiring.scala +++ b/app/config/frontendWiring.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/AllocationExchangeObjects.scala b/app/connectors/AllocationExchangeObjects.scala index 50f004a..17715ee 100644 --- a/app/connectors/AllocationExchangeObjects.scala +++ b/app/connectors/AllocationExchangeObjects.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/ApplicationClient.scala b/app/connectors/ApplicationClient.scala index 7633b0e..e5ee297 100644 --- a/app/connectors/ApplicationClient.scala +++ b/app/connectors/ApplicationClient.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,14 +42,16 @@ trait ApplicationClient { import ExchangeObjects.Implicits._ import config.FrontendAppConfig.fasttrackConfig._ - def createApplication(userId: UniqueIdentifier, frameworkId: String)(implicit hc: HeaderCarrier) = { + def createApplication(userId: UniqueIdentifier, frameworkId: String) + (implicit hc: HeaderCarrier): Future[ApplicationResponse] = { http.PUT(s"${url.host}${url.base}/application/create", CreateApplicationRequest(userId, frameworkId)).map { response => response.json.as[ApplicationResponse] } } - def submitApplication(userId: UniqueIdentifier, applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = { + def submitApplication(userId: UniqueIdentifier, applicationId: UniqueIdentifier) + (implicit hc: HeaderCarrier): Future[Unit] = { http.PUT(s"${url.host}${url.base}/application/submit/$userId/$applicationId", Json.toJson("")).map { case x: HttpResponse if x.status == OK => () }.recover { @@ -57,7 +59,8 @@ trait ApplicationClient { } } - def withdrawApplication(applicationId: UniqueIdentifier, reason: WithdrawApplicationRequest)(implicit hc: HeaderCarrier) = { + def withdrawApplication(applicationId: UniqueIdentifier, reason: WithdrawApplicationRequest) + (implicit hc: HeaderCarrier): Future[Unit] = { http.PUT(s"${url.host}${url.base}/application/withdraw/$applicationId", Json.toJson(reason)).map { case x: HttpResponse if x.status == OK => () }.recover { @@ -65,7 +68,7 @@ trait ApplicationClient { } } - def addMedia(userId: UniqueIdentifier, media: String)(implicit hc: HeaderCarrier) = { + def addMedia(userId: UniqueIdentifier, media: String)(implicit hc: HeaderCarrier): Future[Unit] = { http.PUT(s"${url.host}${url.base}/media/create", AddMedia(userId, media)).map { case x: HttpResponse if x.status == CREATED => () } recover { @@ -73,13 +76,13 @@ trait ApplicationClient { } } - def getApplicationProgress(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = { + def getApplicationProgress(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier): Future[ProgressResponse] = { http.GET(s"${url.host}${url.base}/application/progress/$applicationId").map { response => response.json.as[ProgressResponse] } } - def findApplication(userId: UniqueIdentifier, frameworkId: String)(implicit hc: HeaderCarrier) = { + def findApplication(userId: UniqueIdentifier, frameworkId: String)(implicit hc: HeaderCarrier): Future[ApplicationResponse] = { http.GET(s"${url.host}${url.base}/application/find/user/$userId/framework/$frameworkId").map { response => response.json.as[ApplicationResponse] } recover { @@ -87,10 +90,8 @@ trait ApplicationClient { } } - def updateGeneralDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: GeneralDetailsForm.Data, email: String)( - implicit - hc: HeaderCarrier - ) = { + def updateGeneralDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: GeneralDetailsForm.Data, + email: String)(implicit hc: HeaderCarrier): Future[Unit] = { http.POST( s"${url.host}${url.base}/personal-details/$userId/$applicationId", @@ -113,7 +114,8 @@ trait ApplicationClient { } } - def findPersonalDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = { + def findPersonalDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier) + (implicit hc: HeaderCarrier): Future[GeneralDetailsExchange] = { http.GET(s"${url.host}${url.base}/personal-details/$userId/$applicationId").map { response => response.json.as[GeneralDetailsExchange] } recover { @@ -121,10 +123,8 @@ trait ApplicationClient { } } - def updateAssistanceDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: AssistanceForm.Data)( - implicit - hc: HeaderCarrier - ) = { + def updateAssistanceDetails(applicationId: UniqueIdentifier, userId: UniqueIdentifier, data: AssistanceForm.Data) + (implicit hc: HeaderCarrier): Future[Unit] = { http.PUT( s"${url.host}${url.base}/assistance-details/$userId/$applicationId", data.exchange @@ -135,7 +135,8 @@ trait ApplicationClient { } } - def findAssistanceDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = { + def findAssistanceDetails(userId: UniqueIdentifier, applicationId: UniqueIdentifier) + (implicit hc: HeaderCarrier): Future[AssistanceDetailsExchange] = { http.GET(s"${url.host}${url.base}/assistance-details/$userId/$applicationId").map { response => response.json.as[AssistanceDetailsExchange] } recover { @@ -143,10 +144,8 @@ trait ApplicationClient { } } - def updateQuestionnaire(applicationId: UniqueIdentifier, sectionId: String, questionnaire: Questionnaire)( - implicit - hc: HeaderCarrier - ) = { + def updateQuestionnaire(applicationId: UniqueIdentifier, sectionId: String, questionnaire: Questionnaire) + (implicit hc: HeaderCarrier): Future[Unit] = { http.PUT( s"${url.host}${url.base}/questionnaire/$applicationId/$sectionId", questionnaire @@ -157,7 +156,7 @@ trait ApplicationClient { } } - def updateReview(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier) = { + def updateReview(applicationId: UniqueIdentifier)(implicit hc: HeaderCarrier): Future[Unit] = { http.PUT( s"${url.host}${url.base}/application/review/$applicationId", ReviewRequest(true) diff --git a/app/connectors/ExchangeObjects.scala b/app/connectors/ExchangeObjects.scala index 81eab3a..9c1749c 100644 --- a/app/connectors/ExchangeObjects.scala +++ b/app/connectors/ExchangeObjects.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,9 +63,7 @@ object ExchangeObjects { guaranteedInterview: Option[String], needsAdjustment: Option[String], typeOfAdjustments: Option[List[String]], - otherAdjustments: Option[String], - campaignReferrer: Option[String], - campaignOther: Option[String] + otherAdjustments: Option[String] ) case class AddMedia(userId: UniqueIdentifier, media: String) @@ -219,9 +217,7 @@ object ExchangeObjects { if (needsAssistance) { None } else data.guaranteedInterview, Some(data.needsAdjustment), if (data.needsAdjustment == "No") { None } else data.typeOfAdjustments, - adjustmentValid(data, data.otherAdjustments), - data.campaignReferrer, - data.campaignOther + adjustmentValid(data, data.otherAdjustments) ) } diff --git a/app/connectors/SchemeClient.scala b/app/connectors/SchemeClient.scala index e95b4c9..eae5b70 100644 --- a/app/connectors/SchemeClient.scala +++ b/app/connectors/SchemeClient.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/UserManagementClient.scala b/app/connectors/UserManagementClient.scala index d0378a4..49a49f2 100644 --- a/app/connectors/UserManagementClient.scala +++ b/app/connectors/UserManagementClient.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/addresslookup/AddressLookupClient.scala b/app/connectors/addresslookup/AddressLookupClient.scala index 83e29de..b748df0 100644 --- a/app/connectors/addresslookup/AddressLookupClient.scala +++ b/app/connectors/addresslookup/AddressLookupClient.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/addresslookup/AddressRecord.scala b/app/connectors/addresslookup/AddressRecord.scala index 755ef3c..c4888de 100644 --- a/app/connectors/addresslookup/AddressRecord.scala +++ b/app/connectors/addresslookup/AddressRecord.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/exchange/ProgressResponse.scala b/app/connectors/exchange/ProgressResponse.scala index 96a4ed4..bb87a13 100644 --- a/app/connectors/exchange/ProgressResponse.scala +++ b/app/connectors/exchange/ProgressResponse.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/package.scala b/app/connectors/package.scala index 9618638..313c8bb 100644 --- a/app/connectors/package.scala +++ b/app/connectors/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/ActivationController.scala b/app/controllers/ActivationController.scala index 32740f9..c57459f 100644 --- a/app/controllers/ActivationController.scala +++ b/app/controllers/ActivationController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala index f4965fb..ab6f23c 100644 --- a/app/controllers/Application.scala +++ b/app/controllers/Application.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/AssistanceController.scala b/app/controllers/AssistanceController.scala index 2bebda7..97aefbd 100644 --- a/app/controllers/AssistanceController.scala +++ b/app/controllers/AssistanceController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,9 +42,7 @@ trait AssistanceController extends BaseController with ApplicationClient { ad.guaranteedInterview, ad.needsAdjustment.getOrElse(""), ad.typeOfAdjustments, - ad.otherAdjustments, - ad.campaignReferrer, - ad.campaignOther + ad.otherAdjustments )) Ok(views.html.application.assistance(form)) }.recover { @@ -59,24 +57,16 @@ trait AssistanceController extends BaseController with ApplicationClient { invalidForm => Future.successful(Ok(views.html.application.assistance(invalidForm))), data => { - addMedia(user.user.userID, extractMediaReferrer(data)).flatMap { _ => - updateAssistanceDetails(user.application.applicationId, user.user.userID, data).flatMap { _ => - updateProgress()(_ => Redirect(routes.ReviewApplicationController.present())) - }.recover { - case e: AssistanceDetailsNotFound => - Redirect(routes.HomeController.present()).flashing(danger("account.error")) - } + updateAssistanceDetails(user.application.applicationId, user.user.userID, data).flatMap { _ => + updateProgress()(_ => Redirect(routes.ReviewApplicationController.present())) + }.recover { + case e: AssistanceDetailsNotFound => + Redirect(routes.HomeController.present()).flashing(danger("account.error")) } } ) } - private def extractMediaReferrer(data: AssistanceForm.Data): String = { - if (data.campaignReferrer.contains("Other") || data.campaignReferrer.contains("Careers fair")) { - data.campaignOther.getOrElse("") - } else { - data.campaignReferrer.getOrElse("") - } - } + } diff --git a/app/controllers/BaseController.scala b/app/controllers/BaseController.scala index 1ac80c1..36efa41 100644 --- a/app/controllers/BaseController.scala +++ b/app/controllers/BaseController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/FastTrackApplication.scala b/app/controllers/FastTrackApplication.scala index 48f2ff3..5021afb 100644 --- a/app/controllers/FastTrackApplication.scala +++ b/app/controllers/FastTrackApplication.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/HomeController.scala b/app/controllers/HomeController.scala index bbc0395..8eb7548 100644 --- a/app/controllers/HomeController.scala +++ b/app/controllers/HomeController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/LandingPageController.scala b/app/controllers/LandingPageController.scala index f223dae..46245b6 100644 --- a/app/controllers/LandingPageController.scala +++ b/app/controllers/LandingPageController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/LockAccountController.scala b/app/controllers/LockAccountController.scala index be8c4a5..a73c1d6 100644 --- a/app/controllers/LockAccountController.scala +++ b/app/controllers/LockAccountController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/OnlineTestController.scala b/app/controllers/OnlineTestController.scala index 5f5f2bb..5a7eee7 100644 --- a/app/controllers/OnlineTestController.scala +++ b/app/controllers/OnlineTestController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/PasswordResetController.scala b/app/controllers/PasswordResetController.scala index d3f5413..1c06226 100644 --- a/app/controllers/PasswordResetController.scala +++ b/app/controllers/PasswordResetController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/QuestionnaireController.scala b/app/controllers/QuestionnaireController.scala index 3de3b51..f714b43 100644 --- a/app/controllers/QuestionnaireController.scala +++ b/app/controllers/QuestionnaireController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/ReviewApplicationController.scala b/app/controllers/ReviewApplicationController.scala index 84c8fdb..0470c7a 100644 --- a/app/controllers/ReviewApplicationController.scala +++ b/app/controllers/ReviewApplicationController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/SchemeController.scala b/app/controllers/SchemeController.scala index 1e272d0..67e96d8 100644 --- a/app/controllers/SchemeController.scala +++ b/app/controllers/SchemeController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/SignInController.scala b/app/controllers/SignInController.scala index 8021b1e..fc4982b 100644 --- a/app/controllers/SignInController.scala +++ b/app/controllers/SignInController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/SignUpController.scala b/app/controllers/SignUpController.scala index d7bc561..95fcf6b 100644 --- a/app/controllers/SignUpController.scala +++ b/app/controllers/SignUpController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,13 +50,15 @@ trait SignUpController extends BaseController with SignInUtils with ApplicationC invalidForm => Future.successful(Ok(views.html.registration.signup(invalidForm))), data => { env.register(data.email.toLowerCase, data.password, data.firstName, data.lastName).flatMap { u => - signInUser( - u.toCached, - redirect = Redirect(routes.ActivationController.present()).flashing(success("account.successful")) - ).map { r => + addMedia(u.userId, extractMediaReferrer(data)).flatMap { _ => + signInUser( + u.toCached, + redirect = Redirect(routes.ActivationController.present()).flashing(success("account.successful")) + ).map { r => env.eventBus.publish(SignUpEvent(SecurityUser(u.userId.toString), request, request2lang)) r } + } }.recover { case e: EmailTakenException => Ok(views.html.registration.signup(SignUpForm.form.fill(data), Some(danger("user.exists")))) @@ -64,4 +66,12 @@ trait SignUpController extends BaseController with SignInUtils with ApplicationC } ) } + + private def extractMediaReferrer(data: SignUpForm.Data): String = { + if (data.campaignReferrer.contains("Other") || data.campaignReferrer.contains("Careers fair")) { + data.campaignOther.getOrElse("") + } else { + data.campaignReferrer.getOrElse("") + } + } } diff --git a/app/controllers/SubmitApplicationController.scala b/app/controllers/SubmitApplicationController.scala index 527e3c2..9ad81bc 100644 --- a/app/controllers/SubmitApplicationController.scala +++ b/app/controllers/SubmitApplicationController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/test/AddressLookupController.scala b/app/controllers/test/AddressLookupController.scala index 4607aa0..4f32d17 100644 --- a/app/controllers/test/AddressLookupController.scala +++ b/app/controllers/test/AddressLookupController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/filters/CookiePolicyFilter.scala b/app/filters/CookiePolicyFilter.scala index 13d0334..edec3dd 100644 --- a/app/filters/CookiePolicyFilter.scala +++ b/app/filters/CookiePolicyFilter.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/ActivateAccountform.scala b/app/forms/ActivateAccountform.scala index 28ea999..ae6f781 100644 --- a/app/forms/ActivateAccountform.scala +++ b/app/forms/ActivateAccountform.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/AlternateLocationsForm.scala b/app/forms/AlternateLocationsForm.scala index ccc2c85..f60df59 100644 --- a/app/forms/AlternateLocationsForm.scala +++ b/app/forms/AlternateLocationsForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/AssistanceForm.scala b/app/forms/AssistanceForm.scala index e0bb6da..21d5a6f 100644 --- a/app/forms/AssistanceForm.scala +++ b/app/forms/AssistanceForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,9 +98,7 @@ object AssistanceForm { "guaranteedInterview" -> of(requiredFormatter("needsAssistance", "guaranteedInterview")), "needsAdjustment" -> Mappings.nonEmptyTrimmedText("needsAdjustment.chooseone", 3), "typeOfAdjustments" -> of(requiredListFormatter("needsAdjustment", "typeOfAdjustments")), - "otherAdjustments" -> optional(Mappings.nonEmptyTrimmedText("otherAdjustments.chooseone", 4000)), - "campaignReferrer" -> Mappings.optionalTrimmedText(64), - "campaignOther" -> Mappings.optionalTrimmedText(256) + "otherAdjustments" -> optional(Mappings.nonEmptyTrimmedText("otherAdjustments.chooseone", 4000)) )(Data.apply)(Data.unapply) ) @@ -111,9 +109,7 @@ object AssistanceForm { guaranteedInterview: Option[String], needsAdjustment: String, typeOfAdjustments: Option[List[String]], - otherAdjustments: Option[String], - campaignReferrer: Option[String], - campaignOther: Option[String] + otherAdjustments: Option[String] ) } diff --git a/app/forms/GeneralDetailsForm.scala b/app/forms/GeneralDetailsForm.scala index 27508c8..4d5f0c2 100644 --- a/app/forms/GeneralDetailsForm.scala +++ b/app/forms/GeneralDetailsForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/LockAccountForm.scala b/app/forms/LockAccountForm.scala index 446d281..a83122c 100644 --- a/app/forms/LockAccountForm.scala +++ b/app/forms/LockAccountForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/Mappings.scala b/app/forms/Mappings.scala index bb3ca70..8a36259 100644 --- a/app/forms/Mappings.scala +++ b/app/forms/Mappings.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/QuestionnaireDiversityInfoForm.scala b/app/forms/QuestionnaireDiversityInfoForm.scala index 9ac0230..a89bb3a 100644 --- a/app/forms/QuestionnaireDiversityInfoForm.scala +++ b/app/forms/QuestionnaireDiversityInfoForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/QuestionnaireEducationInfoForm.scala b/app/forms/QuestionnaireEducationInfoForm.scala index 065f9d7..8e5d737 100644 --- a/app/forms/QuestionnaireEducationInfoForm.scala +++ b/app/forms/QuestionnaireEducationInfoForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/QuestionnaireOccupationInfoForm.scala b/app/forms/QuestionnaireOccupationInfoForm.scala index f94e50a..fbc8b7f 100644 --- a/app/forms/QuestionnaireOccupationInfoForm.scala +++ b/app/forms/QuestionnaireOccupationInfoForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/RequestResetPasswordForm.scala b/app/forms/RequestResetPasswordForm.scala index 0c3102d..d79341a 100644 --- a/app/forms/RequestResetPasswordForm.scala +++ b/app/forms/RequestResetPasswordForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/ResetPasswordForm.scala b/app/forms/ResetPasswordForm.scala index 5aa2529..8e7fd67 100644 --- a/app/forms/ResetPasswordForm.scala +++ b/app/forms/ResetPasswordForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/SchemeLocationPreferenceForm.scala b/app/forms/SchemeLocationPreferenceForm.scala index 94c3b00..80a2437 100644 --- a/app/forms/SchemeLocationPreferenceForm.scala +++ b/app/forms/SchemeLocationPreferenceForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/SignInForm.scala b/app/forms/SignInForm.scala index 3b64b75..b1a0346 100644 --- a/app/forms/SignInForm.scala +++ b/app/forms/SignInForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/SignUpForm.scala b/app/forms/SignUpForm.scala index 0004e97..7fd1d97 100644 --- a/app/forms/SignUpForm.scala +++ b/app/forms/SignUpForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,9 @@ object SignUpForm { passwordField -> of(passwordFormatter), confirmPasswordField -> nonEmptyTrimmedText("error.confirmpwd", passwordMaxLength), "agree" -> checked(Messages("agree.accept")), - "agreeEligibleToApply" -> checked(Messages("agree.eligible")) + "agreeEligibleToApply" -> checked(Messages("agree.eligible")), + "campaignReferrer" -> optionalTrimmedText(64), + "campaignOther" -> optionalTrimmedText(256) )(Data.apply)(Data.unapply) ) @@ -94,6 +96,8 @@ object SignUpForm { password: String, confirmpwd: String, agree: Boolean, - agreeEligibleToApply: Boolean + agreeEligibleToApply: Boolean, + campaignReferrer: Option[String], + campaignOther: Option[String] ) } diff --git a/app/forms/WithdrawApplicationForm.scala b/app/forms/WithdrawApplicationForm.scala index d9a7670..0206dc5 100644 --- a/app/forms/WithdrawApplicationForm.scala +++ b/app/forms/WithdrawApplicationForm.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/forms/package.scala b/app/forms/package.scala index 0aa15cf..23ac895 100644 --- a/app/forms/package.scala +++ b/app/forms/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/helpers/CSRFieldConstructor.scala b/app/helpers/CSRFieldConstructor.scala index 195a0e0..a6ba9f1 100644 --- a/app/helpers/CSRFieldConstructor.scala +++ b/app/helpers/CSRFieldConstructor.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/helpers/NotificationType.scala b/app/helpers/NotificationType.scala index c53dd08..f534e07 100644 --- a/app/helpers/NotificationType.scala +++ b/app/helpers/NotificationType.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/mappings/Address.scala b/app/mappings/Address.scala index f2a8888..26ae03d 100644 --- a/app/mappings/Address.scala +++ b/app/mappings/Address.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/mappings/DayMonthYear.scala b/app/mappings/DayMonthYear.scala index 5106a60..0e92618 100644 --- a/app/mappings/DayMonthYear.scala +++ b/app/mappings/DayMonthYear.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/mappings/PhoneNumberMapping.scala b/app/mappings/PhoneNumberMapping.scala index 98ba355..47c764e 100644 --- a/app/mappings/PhoneNumberMapping.scala +++ b/app/mappings/PhoneNumberMapping.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/mappings/PostCodeMapping.scala b/app/mappings/PostCodeMapping.scala index 56e6c39..edb950b 100644 --- a/app/mappings/PostCodeMapping.scala +++ b/app/mappings/PostCodeMapping.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/AdjustmentTypes.scala b/app/models/AdjustmentTypes.scala index 2950bd4..7899414 100644 --- a/app/models/AdjustmentTypes.scala +++ b/app/models/AdjustmentTypes.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/ApplicationData.scala b/app/models/ApplicationData.scala index 68690e0..99d8594 100644 --- a/app/models/ApplicationData.scala +++ b/app/models/ApplicationData.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/AssistanceTypes.scala b/app/models/AssistanceTypes.scala index 3b261a8..31501d1 100644 --- a/app/models/AssistanceTypes.scala +++ b/app/models/AssistanceTypes.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/CampaignReferrers.scala b/app/models/CampaignReferrers.scala index 2226a9f..c39e49f 100644 --- a/app/models/CampaignReferrers.scala +++ b/app/models/CampaignReferrers.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/CookiePolicy.scala b/app/models/CookiePolicy.scala index a3464ed..97a0ba9 100644 --- a/app/models/CookiePolicy.scala +++ b/app/models/CookiePolicy.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Employee.scala b/app/models/Employee.scala index 3b0ae34..2392f2b 100644 --- a/app/models/Employee.scala +++ b/app/models/Employee.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Ethnicity.scala b/app/models/Ethnicity.scala index fa483ed..85697c3 100644 --- a/app/models/Ethnicity.scala +++ b/app/models/Ethnicity.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Gender.scala b/app/models/Gender.scala index 3b49b0f..31dbd38 100644 --- a/app/models/Gender.scala +++ b/app/models/Gender.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Nationalities.scala b/app/models/Nationalities.scala index 8f83d56..86caf87 100644 --- a/app/models/Nationalities.scala +++ b/app/models/Nationalities.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Occupations.scala b/app/models/Occupations.scala index bffa3a3..abedae7 100644 --- a/app/models/Occupations.scala +++ b/app/models/Occupations.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/OrganizationSize.scala b/app/models/OrganizationSize.scala index d73ebb7..545223b 100644 --- a/app/models/OrganizationSize.scala +++ b/app/models/OrganizationSize.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Progress.scala b/app/models/Progress.scala index ac223ed..1e25ec9 100644 --- a/app/models/Progress.scala +++ b/app/models/Progress.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/SecurityUser.scala b/app/models/SecurityUser.scala index c23fd86..583f214 100644 --- a/app/models/SecurityUser.scala +++ b/app/models/SecurityUser.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/SexOrientation.scala b/app/models/SexOrientation.scala index ff11c74..a58d781 100644 --- a/app/models/SexOrientation.scala +++ b/app/models/SexOrientation.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/Supervise.scala b/app/models/Supervise.scala index c8b9616..20d00d8 100644 --- a/app/models/Supervise.scala +++ b/app/models/Supervise.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/UniqueIdentifier.scala b/app/models/UniqueIdentifier.scala index 987ee6c..da2efbd 100644 --- a/app/models/UniqueIdentifier.scala +++ b/app/models/UniqueIdentifier.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/WithdrawReasons.scala b/app/models/WithdrawReasons.scala index 6084a6c..6a08d83 100644 --- a/app/models/WithdrawReasons.scala +++ b/app/models/WithdrawReasons.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/frameworks/Location.scala b/app/models/frameworks/Location.scala index 8c07820..299e42d 100644 --- a/app/models/frameworks/Location.scala +++ b/app/models/frameworks/Location.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/frameworks/LocationAndSchemeSelection.scala b/app/models/frameworks/LocationAndSchemeSelection.scala index ad9ad53..4dd23d0 100644 --- a/app/models/frameworks/LocationAndSchemeSelection.scala +++ b/app/models/frameworks/LocationAndSchemeSelection.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/frameworks/Region.scala b/app/models/frameworks/Region.scala index 48cb05e..fc66c4f 100644 --- a/app/models/frameworks/Region.scala +++ b/app/models/frameworks/Region.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/page/DashboardPage.scala b/app/models/page/DashboardPage.scala index 6bbcdf2..f46e6fb 100644 --- a/app/models/page/DashboardPage.scala +++ b/app/models/page/DashboardPage.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/services/UserCacheService.scala b/app/models/services/UserCacheService.scala index 94ed2cf..10d4933 100644 --- a/app/models/services/UserCacheService.scala +++ b/app/models/services/UserCacheService.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/models/services/UserService.scala b/app/models/services/UserService.scala index a765d88..ffc808f 100644 --- a/app/models/services/UserService.scala +++ b/app/models/services/UserService.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/security/CsrCredentialsProvider.scala b/app/security/CsrCredentialsProvider.scala index ae6991f..5006228 100644 --- a/app/security/CsrCredentialsProvider.scala +++ b/app/security/CsrCredentialsProvider.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/security/Roles.scala b/app/security/Roles.scala index d63d8cf..1c47a07 100644 --- a/app/security/Roles.scala +++ b/app/security/Roles.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/security/SecureActions.scala b/app/security/SecureActions.scala index 30f3984..171d8bb 100644 --- a/app/security/SecureActions.scala +++ b/app/security/SecureActions.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/security/SecurityEnvironment.scala b/app/security/SecurityEnvironment.scala index 313c870..c3a9fe2 100644 --- a/app/security/SecurityEnvironment.scala +++ b/app/security/SecurityEnvironment.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/security/SignInUtils.scala b/app/security/SignInUtils.scala index ec48ba7..90c67e0 100644 --- a/app/security/SignInUtils.scala +++ b/app/security/SignInUtils.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016 HM Revenue & Customs + * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/views/application/assistance.scala.html b/app/views/application/assistance.scala.html index 4ab1c38..dd1191d 100644 --- a/app/views/application/assistance.scala.html +++ b/app/views/application/assistance.scala.html @@ -80,24 +80,6 @@

Guaranteed interview scheme

} -
-

How did you hear about us?

-
- @select_guard(assistanceForm("campaignReferrer"), models.CampaignReferrers.list, - "hearAboutUsDetail", "-- Select one --") { - Select how you heard about us (optional) - } -
- -
- @helper.inputText(assistanceForm("campaignOther"), - '_label -> "Provide more information (optional)", - 'class -> "form-control", - '_showConstraints -> false) -
-
- -
diff --git a/app/views/registration/signup.scala.html b/app/views/registration/signup.scala.html index 4a7049a..001676e 100644 --- a/app/views/registration/signup.scala.html +++ b/app/views/registration/signup.scala.html @@ -2,7 +2,7 @@ implicit request: Request[_], flash: Flash, user: Option[CachedData], feedbackUrl: String, fasttrackConfig: FasttrackConfig) @import helpers.CSRFieldConstructor._ -@import views.html.widgets.checkbox +@import views.html.widgets.{ checkbox, select_guard } @main_template(title = "Create your account", pageForms = Seq(signUpForm), notification = notification) {

Create your account

@@ -77,6 +77,22 @@

Confirm the following statements are true:

+
+

How did you hear about us?

+
+ @select_guard(signUpForm("campaignReferrer"), models.CampaignReferrers.list, + "hearAboutUsDetail", "-- Select one --") { + Select how you heard about us (optional) + } +
+
+ @helper.inputText(signUpForm("campaignOther"), + '_label -> "Provide more information (optional)", + 'class -> "form-control", + '_showConstraints -> false) +
+
+

Terms and conditions

@checkbox(signUpForm("agree")) { diff --git a/conf/application.conf b/conf/application.conf index e22707c..1c31c83 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -1,4 +1,4 @@ -# Copyright 2016 HM Revenue & Customs +# Copyright 2017 HM Revenue & Customs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -112,4 +112,4 @@ microservice { url = "http://localhost:9022" } } -} \ No newline at end of file +} diff --git a/conf/silhouette.conf b/conf/silhouette.conf index d5dd33a..4ad8d00 100644 --- a/conf/silhouette.conf +++ b/conf/silhouette.conf @@ -1,4 +1,4 @@ -# Copyright 2016 HM Revenue & Customs +# Copyright 2017 HM Revenue & Customs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 23d2bc6c9f1473213a79d4ddbe86bf71b5b84683 Mon Sep 17 00:00:00 2001 From: Ben Stephenson Date: Wed, 4 Jan 2017 09:40:42 +0000 Subject: [PATCH 2/2] Fix test --- test/controllers/forms/AssistanceFormSpec.scala | 8 ++++---- test/controllers/forms/SignUpFormSpec.scala | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/test/controllers/forms/AssistanceFormSpec.scala b/test/controllers/forms/AssistanceFormSpec.scala index d938389..92077c7 100644 --- a/test/controllers/forms/AssistanceFormSpec.scala +++ b/test/controllers/forms/AssistanceFormSpec.scala @@ -51,19 +51,19 @@ class AssistanceFormSpec extends BaseSpec { trait Fixture { val noDisabilities = { - val data = Data("No", Some(List("")), None, Some("No"), "No", None, None, None, None) + val data = Data("No", Some(List("")), None, Some("No"), "No", None, None) (data, AssistanceForm.form.fill(data)) } val noAdjustments = { - val data = Data("Yes", Some(List("One of the disabilities")), None, None, "No", None, None, None, None) + val data = Data("Yes", Some(List("One of the disabilities")), None, None, "No", None, None) (data, AssistanceForm.form.fill(data)) } val fullForm: (Data, Form[Data]) = { - val data = Data("Yes", Some(List("One of the disabilities")), Some("some details"), None, "Yes", Some(List("other")), None, None, None) + val data = Data("Yes", Some(List("One of the disabilities")), Some("some details"), None, "Yes", Some(List("other")), None) (data, AssistanceForm.form.fill(data)) } @@ -79,7 +79,7 @@ class AssistanceFormSpec extends BaseSpec { ) = { val data = Data(needsAssistance, typeOfdisability, detailsOfdisability, guaranteedInterview, needsAdjustment, - typeOfAdjustments, otherAdjustments, None, None) + typeOfAdjustments, otherAdjustments) (data, AssistanceForm.form.fill(data)) } diff --git a/test/controllers/forms/SignUpFormSpec.scala b/test/controllers/forms/SignUpFormSpec.scala index 5d5166e..85b3c17 100644 --- a/test/controllers/forms/SignUpFormSpec.scala +++ b/test/controllers/forms/SignUpFormSpec.scala @@ -72,14 +72,14 @@ class SignUpFormSpec extends BaseSpec { signUpForm.errors("password").head.messages must be(Seq(Messages("error.password"))) } - "throw an error if I haven't click on the I am eligible" in { + "throw an error if I haven't clicked on the I am eligible" in { val (_, signUpForm) = SignupFormGenerator(agreeEligibleToApply = false).get signUpForm.hasErrors must be(true) signUpForm.errors.length must be(1) signUpForm.errors("agreeEligibleToApply").head.messages must be(Seq(Messages("agree.eligible"))) } - "throw an error if I haven't click on the I agree" in { + "throw an error if I haven't clicked on the I agree" in { val (_, signUpForm) = SignupFormGenerator(agree = false).get signUpForm.hasErrors must be(true) signUpForm.errors.length must be(1) @@ -105,10 +105,14 @@ case class SignupFormGenerator( password: String = "aA1234567", confirm: String = "aA1234567", agree: Boolean = true, - agreeEligibleToApply: Boolean = true + agreeEligibleToApply: Boolean = true, + campaignReferrer: Option[String] = Some("Google"), + campaignOther: Option[String] = Some("More Google") ) { - private val data = Data(firstName, lastName, email, confirmEmail, password, confirm, agree, agreeEligibleToApply) + private val data = Data(firstName, lastName, email, confirmEmail, password, confirm, agree, agreeEligibleToApply, + campaignReferrer, campaignOther + ) private val validFormData = Map( "firstName" -> data.firstName, @@ -118,7 +122,10 @@ case class SignupFormGenerator( "password" -> data.password, "confirmpwd" -> data.confirmpwd, "agree" -> data.agree.toString, - "agreeEligibleToApply" -> data.agreeEligibleToApply.toString + "agreeEligibleToApply" -> data.agreeEligibleToApply.toString, + "campaignReferrer" -> data.campaignReferrer.getOrElse(""), + "campaignOther" -> data.campaignOther.getOrElse("") + ) private def signUpForm = Form(SignUpForm.form.mapping).bind(validFormData)