From 565937a31c88338e2b01f817caa501e368b69bc3 Mon Sep 17 00:00:00 2001 From: Dominik Lander Date: Thu, 6 Apr 2023 16:39:56 +0100 Subject: [PATCH] Use tone for Inline Merchandise --- admin/app/dfp/DfpDataExtractor.scala | 1 + admin/app/tools/DfpLink.scala | 2 ++ .../inlineMerchandisingTargetedTags.scala.html | 9 +++++++++ common/app/common/dfp/DfpData.scala | 4 ++++ common/app/common/dfp/TagSponsorship.scala | 6 +++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/admin/app/dfp/DfpDataExtractor.scala b/admin/app/dfp/DfpDataExtractor.scala index 5e782b083d8a..201155493201 100644 --- a/admin/app/dfp/DfpDataExtractor.scala +++ b/admin/app/dfp/DfpDataExtractor.scala @@ -30,6 +30,7 @@ case class DfpDataExtractor(lineItems: Seq[GuLineItem], invalidLineItems: Seq[Gu series = soFar.series ++ lineItem.inlineMerchandisingTargetedSeries, contributors = soFar.contributors ++ lineItem.inlineMerchandisingTargetedContributors, sections = soFar.sections ++ lineItem.inlineMerchandisingTargetedSections, + tones = soFar.tones ++ lineItem.inlineMerchandisingTargetedTones, ) } } diff --git a/admin/app/tools/DfpLink.scala b/admin/app/tools/DfpLink.scala index f7f4e680d14a..1e9a615dba9a 100644 --- a/admin/app/tools/DfpLink.scala +++ b/admin/app/tools/DfpLink.scala @@ -39,4 +39,6 @@ object CapiLink { def seriesPage(series: String): String = tagPage("series", series) def sectionPage(section: String): String = tagPage("section", section) + + def tonePage(tone: String): String = tagPage("tone", tone) } diff --git a/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html b/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html index 2d7eb75a8812..f17bff705701 100644 --- a/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html +++ b/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html @@ -20,6 +20,7 @@

Inline Merchandising Slot

  • series: se
  • contributor: co
  • section: s
  • +
  • tone: tn
  • @@ -86,4 +87,12 @@

    Targeted Sections

    } +

    Targeted Tones

    + @if(report.targetedTags.tones.isEmpty) {

    None

    } else { +
      + @for(tone <- report.targetedTags.tones) { +
    1. @tone
    2. + } +
    + } } diff --git a/common/app/common/dfp/DfpData.scala b/common/app/common/dfp/DfpData.scala index 765dabd9e226..91135bc49950 100644 --- a/common/app/common/dfp/DfpData.scala +++ b/common/app/common/dfp/DfpData.scala @@ -87,6 +87,7 @@ case class CustomTarget(name: String, op: String, values: Seq[String]) { val isContributorTag = isPositive("co") val isEditionTag = isPositive("edition") val isSectionTag = isPositive("s") + val isToneTag = isPositive("tn") } object CustomTarget { @@ -107,6 +108,7 @@ case class CustomTargetSet(op: String, targets: Seq[CustomTarget]) { val inlineMerchandisingTargetedSeries = filterTags(tag => tag.isSeriesTag)(_.isInlineMerchandisingSlot) val inlineMerchandisingTargetedContributors = filterTags(tag => tag.isContributorTag)(_.isInlineMerchandisingSlot) val inlineMerchandisingTargetedSections = filterTags(tag => tag.isSectionTag)(_.isInlineMerchandisingSlot) + val inlineMerchandisingTargetedTones = filterTags(tag => tag.isToneTag)(_.isInlineMerchandisingSlot) val highMerchandisingTargets = filterTags(tag => tag.isKeywordTag || tag.isSeriesTag || tag.isContributorTag)(_.isHighMerchandisingSlot) @@ -253,6 +255,8 @@ case class GuLineItem( targeting.customTargetSets.flatMap(_.inlineMerchandisingTargetedContributors).distinct val inlineMerchandisingTargetedSections: Seq[String] = targeting.customTargetSets.flatMap(_.inlineMerchandisingTargetedSections).distinct + val inlineMerchandisingTargetedTones: Seq[String] = + targeting.customTargetSets.flatMap(_.inlineMerchandisingTargetedTones).distinct val highMerchandisingTargets: Seq[String] = targeting.customTargetSets.flatMap(_.highMerchandisingTargets).distinct diff --git a/common/app/common/dfp/TagSponsorship.scala b/common/app/common/dfp/TagSponsorship.scala index ec13f08c6b90..cff947e03f29 100644 --- a/common/app/common/dfp/TagSponsorship.scala +++ b/common/app/common/dfp/TagSponsorship.scala @@ -14,6 +14,7 @@ object InlineMerchandisingTagSet { "series" -> tagSet.series, "contributors" -> tagSet.contributors, "sections" -> tagSet.sections, + "tones" -> tagSet.tones, ) } @@ -24,6 +25,7 @@ case class InlineMerchandisingTagSet( series: Set[String] = Set.empty, contributors: Set[String] = Set.empty, sections: Set[String] = Set.empty, + tones: Set[String] = Set.empty, ) { private def hasTagId(tags: Set[String], tagId: String): Boolean = @@ -37,10 +39,12 @@ case class InlineMerchandisingTagSet( case "Series" => hasTagId(series, tag.id) case "Contributor" => hasTagId(contributors, tag.id) case "Section" => hasTagId(sections, tag.id) + case "Tone" => hasTagId(tones, tag.id) case _ => false } - def nonEmpty: Boolean = keywords.nonEmpty || series.nonEmpty || contributors.nonEmpty || sections.nonEmpty + def nonEmpty: Boolean = + keywords.nonEmpty || series.nonEmpty || contributors.nonEmpty || sections.nonEmpty || tones.nonEmpty } object InlineMerchandisingLineItem {