Add VersionedModel base and version page changes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const Model = require("flitter-orm/src/model/Model");
|
||||
const { ObjectId } = require("mongodb");
|
||||
const uuid = require('uuid/v4');
|
||||
const VersionedModel = require('../VersionedModel')
|
||||
const { ObjectId } = require('mongodb')
|
||||
const uuid = require('uuid/v4')
|
||||
|
||||
const ActiveScope = require('../scopes/Active.scope')
|
||||
|
||||
@@ -9,13 +9,14 @@ const ActiveScope = require('../scopes/Active.scope')
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class Page extends Model {
|
||||
class Page extends VersionedModel {
|
||||
static get services() {
|
||||
return [...super.services, "models"];
|
||||
return [...super.services, 'models'];
|
||||
}
|
||||
static get schema() {
|
||||
// Return a flitter-orm schema here.
|
||||
return {
|
||||
...super.schema,
|
||||
UUID: {type: String, default: () => uuid()},
|
||||
Name: String,
|
||||
OrgUserId: ObjectId,
|
||||
@@ -201,7 +202,8 @@ class Page extends Model {
|
||||
// Add the user to the appropriate access list
|
||||
this[`shared_users_${level}`].push(user._id)
|
||||
|
||||
await this.save()
|
||||
// TODO replace user.uid with name of user when we support that
|
||||
await this.version_save(`Shared with ${user.uid} (${level} access)`)
|
||||
await user.save()
|
||||
}
|
||||
|
||||
@@ -217,7 +219,7 @@ class Page extends Model {
|
||||
this.shared_users_update = this.shared_users_update.filter(x => String(x) !== user.id)
|
||||
this.shared_users_manage = this.shared_users_manage.filter(x => String(x) !== user.id)
|
||||
|
||||
await this.save()
|
||||
await this.version_save(`Unshared with ${user.uid}`)
|
||||
await user.save()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user