Skip to content

Commit

Permalink
Merge pull request sitcomlab#50 from sitcomlab/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SpeckiJ authored Apr 4, 2018
2 parents 945c0a7 + a4e7bc9 commit 02522d7
Show file tree
Hide file tree
Showing 50 changed files with 1,621 additions and 179 deletions.
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ REMIND_AFTER=7
REMIND_UNITL=0
REMIND_ALL=true
JWTSECRET='secret'

UPLOAD_DIR='uploads/'

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ node_modules/*
ssl/*
public/bower_components/*
public/files/temp/*
public/files/custom/*
sql/schema/examples.sql
sql/schema/defaults.sql
*.env
*.log
*.DS_Store
.securestorage.json
.dejavuerc
.idea/*

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Version 1.4.1
- Added Email Notification to all Members when Review is started (and not pending anymore)
- Added q14 (Custom Files)
- Added Password Generation on Cover Sheet
- bugfixes & style improvements
- Added Debugging for SMTP Connection

>>>>>>> Stashed changes
# Version 1.4.0
- Added Reminder Email to be sent out after 7 days of inactivity with still pending reviews.
- Added Revision Number on Output Documents
- Functionality for user to revert Document to Draft Phase after it was already approved (for fixing typos etc.)
- Added downloadable How-To Guide
- Added Cover Sheet Generation
- Status now explicitly listed on Status Overview Page
- various bugfixes

# Version 1.0
- Initial App
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<img src="https://raw.githubusercontent.com/sitcomlab/Ethics-app/dev/documentation/logo.png" alt="Ethics-app" title="Ethics-app" align="right" height="250" width="250"/>

# Ethics-app

Ethics-application for the approval of user-studies
Expand Down
61 changes: 31 additions & 30 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
{
"name": "ethics-app",
"version": "0.0.1",
"authors": [
"Nicholas Schiestel <[email protected]>"
],
"description": "Ethics-App for the Institute for Geoinformatics, Münster",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.6.4",
"angular-momentjs": "^0.2.2",
"angular-route": "1.6.4",
"angular-sanitize": "1.6.4",
"angular-translate": "^2.11.1",
"bootstrap": "v4.0.0-alpha.6",
"font-awesome": "^4.6.3",
"jquery": "^3.1.0",
"moment": "^2.14.1",
"tether": "^1.3.7",
"flag-icon-css": "^2.0.0",
"underscore": "^1.8.3",
"angular-underscore-module": "^1.0.3",
"angucomplete-alt": "^3.0.0"
},
"resolutions": {
"angular": "1.6.4",
"angular-route": "1.6.4",
"angular-sanitize": "1.6.4",
"bootstrap": "v4.0.0-alpha.6"
}
"name": "ethics-app",
"version": "0.0.1",
"authors": [
"Nicholas Schiestel <[email protected]>"
],
"description": "Ethics-App for the Institute for Geoinformatics, Münster",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.6.4",
"angular-momentjs": "^0.2.2",
"angular-route": "1.6.4",
"angular-sanitize": "1.6.4",
"angular-translate": "^2.11.1",
"bootstrap": "v4.0.0-alpha.6",
"font-awesome": "^4.6.3",
"jquery": "^3.1.0",
"moment": "^2.14.1",
"tether": "^1.3.7",
"flag-icon-css": "^2.0.0",
"underscore": "^1.8.3",
"angular-underscore-module": "^1.0.3",
"angucomplete-alt": "^3.0.0",
"angular-upload": "^1.0.12"
},
"resolutions": {
"angular": "1.6.4",
"angular-route": "1.6.4",
"angular-sanitize": "1.6.4",
"bootstrap": "v4.0.0-alpha.6"
}
}
3 changes: 2 additions & 1 deletion controllers/comments/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ exports.request = function(req, res) {
req.body.q11_1_comment,
req.body.q11_2_comment,
req.body.q12_comment,
req.body.q13_comment
req.body.q13_comment,
req.body.q14_comment
], function(err, result) {
done();
if (err) {
Expand Down
4 changes: 3 additions & 1 deletion controllers/concerns/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ exports.request = function(req, res) {
q12_value: req.body.q12_value,
q12_explanation: req.body.q12_explanation,
q13_value: req.body.q13_value,
q13_explanation: req.body.q13_explanation
q13_explanation: req.body.q13_explanation,
q14_value: req.body.q14_value,
q14_explanation: req.body.q14_explanation
};
var params = _.values(object);
callback(null, client, done, params);
Expand Down
76 changes: 76 additions & 0 deletions controllers/concerns/upload_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
var async = require('async');
var colors = require('colors');
var pg = require('pg');
var types = require('pg').types;
types.setTypeParser(1700, 'text', parseFloat);
var _ = require('underscore');
var pool = require('../../server.js').pool;

var fs = require("fs");
var dir = "/../../sql/queries/concerns/";
var query_get_concern = fs.readFileSync(__dirname + dir + 'get.sql', 'utf8').toString();
var query_add_file = fs.readFileSync(__dirname + dir + 'set_uploaded_file.sql', 'utf8').toString();


// EDIT
exports.upload = function(req, res) {

async.waterfall([
function(callback){
// Connect to database
pool.connect(function(err, client, done) {
if(err) {
callback(err, 500);
} else {
callback(null, client, done);
}
});
},
function(client, done, callback) {
// Database query
client.query(query_get_concern, [
req.params.concern_id
], function(err, result) {
done();
if (err) {
callback(err, 500);
} else {
// Check if Concern exists
if (result.rows.length === 0) {
callback(new Error("Concern not found"), 404);
} else {
callback(null, client, done);
}
}
});
},
function(client, done, callback) {
// TODO: Add object/schema validation
var object = {
concern_id: req.params.concern_id,
q14_filename: req.file.originalname,
q14_filepath: '/files/custom/' + req.headers['x-documentid'] + "/" + req.file.filename
};
var params = _.values(object);
callback(null, client, done, params);
},
function(client, done, params, callback){
// Database query
client.query(query_add_file, params, function(err, result) {
done();
if (err) {
callback(err, 500);
} else {
callback(null, 200, params[2], result.rows[0]);
}
});
}
], function(err, code, destination, result) {
if(err){
console.error(colors.red(err));
res.status(code).send(err.message);
} else {
res.status(code).send(destination);
}
});
};
8 changes: 6 additions & 2 deletions controllers/documents/change_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ exports.request = function(req, res) {
concern.q12_value,
concern.q12_explanation,
concern.q13_value,
concern.q13_explanation
concern.q13_explanation,
concern.q14_value,
concern.q14_explanation,
concern.q14_filename,
concern.q14_filepath
], function(err, result) {
done();
if (err) {
Expand Down Expand Up @@ -399,7 +403,7 @@ exports.request = function(req, res) {
html: output
}, function(err, info) {
if (err) {
callback(err);
callback(err, 500);
} else {
callback(null, 200, updated_document);
}
Expand Down
13 changes: 13 additions & 0 deletions controllers/documents/generate_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var moment = require('moment');
var pool = require('../../server.js').pool;
var pdf = require('html-pdf');
var uuid = require("uuid");
var crypto = require('crypto');

var fs = require("fs");
var dir_1 = "/../../templates/pdfs/";
Expand Down Expand Up @@ -163,11 +164,23 @@ exports.request = function(req, res) {
// Create files
async.parallel([
function(callback) { // Generate Cover Sheet

// create distinguishable password
var psw = crypto.randomBytes(32)
.toString('base64')
.replace("1","R")
.replace("I","A")
.replace("0","M")
.replace("O","P")
.replace("U","F")
.replace("V","Z")
.replace("Q","X");
// Render HTML-content
var html = mustache.render(template_cover_sheet, {
document: document,
description: description,
revision: revision,
veracryptpassword: psw,
year: moment().format("YYYY")
});

Expand Down
15 changes: 13 additions & 2 deletions controllers/documents/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ exports.request = function(req, res) {
callback(null, client, done, document, course, revision, description, concern, 3);
} else if(concern.q13_value){
callback(null, client, done, document, course, revision, description, concern, 3);
} else if(concern.q14_value){
callback(null, client, done, document, course, revision, description, concern, 3);
} else {
// Check if document has been already in review
if(document.status === 5){
Expand Down Expand Up @@ -373,6 +375,14 @@ exports.request = function(req, res) {
concern.q13_label = "badge-success";
concern.q13_sign = "no";
}

if(concern.q14_value){
concern.q14_label = "badge-danger";
concern.q14_sign = "yes";
} else {
concern.q14_label = "badge-success";
concern.q14_sign = "no";
}

// Notify each committee member
async.eachOfSeries(members, function (member, key, callback) {
Expand Down Expand Up @@ -401,9 +411,10 @@ exports.request = function(req, res) {
address: process.env.SENDER_EMAIL_ADDRESS
},
to: member.email_address,
subject: "[Ethics-App] A document needs your review",
subject: "[Ethics-App] A Study needs your review - Study Title: " + description.en_title,
text: text,
html: output
html: output,
messageId: document.document_id + "[email protected]"
}, function(err, info) {
if (err) {
callback(err);
Expand Down
Loading

0 comments on commit 02522d7

Please sign in to comment.