diff --git a/assets/vue/router/index.js b/assets/vue/router/index.js index 1feea7584c6..50d8686436e 100644 --- a/assets/vue/router/index.js +++ b/assets/vue/router/index.js @@ -196,14 +196,12 @@ router.beforeResolve(async (to) => { if ("CourseHome" === to.name) { cid = parseInt(to.params?.id ?? 0) - const useBasic = true - await cidReqStore.setCourseAndSessionById(cid, sid, useBasic) + } + + if (cid) { + await cidReqStore.setCourseAndSessionById(cid, sid) } else { - if (cid) { - await cidReqStore.setCourseAndSessionById(cid, sid) - } else { - cidReqStore.resetCid() - } + cidReqStore.resetCid() } }) diff --git a/assets/vue/services/sessionService.js b/assets/vue/services/sessionService.js index c0c3d77c4fd..4f53e483414 100644 --- a/assets/vue/services/sessionService.js +++ b/assets/vue/services/sessionService.js @@ -17,7 +17,7 @@ export default { * @returns {Promise} */ async find(iri, useBasic = false) { - const endpoint = useBasic ? `${iri}/basic` : iri + const endpoint = iri const groups = useBasic ? ['session:basic'] : ['session:read'] const { data } = await api.get(endpoint, { params: { diff --git a/assets/vue/store/cidReq.js b/assets/vue/store/cidReq.js index fba675d466e..fde93cb08a2 100644 --- a/assets/vue/store/cidReq.js +++ b/assets/vue/store/cidReq.js @@ -78,7 +78,7 @@ export const useCidReqStore = defineStore("cidReq", () => { } } - const setSessionByIri = async (sId, useBasic = false) => { + const setSessionByIri = async (sId, useBasic = true) => { const sessionIri = `/api/sessions/${sId}` if (session.value && sessionIri === session.value["@id"]) { @@ -92,7 +92,7 @@ export const useCidReqStore = defineStore("cidReq", () => { } } - const setCourseAndSessionById = (cId, sId = undefined, useBasic = false) => { + const setCourseAndSessionById = (cId, sId = undefined, useBasic = true) => { if (!cId) { return Promise.resolve() } diff --git a/src/CoreBundle/Entity/Session.php b/src/CoreBundle/Entity/Session.php index 558448292a5..b5c002d9e70 100644 --- a/src/CoreBundle/Entity/Session.php +++ b/src/CoreBundle/Entity/Session.php @@ -6,6 +6,7 @@ namespace Chamilo\CoreBundle\Entity; +use ApiPlatform\Core\Serializer\Filter\GroupFilter; use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter; @@ -33,17 +34,10 @@ #[ApiResource( operations: [ - new Get( - uriTemplate: '/sessions/{id}/basic', - normalizationContext: [ - 'groups' => ['session:basic'], - ], - security: "is_granted('ROLE_ADMIN') or is_granted('VIEW', object)" - ), new Get( uriTemplate: '/sessions/{id}', normalizationContext: [ - 'groups' => ['session:read', 'session:item:read'], + 'groups' => ['session:basic'], ], security: "is_granted('ROLE_ADMIN') or is_granted('VIEW', object)" ), @@ -112,9 +106,10 @@ #[ORM\EntityListeners([SessionListener::class])] #[ORM\Entity(repositoryClass: SessionRepository::class)] #[UniqueEntity('title')] -#[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial'])] -#[ApiFilter(filterClass: PropertyFilter::class)] -#[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'title'])] +#[ApiFilter(SearchFilter::class, properties: ['title' => 'partial'])] +#[ApiFilter(PropertyFilter::class)] +#[ApiFilter(OrderFilter::class, properties: ['id', 'title'])] +#[ApiFilter(GroupFilter::class, arguments: ['parameterName' => 'groups'])] class Session implements ResourceWithAccessUrlInterface, Stringable { public const READ_ONLY = 1;