diff --git a/routes/methods.js b/routes/methods.js index 5a7dc6526268099c3f8b53cdcc88c4826e0716f7..3ffec7199aca4bb05665baffb054f0895c88f116 100644 --- a/routes/methods.js +++ b/routes/methods.js @@ -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); + }) } }; diff --git a/routes/routes.js b/routes/routes.js index abd4f03fa91fee9b5358fbba9b782a265e6b57c8..4a757553b68c8ca8e6a0424507be839afd5375f6 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -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 diff --git a/views/DE/project/addProjectOverview.pug b/views/DE/project/addProjectOverview.pug index a6499a87b3cebd85bac39a604b4cae385ba0319b..7b40b54fc63b3d774caf8d0b8af272f4e3a554ce 100644 --- a/views/DE/project/addProjectOverview.pug +++ b/views/DE/project/addProjectOverview.pug @@ -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") diff --git a/views/DE/project/projects.pug b/views/DE/project/projects.pug index a59cdf45ba6ef160b1cbc60f0c81fe0c3c05739b..10987e6205a9b50f8dcf506fead6b00e6da80040 100644 --- a/views/DE/project/projects.pug +++ b/views/DE/project/projects.pug @@ -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") × // Active projects h3(class="mb-3 font-weight-bold") Aktive Projekte table(class="table table-striped")