Commit f88e6c8a authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

add project overview: insert data to db

parent 2786292c
......@@ -138,6 +138,12 @@ var methods = {
if (err) throw err;
callback(rows[0], err);
})
},
addProjectOverview: function(data, callback) {
dbconn.project.query('INSERT INTO project_overview SET ?', data, function (err, rows, fields){
if (err) throw err;
callback(err);
})
}
};
......
......@@ -611,17 +611,59 @@ module.exports = function (app, config, passport, i18n) {
})
app.get('/addprojectoverview', function (req, res) {
//res.render(lang+'/project/addProjectOverview')
if (req.isAuthenticated()) {
res.render(lang+'/project/addProjectOverview')
}
else {
res.redirect('/login')
}
}
})
app.post('/addprojectoverview', function (req, res) {
console.log(req.body)
if (req.isAuthenticated()) {
var wiki = 0
if (req.body.wiki)
wiki = 1
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: req.body.term,
further_details: req.body.furtherDetails,
website: req.body.website,
src: req.body.src,
caption: req.body.caption,
contact_firstname: req.body.contactFirstname,
contact_lastname: req.body.contactLastname,
contact_email: req.body.contactEmail,
leader_firstname: req.body.leaderFirstname,
leader_lastname: req.body.leaderLastname,
leader_email: req.body.leaderEmail
}
methods.addProjectOverview(projectOverviewData, function(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');
}
})
}
})
};
\ No newline at end of file
......@@ -37,10 +37,6 @@ html(lang="de")
div(class="col-md-6 offset-md-2")
h4(class="mb-3 font-weight-bold") Neues Projekt
div(class="col-md-6 offset-md-3")
if successes
for success in successes
div.alert.alert-success.alert-dismissible #{ success }
a(class="close", href="#", data-dismiss="alert", aria-label="close") ×
if errors
for error, i in errors
div.alert.alert-danger.alert-dismissible.fade.show #{ error }
......@@ -52,13 +48,19 @@ html(lang="de")
div(class="form-group col-md-12")
input#inputTitle(name="title" class="form-control" type="text" placeholder="official title of the project*" required)
div(class="form-group col-md-12")
input#inputSummary(name="summary" class="form-control" type="text" placeholder="one line summery of the project")
input#inputSummary(name="summary" class="form-control" type="text" placeholder="one line summary of the project")
div(class="form-group col-md-12")
input#inputCategory(name="category" class="form-control" type="text" placeholder="category of the project")
//div(class="form-group col-md-12")
div(class="form-group col-md-12")
input#inputLogo(name="logo" class="form-control" type="text" placeholder="official logo of the project")
//div(class="form-group col-md-12")
input#inputWiki(name="wiki" class="form-control" type="text")
div(class="form-group col-md-12")
div(class="input-group mb-3")
input#inputGitlabURL(name="gitlabURL" type="text" class="form-control" placeholder="M4_LAB GitLab Project URL, z.B. https://transfer.hft-stuttgart.de/gitlab/username/projectname")
div(class="input-group-prepend")
div(class="input-group-text")
input#inputWiki(name="wiki" type="checkbox")
|   Wiki
h5(class="mb-3 font-weight-bold") Content
div(class='form-row')
div(class='form-group col-md-12')
......@@ -94,13 +96,13 @@ html(lang="de")
div(class="form-group col-md-4")
input#inputContactLastname(name="contactLastname" class="form-control" type="text" placeholder="contact lastname")
div(class="form-group col-md-4")
input#inputContactEmail(name="contactEmail" class="form-control" type="text" placeholder="contact email")
input#inputContactEmail(name="contactEmail" class="form-control" type="email" placeholder="contact email")
div(class="form-group col-md-4")
input#inputLeaderFirstname(name="leaderFirstname" class="form-control" type="text" placeholder="leader firstname")
div(class="form-group col-md-4")
input#inputLeaderLastname(name="leaderLastname" class="form-control" type="text" placeholder="leader lastname")
div(class="form-group col-md-4")
input#inputLeaderEmail(name="leaderEmail" class="form-control" type="text" placeholder="leader email")
input#inputLeaderEmail(name="leaderEmail" class="form-control" type="email" placeholder="leader email")
p <em><small>* Pflichtfeld</small></em>
input#submitBtn(type="submit", class="btn btn-outline-dark btn-block", value="Projekt Anlegen")
......
......@@ -39,6 +39,10 @@ html(lang="de")
else
p Auf dieser Seite sehen Sie die Liste der über dieses Portal veröffentlichten Projekte.
p Möchten Sie ein neues Projekt anlegen, dann klicken Sie bitte auf #[a(href="/addprojectoverview") Anmelden und Projekt anlegen]
if successes
for success in successes
div.alert.alert-success.alert-dismissible #{ success }
a(class="close", href="#", data-dismiss="alert", aria-label="close") &times;
// Active projects
h3(class="mb-3 font-weight-bold") Aktive Projekte
table(class="table table-striped")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment