diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-29 14:24:43 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-29 14:24:43 +0200 |
commit | 7ffbad817125e0767ff51ae7b3ddd9092328bafc (patch) | |
tree | 263cd285ca4b06c7c13cc6f92e3cf7739be9bfc1 | |
parent | added button for new project (diff) | |
download | Divid-7ffbad817125e0767ff51ae7b3ddd9092328bafc.tar.gz |
been working on the project model and posting projects
Diffstat (limited to '')
-rw-r--r-- | app.js | 2 | ||||
-rw-r--r-- | controllers/system.js | 11 | ||||
-rw-r--r-- | models/project.js | 2 | ||||
-rw-r--r-- | views/newproject.ejs | 2 |
4 files changed, 12 insertions, 5 deletions
@@ -10,7 +10,7 @@ var express = require('express') /** * App configuration */ -var port = process.env.PORT || 8001 +var port = process.env.PORT || 8000 , env = process.env.NODE_ENV || 'development' , config = require('./config/config')[env] , auth = require('./config/middlewares/authorization'); diff --git a/controllers/system.js b/controllers/system.js index f04ec6d..e3a55bd 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -2,7 +2,8 @@ /** * Module dependencies */ - +var mongoose = require('mongoose') + , Project = mongoose.model('Project'); @@ -69,3 +70,11 @@ exports.newProject = function(req, res) { res.render('newproject', { title: 'Nytt prosjekt', loggedin: true }); } +exports.postNewProject = function(req, res) { + var project = new Project(req.body); + project.save(function(err) { + if (err) return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + return res.redirect('/dashboard'); + }); +} + diff --git a/models/project.js b/models/project.js index 52853d7..2424694 100644 --- a/models/project.js +++ b/models/project.js @@ -20,8 +20,6 @@ var ProjectSchema = new Schema({ updated: { type: Date, default: Date.now } }); -console.log(Schema.ObjectId); - // the four validations below only apply if you are signing up traditionally diff --git a/views/newproject.ejs b/views/newproject.ejs index 3d0ff7c..e83673f 100644 --- a/views/newproject.ejs +++ b/views/newproject.ejs @@ -13,7 +13,7 @@ <form class="form-horizontal" action="/project/new" method="post"> <fieldset> - <legend>Lag nytt prosjekt</legend> + <h1><legend><%= title %></legend></h1> <div class="control-group"> <label class="control-label">Prosjektnavn</label> |