Skip to content

Commit

Permalink
Update draft to accept summary
Browse files Browse the repository at this point in the history
  • Loading branch information
ekrojo77 committed Oct 23, 2024
1 parent 30c5746 commit 7546a29
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ case class Draft(
comments: Seq[Comment],
priority: Priority,
started: Boolean,
qualityEvaluation: Option[QualityEvaluation]
qualityEvaluation: Option[QualityEvaluation],
summary: Seq[ArticleIntroSummary]
) extends Content {

def supportedLanguages: Seq[String] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.circe.{Decoder, Encoder}
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
import no.ndla.common.model.NDLADate
import no.ndla.common.model.api.{DraftCopyright, RelatedContentLink}
import no.ndla.common.model.domain.ArticleIntroSummary
import sttp.tapir.Schema.annotations.description

// format: off
Expand Down Expand Up @@ -42,6 +43,7 @@ case class NewArticle(
@description("If the article should be prioritized") prioritized: Option[Boolean],
@description("If the article should be prioritized. Possible values are prioritized, on-hold, unspecified") priority: Option[String],
@description("The quality evaluation of the article. Consist of a score from 1 to 5 and a comment.") qualityEvaluation : Option[QualityEvaluation],
@description("The summary of the article") summary: Seq[ArticleIntroSummary]
)
// format: on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
package no.ndla.draftapi.model.api

import com.scalatsi.TypescriptType.{TSNull, TSUndefined, TSUnion}
import no.ndla.common.implicits._
import no.ndla.common.implicits.*
import io.circe.{Decoder, Encoder}
import io.circe.generic.semiauto._
import io.circe.generic.semiauto.*
import no.ndla.common.model.NDLADate
import no.ndla.common.model.api.{DraftCopyright, RelatedContent, RelatedContentLink, UpdateOrDelete}
import sttp.tapir.Schema.annotations.description
import com.scalatsi._
import com.scalatsi.*
import no.ndla.common.model.domain.ArticleIntroSummary

// format: off
@description("Information about the article")
Expand Down Expand Up @@ -47,6 +48,7 @@ case class UpdatedArticle(
@description("If the article should be prioritized") prioritized: Option[Boolean],
@description("If the article should be prioritized. Possible values are prioritized, on-hold, unspecified") priority: Option[String],
@description("The quality evaluation of the article. Consist of a score from 1 to 5 and a comment.") qualityEvaluation : Option[QualityEvaluation],
@description("The summary of the article") summary: Option[Seq[ArticleIntroSummary]]

)
// format: on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import no.ndla.common.configuration.Constants.EmbedTagName
import no.ndla.common.errors.{ValidationException, ValidationMessage}
import no.ndla.common.implicits.TryQuestionMark
import no.ndla.common.model.api.{Delete, DraftCopyright, Missing, UpdateWith, draft}
import no.ndla.common.model.domain.{ArticleContent, Priority, Responsible}
import no.ndla.common.model.domain.{ArticleContent, ArticleIntroSummary, Priority, Responsible}
import no.ndla.common.model.domain.draft.DraftStatus.{IMPORTED, PLANNED}
import no.ndla.common.model.domain.draft.{Comment, Draft, DraftStatus}
import no.ndla.common.model.{NDLADate, RelatedContentLink, api as commonApi, domain as common}
Expand Down Expand Up @@ -124,7 +124,8 @@ trait ConverterService {
comments = newCommentToDomain(newArticle.comments.getOrElse(List.empty)),
priority = priority,
started = false,
qualityEvaluation = qualityEvaluationToDomain(newArticle.qualityEvaluation)
qualityEvaluation = qualityEvaluationToDomain(newArticle.qualityEvaluation),
summary = newArticle.summary
)
)
}
Expand Down Expand Up @@ -620,7 +621,8 @@ trait ConverterService {
availability = draft.availability,
relatedContent = draft.relatedContent,
revisionDate = getNextRevision(draft.revisionMeta).map(_.revisionDate),
slug = draft.slug
slug = draft.slug,
summary = draft.summary
)
)
}
Expand Down Expand Up @@ -843,7 +845,8 @@ trait ConverterService {
comments = updatedComments,
priority = priority,
started = toMergeInto.started,
qualityEvaluation = qualityEvaluationToDomain(article.qualityEvaluation)
qualityEvaluation = qualityEvaluationToDomain(article.qualityEvaluation),
summary = article.summary.getOrElse(toMergeInto.summary)
)

Success(converted)
Expand Down Expand Up @@ -931,7 +934,8 @@ trait ConverterService {
comments = comments,
priority = priority,
started = false,
qualityEvaluation = qualityEvaluationToDomain(article.qualityEvaluation)
qualityEvaluation = qualityEvaluationToDomain(article.qualityEvaluation),
summary = article.summary.getOrElse(Seq.empty)
)
}

Expand Down

0 comments on commit 7546a29

Please sign in to comment.