Skip to content

Commit

Permalink
arenaAccept to arenaAccepted and add to user object
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarvelle committed Jan 22, 2025
1 parent d9ff8f0 commit 5a16ef9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common/src/main/scala/no/ndla/common/model/NDLADate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package no.ndla.common.model

import com.scalatsi.TSType
import io.circe.{Decoder, Encoder, FailedCursor}
import io.circe.syntax._
import io.circe.syntax.*
import scalikejdbc.ParameterBinderFactory
import sttp.tapir.Schema

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ case class MyNDLAUserDTO(
@description("User root organization") organization: String,
@description("User groups") groups: Seq[MyNDLAGroupDTO],
@description("Whether arena is explicitly enabled for the user") arenaEnabled: Boolean,
@description("Whether the user has accepted the use of arena") arenaAccepted: Boolean,
@description("Whether users name is shared with folders or not") shareName: Boolean,
@description("Arena user groups") arenaGroups: List[ArenaGroup]
)
Expand All @@ -54,7 +55,7 @@ case class UpdatedMyNDLAUserDTO(
@description("Which arena groups the user should be in, only modifiable by admins")
arenaGroups: Option[List[ArenaGroup]],
@description("Whether the user has accepted the use of arena")
arenaAccept: Option[Boolean]
arenaAccepted: Option[Boolean]
)

object UpdatedMyNDLAUserDTO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ trait FolderConverterService {
organization = domainUserData.organization,
groups = domainUserData.groups.map(toApiGroup),
arenaEnabled = arenaEnabled,
arenaAccepted = domainUserData.arenaAccepted,
shareName = domainUserData.shareName,
arenaGroups = domainUserData.arenaGroups
)
Expand Down Expand Up @@ -243,7 +244,7 @@ trait FolderConverterService {
domainUserData.arenaEnabled || arenaEnabledUsers.map(_.toLowerCase).contains(domainUserData.email.toLowerCase)
}

val arenaAccepted = updatedUser.arenaAccept match {
val arenaAccepted = updatedUser.arenaAccepted match {
case Some(true) if arenaEnabled => true
case Some(false) => false
case _ => domainUserData.arenaAccepted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ trait UserService {
arenaEnabled = None,
shareName = Some(shareName),
arenaGroups = None,
arenaAccept = None
arenaAccepted = None
)
updated <- userService.updateFeideUserDataAuthenticated(updatedFeideUser, feideId, feideAccessToken)(session)
} yield updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class FolderConverterServiceTest extends UnitTestSuite with TestEnvironment {
organization = "oslo",
groups = Seq(MyNDLAGroupDTO(id = "id", displayName = "oslo", isPrimarySchool = true, parentId = None)),
arenaEnabled = false,
arenaAccepted = false,
shareName = false,
arenaGroups = List.empty
)
Expand Down Expand Up @@ -482,23 +483,23 @@ class FolderConverterServiceTest extends UnitTestSuite with TestEnvironment {
arenaEnabled = None,
shareName = None,
arenaGroups = None,
arenaAccept = None
arenaAccepted = None
)
val updatedUserData2 =
UpdatedMyNDLAUserDTO(
favoriteSubjects = Some(Seq.empty),
arenaEnabled = None,
shareName = None,
arenaGroups = None,
arenaAccept = None
arenaAccepted = None
)
val updatedUserData3 =
UpdatedMyNDLAUserDTO(
favoriteSubjects = Some(Seq("x", "y", "z")),
arenaEnabled = None,
shareName = None,
arenaGroups = None,
arenaAccept = None
arenaAccepted = None
)

val expectedUserData1 = MyNDLAUser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment {
arenaEnabled = None,
shareName = Some(true),
arenaGroups = None,
arenaAccept = None
arenaAccepted = None
)
val userAfterMerge = MyNDLAUser(
id = 42,
Expand Down Expand Up @@ -100,6 +100,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment {
organization = "oslo",
groups = Seq(MyNDLAGroupDTO(id = "id", displayName = "oslo", isPrimarySchool = false, parentId = None)),
arenaEnabled = false,
arenaAccepted = false,
shareName = true,
arenaGroups = List.empty
)
Expand Down Expand Up @@ -128,7 +129,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment {
arenaEnabled = None,
shareName = None,
arenaGroups = None,
arenaAccept = None
arenaAccepted = None
)

doReturn(Success(()))
Expand Down Expand Up @@ -199,6 +200,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment {
organization = "oslo",
groups = Seq(MyNDLAGroupDTO(id = "id", displayName = "oslo", isPrimarySchool = true, parentId = None)),
arenaEnabled = false,
arenaAccepted = false,
shareName = false,
arenaGroups = List.empty
)
Expand Down Expand Up @@ -274,6 +276,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment {
organization = "oslo",
groups = Seq(MyNDLAGroupDTO(id = "id", displayName = "oslo", isPrimarySchool = true, parentId = None)),
arenaEnabled = false,
arenaAccepted = false,
shareName = false,
arenaGroups = List.empty
)
Expand Down Expand Up @@ -352,6 +355,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment {
organization = "oslo",
groups = Seq(MyNDLAGroupDTO(id = "id", displayName = "oslo", isPrimarySchool = true, parentId = None)),
arenaEnabled = false,
arenaAccepted = false,
shareName = false,
arenaGroups = List.empty
)
Expand Down

0 comments on commit 5a16ef9

Please sign in to comment.