mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Small model update for tags and users
- tags are now created with uuid & timestamps - user role is no longer a model, just a join done with attach
This commit is contained in:
parent
dd7e04e9a5
commit
01f6551bf2
@ -1,11 +1,20 @@
|
||||
var Tag,
|
||||
Tags,
|
||||
uuid = require('node-uuid'),
|
||||
Posts = require('./post').Posts,
|
||||
GhostBookshelf = require('./base');
|
||||
|
||||
Tag = GhostBookshelf.Model.extend({
|
||||
tableName: 'tags',
|
||||
|
||||
hasTimestamps: true,
|
||||
|
||||
defaults: function () {
|
||||
return {
|
||||
uuid: uuid.v4()
|
||||
};
|
||||
},
|
||||
|
||||
posts: function () {
|
||||
return this.belongsToMany(Posts);
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
var User,
|
||||
Users,
|
||||
UserRole,
|
||||
// UserRoles,
|
||||
_ = require('underscore'),
|
||||
uuid = require('node-uuid'),
|
||||
when = require('when'),
|
||||
@ -13,10 +11,6 @@ var User,
|
||||
Role = require('./role').Role,
|
||||
Permission = require('./permission').Permission;
|
||||
|
||||
UserRole = GhostBookshelf.Model.extend({
|
||||
tableName: 'roles_users'
|
||||
});
|
||||
|
||||
|
||||
function validatePasswordLength(password) {
|
||||
try {
|
||||
@ -145,7 +139,7 @@ User = GhostBookshelf.Model.extend({
|
||||
// Assign the userData to our created user so we can pass it back
|
||||
userData = addedUser;
|
||||
// Add this user to the admin role (assumes admin = role_id: 1)
|
||||
return UserRole.add({role_id: 1, user_id: addedUser.id});
|
||||
return userData.roles().attach(1);
|
||||
}).then(function (addedUserRole) {
|
||||
// Return the added user as expected
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user