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