added stuff

This commit is contained in:
David Baldwynn 2015-07-02 18:40:57 -07:00
parent 64245d6582
commit 7c8495cd64
3 changed files with 29 additions and 74 deletions

View file

@ -14,25 +14,6 @@ var mongoose = require('mongoose'),
path = require('path'), path = require('path'),
_ = require('lodash'); _ = require('lodash');
/**
* Create a new form
*/
exports.create = function(req, res) {
var form = new Form(req.body);
form.admin = req.user;
form.save(function(err) {
if (err) {
console.log(err);
res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(form);
}
});
};
/** /**
* Upload PDF * Upload PDF
*/ */
@ -80,58 +61,6 @@ exports.uploadPDF = function(req, res, next) {
}else { }else {
next(new Error('Uploaded files were NOT detected')); next(new Error('Uploaded files were NOT detected'));
} }
};
// exports.uploadPDF = function(pdfFile, _user, cb) {
// // console.log(_user.username);
// // console.log(config.tmpUploadPath);
// console.log('inside uploadPDF');
// // console.log(pdfFile);
// if (pdfFile.size === 0) {
// cb(new Error('Files uploaded are EMPTY'), null);
// }else {
// fs.exists(pdfFile.path, function(exists) {
// //If file exists move to user's tmp directory
// if(exists) {
// var newDestination = config.tmpUploadPath+""+_user.username;
// var stat = null;
// try {
// stat = fs.statSync(newDestination);
// } catch (err) {
// fs.mkdirSync(newDestination);
// }
// if (stat && !stat.isDirectory()) {
// console.log('Directory cannot be created');
// cb(new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"'), null);
// }
// fs.move(pdfFile.path, path.join(newDestination, pdfFile.name), function (err) {
// if (err) {
// return cb(new Error(err.message), null);
// }
// pdfFile.path = path.join(newDestination, pdfFile.name);
// return cb(null, pdfFile);
// });
// } else {
// cb(new Error('Did NOT get your file!'), null);
// }
// });
// }
// };
/**
* Show the current form
*/
exports.read = function(req, res) {
res.json(req.form);
}; };
/** /**
@ -180,7 +109,6 @@ exports.createSubmission = function(req, res) {
}); });
}; };
/** /**
* Get List of Submissions for a given Form * Get List of Submissions for a given Form
*/ */
@ -200,6 +128,32 @@ exports.listSubmissions = function(req, res) {
}); });
}; };
/**
* Create a new form
*/
exports.create = function(req, res) {
var form = new Form(req.body);
form.admin = req.user;
form.save(function(err) {
if (err) {
console.log(err);
res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(form);
}
});
};
/**
* Show the current form
*/
exports.read = function(req, res) {
res.json(req.form);
};
/** /**
* Update a form * Update a form

View file

@ -2,6 +2,7 @@
// Setting up route // Setting up route
angular.module('forms').config(['$stateProvider', angular.module('forms').config(['$stateProvider',
function($stateProvider) { function($stateProvider) {
// Forms state routing // Forms state routing
$stateProvider. $stateProvider.

View file

@ -39,7 +39,7 @@
Date Submitted (UTC) Date Submitted (UTC)
</th> </th>
<th ng-if="form.autofillPDFs"> <th ng-if="form.autofillPDFs">
Generated PDf Generated PDF
</th> </th>
</tr> </tr>
</thead> </thead>
@ -55,7 +55,7 @@
<td> <td>
{{submission.created | date:'yyyy-MM-dd HH:mm:ss'}} {{submission.created | date:'yyyy-MM-dd HH:mm:ss'}}
</td> </td>
<td ng-if="form.autofillPDFs"> <td ng-if="submission.pdf">
<a href="{{submission.pdf.path}}">Generated PDF</a> <a href="{{submission.pdf.path}}">Generated PDF</a>
</td> </td>
</tr> </tr>