Skip to content

Commit

Permalink
Fix addable in types endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Aug 29, 2023
1 parent 962ead1 commit b141b94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- Read position in parent in update content call @robgietema
- Apply behaviors to children in get content call @robgietema
- Reindex parent after delete @robgietema
- Fix addable in types endpoint @robgietema

### Internal

Expand Down
12 changes: 7 additions & 5 deletions src/collections/type/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* @module collections/type/type
*/

import { includes } from 'lodash';
import { has, includes } from 'lodash';

import { getRootUrl } from '../../helpers';
import { getRootUrl, hasPermission } from '../../helpers';
import { Collection } from '../../collections';
import _ from 'lodash';

Expand All @@ -25,9 +25,11 @@ export class TypeCollection extends Collection {
return _(super.toJSON())
.map((model) => ({
'@id': `${getRootUrl(req)}/@types/${model.id}`,
addable: req.type.filter_content_types
? includes(req.type.allowed_content_types, model.id)
: model.global_allow,
addable:
hasPermission(req.permissions, 'Add') &&
(req.type.filter_content_types
? includes(req.type.allowed_content_types, model.id)
: model.global_allow),
title: req.i18n(model.title),
}))
.value();
Expand Down

0 comments on commit b141b94

Please sign in to comment.