(teamId, userId, projectId, options = {})
| 160 | } |
| 161 | |
| 162 | addProjectAccess(teamId, userId, projectId, options = {}) { |
| 163 | let gTeamRole; |
| 164 | const { transaction } = options; |
| 165 | |
| 166 | return db.TeamRole.findOne({ where: { team_id: teamId, user_id: userId }, transaction }) |
| 167 | .then((teamRole) => { |
| 168 | gTeamRole = teamRole; |
| 169 | |
| 170 | const newProjects = teamRole.projects || []; |
| 171 | if (_.indexOf(newProjects, parseInt(projectId, 10)) > -1) return teamRole; |
| 172 | |
| 173 | newProjects.push(parseInt(projectId, 10)); |
| 174 | return db.TeamRole.update({ projects: newProjects }, { where: { id: teamRole.id }, transaction }); |
| 175 | }) |
| 176 | .then(() => { |
| 177 | return db.TeamRole.findByPk(gTeamRole.id, { transaction }); |
| 178 | }) |
| 179 | .catch((err) => { |
| 180 | return new Promise((resolve, reject) => reject(err)); |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | addProjectAccessToOwner(teamId, projectId, options = {}) { |
| 185 | const { transaction } = options; |
no test coverage detected