salix/services/ticket/common/models/ticket-tracking.js

16 lines
539 B
JavaScript
Raw Normal View History

2018-03-21 11:56:18 +00:00
module.exports = function(Self) {
require('../methods/ticket-tracking/filter')(Self);
require('../methods/ticket-tracking/changeState')(Self);
2018-04-05 09:09:22 +00:00
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
Self.observe('before save', async function(ctx) {
let models = Self.app.models;
let token = ctx.options.accessToken;
let userId = token && token.userId;
let user = await models.Worker.findOne({where: {userFk: userId}});
ctx.instance.workerFk = user.id;
});
2018-03-21 11:56:18 +00:00
};