feat: Add read-only collections (#1991)

closes #1017
This commit is contained in:
Tom Moor
2021-03-30 21:02:08 -07:00
committed by GitHub
parent d7acf616cf
commit 7e1b07ef98
50 changed files with 940 additions and 558 deletions

View File

@ -25,7 +25,14 @@ const Collection = sequelize.define(
type: DataTypes.STRING,
defaultValue: null,
},
private: DataTypes.BOOLEAN,
permission: {
type: DataTypes.STRING,
defaultValue: null,
allowNull: true,
validate: {
isIn: [["read", "read_write"]],
},
},
maintainerApprovalRequired: DataTypes.BOOLEAN,
documentStructure: DataTypes.JSONB,
sharing: {
@ -199,7 +206,7 @@ Collection.addHook("afterDestroy", async (model: Collection) => {
});
Collection.addHook("afterCreate", (model: Collection, options) => {
if (model.private) {
if (model.permission !== "read_write") {
return CollectionUser.findOrCreate({
where: {
collectionId: model.id,