Skip to content

Commit

Permalink
review: routing changed to include testUser
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-daniel-dempsey committed Feb 4, 2025
1 parent 870fd43 commit 2353b7c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
47 changes: 25 additions & 22 deletions support-frontend/app/controllers/SubscriptionsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import config.StringsConfig
import lib.RedirectWithEncodedQueryString
import play.api.mvc._
import play.twirl.api.Html
import services.CachedProductCatalogServiceProvider
import services.{CachedProductCatalogServiceProvider, TestUserService}
import services.pricing.{PriceSummary, PriceSummaryServiceProvider}
import views.EmptyDiv
import views.ViewHelpers.outputJson
Expand All @@ -30,6 +30,7 @@ class SubscriptionsController(
settingsProvider: AllSettingsProvider,
val supportUrl: String,
stage: Stage,
testUserService: TestUserService,
cachedProductCatalogServiceProvider: CachedProductCatalogServiceProvider,
)(implicit val ec: ExecutionContext)
extends AbstractController(components)
Expand Down Expand Up @@ -93,29 +94,31 @@ class SubscriptionsController(
) ++ paperMap
}

def landing(countryCode: String): Action[AnyContent] = CachedAction() { implicit request =>
implicit val settings: AllSettings = settingsProvider.getAllSettings()
val title = "Support the Guardian | Get a Subscription"
val mainElement = EmptyDiv("subscriptions-landing-page")
val js = "subscriptionsLandingPage.js"
val pricingCopy = CountryGroup.byId(countryCode).map(getLandingPrices)
val productCatalog = cachedProductCatalogServiceProvider.fromStage(stage, false).get()

Ok(
views.html.main(
title,
mainElement,
RefPath(js),
Some(RefPath("subscriptionsLandingPage.css")),
description = stringsConfig.subscriptionsLandingDescription,
noindex = stage != PROD,
) {
Html(s"""<script type="text/javascript">
def landing(countryCode: String): Action[AnyContent] = {
MaybeAuthenticatedAction { implicit request =>
implicit val settings: AllSettings = settingsProvider.getAllSettings()
val title = "Support the Guardian | Get a Subscription"
val mainElement = EmptyDiv("subscriptions-landing-page")
val js = "subscriptionsLandingPage.js"
val pricingCopy = CountryGroup.byId(countryCode).map(getLandingPrices)
val isTestUser = testUserService.isTestUser(request)
val productCatalog = cachedProductCatalogServiceProvider.fromStage(stage, isTestUser).get()

Ok(
views.html.main(
title,
mainElement,
RefPath(js),
Some(RefPath("subscriptionsLandingPage.css")),
description = stringsConfig.subscriptionsLandingDescription,
noindex = stage != PROD,
) {
Html(s"""<script type="text/javascript">
window.guardian.pricingCopy = ${outputJson(pricingCopy)};
window.guardian.productCatalog = ${outputJson(productCatalog)}
</script>""")
},
).withSettingsSurrogateKey
},
).withSettingsSurrogateKey
}
}

}
1 change: 1 addition & 0 deletions support-frontend/app/wiring/Controllers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ trait Controllers {
allSettingsProvider,
appConfig.supportUrl,
appConfig.stage,
testUsers,
cachedProductCatalogServiceProvider,
)

Expand Down

0 comments on commit 2353b7c

Please sign in to comment.