Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
c68f576a
Commit
c68f576a
authored
Mar 19, 2020
by
Rosanny Sihombing
Browse files
addUserProjectRole
parent
adcfe447
Changes
2
Show whitespace changes
Inline
Side-by-side
routes/methods.js
View file @
c68f576a
...
...
@@ -132,6 +132,12 @@ var methods = {
callback
(
rows
,
err
);
});
},
addUserProjectRole
:
function
(
data
,
callback
)
{
dbconn
.
user
.
query
(
'
INSERT INTO user_project_role SET ?
'
,
data
,
function
(
err
,
results
,
fields
){
if
(
err
)
throw
err
;
callback
(
err
);
})
},
// ======================= project db =======================
getAllProjects
:
function
(
callback
)
{
dbconn
.
project
.
query
(
'
CALL getAllprojects
'
,
function
(
err
,
rows
,
fields
){
...
...
@@ -146,9 +152,10 @@ var methods = {
})
},
addProjectOverview
:
function
(
data
,
callback
)
{
dbconn
.
project
.
query
(
'
INSERT INTO project_overview SET ?
'
,
data
,
function
(
err
,
r
ow
s
,
fields
){
dbconn
.
project
.
query
(
'
INSERT INTO project_overview SET ?
'
,
data
,
function
(
err
,
r
esult
s
,
fields
){
if
(
err
)
throw
err
;
callback
(
err
);
//console.log(results.insertId)
callback
(
results
.
insertId
,
err
);
})
}
};
...
...
routes/routes-project.js
View file @
c68f576a
...
...
@@ -100,7 +100,7 @@ module.exports = function (app) {
}
})
app
.
post
(
'
/addprojectoverview
'
,
function
(
req
,
res
)
{
app
.
post
(
'
/addprojectoverview
__
'
,
function
(
req
,
res
)
{
if
(
req
.
isAuthenticated
())
{
var
wiki
=
0
if
(
req
.
body
.
wiki
)
...
...
@@ -146,6 +146,83 @@ module.exports = function (app) {
}
})
app
.
post
(
'
/addprojectoverview
'
,
function
(
req
,
res
)
{
if
(
req
.
isAuthenticated
())
{
var
wiki
=
0
if
(
req
.
body
.
wiki
)
wiki
=
1
var
projectTerm
=
req
.
body
.
termForm
+
"
-
"
+
req
.
body
.
termTo
var
projectOverviewData
=
{
pname
:
req
.
body
.
pname
,
title
:
req
.
body
.
title
,
onelinesummary
:
req
.
body
.
summary
,
category
:
req
.
body
.
category
,
logo
:
req
.
body
.
logo
,
gitlab
:
req
.
body
.
gitlabURL
,
wiki
:
wiki
,
overview
:
req
.
body
.
overview
,
question
:
req
.
body
.
question
,
approach
:
req
.
body
.
approach
,
result
:
req
.
body
.
result
,
keywords
:
req
.
body
.
keywords
,
announcement
:
req
.
body
.
announcement
,
term
:
projectTerm
,
further_details
:
req
.
body
.
furtherDetails
,
website
:
req
.
body
.
website
,
src
:
req
.
body
.
src
,
caption
:
req
.
body
.
caption
,
contact_lastname
:
req
.
body
.
contactName
,
contact_email
:
req
.
body
.
contactEmail
,
leader_lastname
:
req
.
body
.
leaderName
,
leader_email
:
req
.
body
.
leaderEmail
}
/* RS: Temporary solution while Project DB is still in early phase.
When User DB and Project DB are integrated and quite stabil, this operation should be done in 1 transaction.
*/
var
userId
// todo: make this global variable?
async
.
waterfall
([
// get userId by email from userdb
function
(
done
)
{
methods
.
getUserIdByEmail
(
req
.
user
.
email
,
function
(
id
,
err
)
{
if
(
!
err
)
{
userId
=
id
done
(
err
)
}
})
},
// add project overview
function
(
done
)
{
methods
.
addProjectOverview
(
projectOverviewData
,
function
(
projectOverviewId
,
err
){
if
(
!
err
)
{
done
(
err
,
projectOverviewId
)
}
})
},
// assign the created overview to logged-in user
function
(
projectOverviewId
,
done
)
{
var
userProjectRoleData
=
{
project_id
:
projectOverviewId
,
user_id
:
userId
,
role_id
:
3
// OVERVIEW_CREATOR
}
methods
.
addUserProjectRole
(
userProjectRoleData
,
function
(
userProjects
,
err
)
{
if
(
err
)
{
//req.flash('error', "Failed")
req
.
flash
(
'
error
'
,
"
Fehlgeschlagen
"
)
res
.
redirect
(
'
/addProjectOverview
'
);
}
else
{
req
.
flash
(
'
success
'
,
'
Your project has been created.
'
)
res
.
redirect
(
'
/project
'
);
}
})
}
])
}
})
app
.
get
(
'
/updateprojectoverview
'
,
function
(
req
,
res
)
{
// only their own project
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment