aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/controllers
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-25 11:17:42 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-25 11:17:42 +0200
commite582c3b84c6090b08f33d599c354968fcd868d14 (patch)
treeb6de1b7b1f708bf9126ccb709d5129e91a67c7d5 /app/controllers
parentchanged what gets collected (diff)
downloadDivid-e582c3b84c6090b08f33d599c354968fcd868d14.tar.gz
moved and renamed files to match the filesetup we want.
havebeen using a dev-setup till now.
Diffstat (limited to '')
-rw-r--r--app/controllers/system.js (renamed from controllers/system.js)35
-rw-r--r--app/controllers/users.js (renamed from controllers/users.js)31
2 files changed, 19 insertions, 47 deletions
diff --git a/controllers/system.js b/app/controllers/system.js
index c29e06f..0e63083 100644
--- a/controllers/system.js
+++ b/app/controllers/system.js
@@ -4,7 +4,7 @@
*/
var mongoose = require('mongoose')
, env = process.env.NODE_ENV || 'development'
- , config = require('../config/config.js')[env]
+ , config = require('../../config/config.js')[env]
, Project = mongoose.model('Project')
, Access = mongoose.model('Access')
, User = mongoose.model('User')
@@ -36,23 +36,6 @@ exports.index = function(req, res) {
};
-
-exports.test = function(req, res) {
- res.render('test', {
- title: 'test',
- user: req.user
- });
-};
-
-
-exports.home = function(req, res) {
- res.render('home', {
- title: 'home',
- user: req.user
- });
-};
-
-
exports.faq = function(req, res) {
res.render('faq', {
title: 'faq',
@@ -159,7 +142,7 @@ exports.dashboard = function(req, res) {
exports.project = function(req, res) {
Project.loadShort(req.params.short, function(err, project) {
- if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack });
+ if (err || !project) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err });
Access.loadProject(project._id, function(err, access) {
if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack });
pPost.loadProject(project._id, function(err, posts) {
@@ -207,7 +190,7 @@ exports.project = function(req, res) {
if (pro.user[i].diff > 0) pro.user[i].coeff = pro.user[i].diff / pro.otot;
}
console.log(pro);
- res.render('project', {
+ res.render('project/project', {
title: project.name
, user: req.user
, req: req
@@ -228,7 +211,7 @@ exports.projectParticipants = function(req, res) {
if (req.header('Referer') === undefined) { return res.status(403).render('error', { title: 403, text: 'Du har ikke tilgang til denne siden. Du må registrere deg først. Sjekk mailen din for å se invitekode.' }); }
else { return res.redirect('back'); }
}
- res.render('projectParticipants', { title: 'Prosjektdeltakere', user: req.user });
+ res.render('project/participants', { title: 'Prosjektdeltakere', user: req.user });
}
@@ -241,7 +224,7 @@ exports.projectPost = function(req, res) {
Project.loadShort(req.params.short, function(err, project) {
if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack });
req.project = project;
- res.render('projectPost', { title: 'Legg til utgift', user: req.user, req: req, project: project });
+ res.render('project/post', { title: 'Legg til utgift', user: req.user, req: req, project: project });
});
@@ -278,7 +261,7 @@ exports.postProjectPost = function(req, res) {
ppost.value = sanitize(req.body.value).toInt(); // this will remove leading zeroes. '0123' => '123'
ppost.when = new Date(sanitize(req.body.date).escape() + ' ' + sanitize(req.body.time).escape() + ':00');
ppost.save(function(err) {
- if (err) return res.render('projectPost', { title: 'Legg til utgift - en feil oppstod', user: req.user, req: req, project: project });
+ if (err) return res.render('project/post', { title: 'Legg til utgift - en feil oppstod', user: req.user, req: req, project: project });
return res.redirect('/project/' + project.shortURL);
});
});
@@ -290,7 +273,7 @@ exports.newProject = function(req, res) {
else { return res.redirect('back'); }
}
- res.render('newProject', { title: 'Nytt prosjekt', user: req.user });
+ res.render('project/newProject', { title: 'Nytt prosjekt', user: req.user });
}
exports.postNewProject = function(req, res) {
@@ -304,7 +287,7 @@ exports.postNewProject = function(req, res) {
project.save(function(err) {
if (err) {
console.log(err.errors);
- return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user, errors: err.errors, project: project });
+ return res.render('project/newProject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user, errors: err.errors, project: project });
}
var access = new Access();
access.user = req.user._id;
@@ -314,7 +297,7 @@ exports.postNewProject = function(req, res) {
access.save(function(err) {
if (err) {
console.log(err.errors);
- return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user });
+ return res.render('project/newProject', { title: 'Nytt prosjekt - en feil oppstod', user: req.user });
}
return res.redirect('/dashboard');
});
diff --git a/controllers/users.js b/app/controllers/users.js
index 86cbd35..725fa3e 100644
--- a/controllers/users.js
+++ b/app/controllers/users.js
@@ -8,7 +8,7 @@ var mongoose = require('mongoose')
, Project = mongoose.model('Project')
, Access = mongoose.model('Access')
, env = process.env.NODE_ENV || 'development'
- , config = require('../config/config')[env]
+ , config = require('../../config/config')[env]
, Validator = require('validator').Validator
, v = new Validator()
, sanitize = require('validator').sanitize;
@@ -26,17 +26,6 @@ Validator.prototype.getErrors = function() {
/**
- * Login
- */
-exports.login = function(req, res) {
- res.render('login', {
- title: 'Login'
- });
-
-}
-
-
-/**
* Logout
*/
exports.logout = function(req, res) {
@@ -66,7 +55,7 @@ exports.randomLogin = function(req, res) {
* Signup
*/
exports.signup = function(req, res) {
- res.render('signup', { title: 'Registrer deg', invite: false });
+ res.render('users/signup', { title: 'Registrer deg', invite: false });
}
/**
@@ -76,7 +65,7 @@ exports.create = function(req, res) {
var user = new User(req.body);
user.provider = 'local';
user.save(function(err) {
- if (err) return res.render('signup', { errors: err.errors, user: user });
+ if (err) return res.render('users/signup', { errors: err.errors, user: user });
req.logIn(user, function(err) {
if (err) return next(err);
return res.redirect('/dashboard');
@@ -106,7 +95,7 @@ exports.authCallback = function(req, res, next) {
exports.registerEmail = function(req, res) {
// in case some user who has alreadu registered an email gets on this page
if (req.user.email !== undefined) return res.redirect('/dashboard');
- res.render('registerEmail', { title: 'Registrer din e-post' });
+ res.render('users/registerEmail', { title: 'Registrer din e-post' });
}
@@ -125,7 +114,7 @@ exports.postRegisterEmail = function(req, res) {
if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack });
// if mail is in use..
- if (user) return res.render('registerEmail', { title: 'Den e-posten er allerede i bruk. Vennligs registrer en annen.' });
+ if (user) return res.render('users/registerEmail', { title: 'Den e-posten er allerede i bruk. Vennligs registrer en annen.' });
User.update({ _id: req.user._id }, { email: req.body.email, status: 3 }, function(err) {
if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack });
@@ -183,7 +172,7 @@ exports.postProjectParticipants = function(req, res) {
newUser.password = newUser.generateRandomToken(32);
newUser.randomToken = newUser.generateRandomToken(10, true);
newUser.save(function(err) {
- if (err) return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
+ if (err) return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
console.log('made new user ' + newUser._id);
var access = new Access();
access.user = newUser._id;
@@ -193,7 +182,7 @@ exports.postProjectParticipants = function(req, res) {
access.save(function(err) {
if (err) {
console.log(err.errors);
- return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
+ return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
}
console.log('made new access for user ' + newUser._id);
message.to = newUser.email;
@@ -204,7 +193,7 @@ exports.postProjectParticipants = function(req, res) {
} else { // if the user exists, add him to the project
Access.checkAccess(user._id, project._id, 0, function(err, acc) {
- if (err) return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
+ if (err) return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
if (acc) { // if the user already has access to the project.. do nothing
console.log('user ' + user.email + ' already has access to project ' + project.name);
} else {
@@ -221,7 +210,7 @@ exports.postProjectParticipants = function(req, res) {
access.save(function(err) {
if (err) {
console.log(err.errors);
- return res.render('projectParticipants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
+ return res.render('project/participants', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true });
}
console.log('made new access for user ' + user.username);
message.to = user.email;
@@ -251,7 +240,7 @@ exports.claimInvite = function(req, res) {
if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack });
if (!user) return res.render('error', { title: 'This invite does not exist', text: 'Invitasjonen din er ugyldig' });
- res.render('signup', {
+ res.render('users/signup', {
invite: true,
title: 'Registrer deg!',
email: user.email }