@@ -31,6 +31,7 @@ import navigation._
31
31
import play .api .libs .json ._
32
32
import play .api .mvc .RequestHeader
33
33
import services .NewsletterData
34
+ import views .html .fragments .affiliateLinksDisclaimer
34
35
import views .support .{CamelCase , ContentLayout , JavaScriptPage }
35
36
// -----------------------------------------------------------------
36
37
// DCR DataModel
@@ -41,6 +42,7 @@ case class DotcomRenderingDataModel(
41
42
headline : String ,
42
43
standfirst : String ,
43
44
webTitle : String ,
45
+ affiliateLinksDisclaimer : Option [String ],
44
46
mainMediaElements : List [PageElement ],
45
47
main : String ,
46
48
availableTopics : Option [Seq [Topic ]],
@@ -122,6 +124,7 @@ object DotcomRenderingDataModel {
122
124
" headline" -> model.headline,
123
125
" standfirst" -> model.standfirst,
124
126
" webTitle" -> model.webTitle,
127
+ " affiliateLinksDisclaimer" -> model.affiliateLinksDisclaimer,
125
128
" mainMediaElements" -> model.mainMediaElements,
126
129
" main" -> model.main,
127
130
" filterKeyEvents" -> model.filterKeyEvents,
@@ -452,7 +455,14 @@ object DotcomRenderingDataModel {
452
455
twitterHandle = content.tags.contributors.headOption.flatMap(_.properties.twitterHandle),
453
456
)
454
457
458
+ def hasAffiliateLinks (
459
+ blocks : Seq [APIBlock ],
460
+ ): Boolean = {
461
+ blocks.exists(block => DotcomRenderingUtils .stringContainsAffiliateableLinks(block.bodyHtml))
462
+ }
463
+
455
464
val shouldAddAffiliateLinks = DotcomRenderingUtils .shouldAddAffiliateLinks(content)
465
+ val shouldAddDisclaimer = hasAffiliateLinks(bodyBlocks)
456
466
457
467
val contentDateTimes : ArticleDateTimes = ArticleDateTimes (
458
468
webPublicationDate = content.trail.webPublicationDate,
@@ -545,7 +555,16 @@ object DotcomRenderingDataModel {
545
555
546
556
val selectedTopics = topicResult.map(topic => Seq (Topic (topic.`type`, topic.name)))
547
557
558
+ def getAffiliateLinksDisclaimer (shouldAddAffiliateLinks : Boolean , shouldAddDisclaimer : Boolean ) = {
559
+ if (shouldAddAffiliateLinks && shouldAddDisclaimer) {
560
+ Some (affiliateLinksDisclaimer(" article" ).body)
561
+ } else {
562
+ None
563
+ }
564
+ }
565
+
548
566
DotcomRenderingDataModel (
567
+ affiliateLinksDisclaimer = getAffiliateLinksDisclaimer(shouldAddAffiliateLinks, shouldAddDisclaimer),
549
568
author = author,
550
569
badge = Badges .badgeFor(content).map(badge => DCRBadge (badge.seriesTag, badge.imageUrl)),
551
570
beaconURL = Configuration .debug.beaconUrl,
0 commit comments