MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / create

Method create

server/controllers/ProjectController.js:61–98  ·  view source on GitHub ↗
(userId, data, options = {})

Source from the content-addressed store, hash-verified

59 }
60
61 create(userId, data, options = {}) {
62 let newProject = {};
63 const { transaction } = options;
64
65 return db.Project.create(data, { transaction })
66 .then((project) => {
67 newProject = project;
68 return this.updateProjectRole(project.id, userId, "teamOwner", options);
69 })
70 .then(() => {
71 const brewName = `${newProject.name.replace(/[\W_]+/g, "_")}_${newProject.id}`;
72 if (transaction) {
73 return db.Project.update({ brewName }, { where: { id: newProject.id }, transaction });
74 }
75
76 return this.update(newProject.id, { brewName });
77 })
78 .then(() => {
79 // now update the projects access in TeamRole
80 return this.teamController.addProjectAccess(data.team_id, userId, newProject.id, options);
81 })
82 .then(() => {
83 return this.teamController.addProjectAccessToOwner(data.team_id, newProject.id, options);
84 })
85 .then(() => {
86 if (transaction) {
87 return db.Project.findOne({
88 where: { id: newProject.id },
89 transaction,
90 });
91 }
92
93 return this.findById(newProject.id);
94 })
95 .catch((error) => {
96 return new Promise((resolve, reject) => reject(error));
97 });
98 }
99
100 update(id, data) {
101 const newFields = normalizeProjectScheduleTimezones(data);

Callers 4

updateProjectRoleMethod · 0.45
createVariableMethod · 0.45
createDashboardFilterMethod · 0.45
createSharePolicyMethod · 0.45

Calls 5

updateProjectRoleMethod · 0.95
updateMethod · 0.95
findByIdMethod · 0.95
addProjectAccessMethod · 0.80

Tested by

no test coverage detected