From aea0cd7b76be36e944374b003fe2b390463d11f3 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Wed, 14 Feb 2024 08:42:23 +0100 Subject: [PATCH] fix cms page update --- modules/cms/src/main/CmsApi.scala | 2 +- modules/cms/src/main/CmsForm.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cms/src/main/CmsApi.scala b/modules/cms/src/main/CmsApi.scala index b0af791569b8b..8fa1758a97765 100644 --- a/modules/cms/src/main/CmsApi.scala +++ b/modules/cms/src/main/CmsApi.scala @@ -37,7 +37,7 @@ final class CmsApi(coll: Coll, markup: CmsMarkup)(using Executor): def create(page: CmsPage): Funit = coll.insert.one(page).void def update(prev: CmsPage, data: CmsForm.CmsPageData)(using me: Me): Fu[CmsPage] = - val page = data update me + val page = data.update(prev, me) coll.update.one($id(page.id), page) inject page def delete(id: Id): Funit = coll.delete.one($id(id)).void diff --git a/modules/cms/src/main/CmsForm.scala b/modules/cms/src/main/CmsForm.scala index d312788587f6e..336ebb770e0cf 100644 --- a/modules/cms/src/main/CmsForm.scala +++ b/modules/cms/src/main/CmsForm.scala @@ -51,4 +51,4 @@ object CmsForm: by = user.id ) - def update(user: User) = create(user) + def update(prev: CmsPage, user: User) = create(user).copy(id = prev.id)