-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1770 from betagouv/bookmarks
Bookmarks
- Loading branch information
Showing
39 changed files
with
456 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package controllers | ||
|
||
import authentication.Authenticator | ||
import authentication.actions.UserAction.WithRole | ||
import models._ | ||
import orchestrators._ | ||
import play.api.Logger | ||
import play.api.libs.json.Json | ||
import play.api.mvc.ControllerComponents | ||
|
||
import java.util.UUID | ||
import scala.concurrent.ExecutionContext | ||
|
||
class BookmarkController( | ||
bookmarkOrchestrator: BookmarkOrchestrator, | ||
authenticator: Authenticator[User], | ||
controllerComponents: ControllerComponents | ||
)(implicit val ec: ExecutionContext) | ||
extends BaseController(authenticator, controllerComponents) { | ||
|
||
val logger: Logger = Logger(this.getClass) | ||
|
||
def addBookmark(uuid: UUID) = | ||
SecuredAction.andThen(WithRole(UserRole.AdminsAndReadOnlyAndAgents)).async { request => | ||
for { | ||
_ <- bookmarkOrchestrator.addBookmark(uuid, request.identity) | ||
} yield Ok | ||
} | ||
|
||
def removeBookmark(uuid: UUID) = | ||
SecuredAction.andThen(WithRole(UserRole.AdminsAndReadOnlyAndAgents)).async { request => | ||
for { | ||
_ <- bookmarkOrchestrator.removeBookmark(uuid, request.identity) | ||
} yield Ok | ||
} | ||
|
||
def countBookmarks() = SecuredAction.andThen(WithRole(UserRole.AdminsAndReadOnlyAndAgents)).async { request => | ||
for { | ||
count <- bookmarkOrchestrator.countBookmarks(request.identity) | ||
} yield Ok(Json.toJson(count)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.