Skip to content

Commit 4cc800b

Browse files
committed
Implemented diff #52
1 parent 820a03c commit 4cc800b

37 files changed

+3165
-2631
lines changed

controllers/documents/change_status.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ exports.request = function(req, res) {
6161
} else {
6262
if(decoded.member || req.body.status == 1){
6363
callback(null, client, done);
64-
} else {
64+
} else {
6565
callback(new Error("Authorization failed"), 401);
6666
}
6767
}
@@ -340,6 +340,14 @@ exports.request = function(req, res) {
340340
var status_description_2 = "";
341341

342342
switch (updated_document.status) {
343+
case 1: {
344+
icon = "fa-pencil-square-o";
345+
status_description_1 = "You reverted your document and can now modify it. Please note that a reverted document has to be submitted and approved again.";
346+
status_description_2 = "If you have problems with your document, please get in touch with a committee member of your institute.";
347+
updated_document._status_label = "badge-info";
348+
updated_document._status_description = "unsubmitted";
349+
break;
350+
}
343351
case 4: {
344352
icon = "fa-eye";
345353
status_description_1 = "Your document is under review now. You will get another email as soon as the Ethics-committee has reviewed it completely.";

controllers/documents/get_v2.js

+416
Large diffs are not rendered by default.

controllers/documents/submit.js

+36-34
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ exports.request = function(req, res) {
173173
} else if(concern.q14_value){
174174
callback(null, client, done, document, course, revision, description, concern, 3);
175175
} else {
176-
// Check if document has been already in review
176+
// Check if document has already been in review
177177
if(document.status === 5){
178178
callback(null, client, done, document, course, revision, description, concern, 3);
179179
} else {
@@ -258,129 +258,130 @@ exports.request = function(req, res) {
258258
}
259259
},
260260
function(client, done, document, course, revision, description, concern, author, members, callback){
261+
261262
// Check status to notify members, in case of a review
262263
if(document.status === 2){
263264
callback(null, 204, null);
264265
} else {
265266

266267
// Formatting
267268
if(concern.q01_value){
268-
concern.q01_label = "badge-danger";
269+
concern.q01_label = "badge-warning";
269270
concern.q01_sign = "yes";
270271
} else {
271-
concern.q01_label = "badge-success";
272+
concern.q01_label = "badge-default";
272273
concern.q01_sign = "no";
273274
}
274275

275276
if(concern.q02_value){
276-
concern.q02_label = "badge-danger";
277+
concern.q02_label = "badge-warning";
277278
concern.q02_sign = "yes";
278279
} else {
279-
concern.q02_label = "badge-success";
280+
concern.q02_label = "badge-default";
280281
concern.q02_sign = "no";
281282
}
282283

283284
if(concern.q03_value){
284-
concern.q03_label = "badge-danger";
285+
concern.q03_label = "badge-warning";
285286
concern.q03_sign = "yes";
286287
} else {
287-
concern.q03_label = "badge-success";
288+
concern.q03_label = "badge-default";
288289
concern.q03_sign = "no";
289290
}
290291

291292
if(concern.q04_value){
292-
concern.q04_label = "badge-danger";
293+
concern.q04_label = "badge-warning";
293294
concern.q04_sign = "yes";
294295
} else {
295-
concern.q04_label = "badge-success";
296+
concern.q04_label = "badge-default";
296297
concern.q04_sign = "no";
297298
}
298299

299300
if(concern.q05_value){
300-
concern.q05_label = "badge-danger";
301+
concern.q05_label = "badge-warning";
301302
concern.q05_sign = "yes";
302303
} else {
303-
concern.q05_label = "badge-success";
304+
concern.q05_label = "badge-default";
304305
concern.q05_sign = "no";
305306
}
306307

307308
if(concern.q06_value){
308-
concern.q06_label = "badge-danger";
309+
concern.q06_label = "badge-warning";
309310
concern.q06_sign = "yes";
310311
} else {
311-
concern.q06_label = "badge-success";
312+
concern.q06_label = "badge-default";
312313
concern.q06_sign = "no";
313314
}
314315

315316
if(concern.q07_value){
316-
concern.q07_label = "badge-danger";
317+
concern.q07_label = "badge-warning";
317318
concern.q07_sign = "yes";
318319
} else {
319-
concern.q07_label = "badge-success";
320+
concern.q07_label = "badge-default";
320321
concern.q07_sign = "no";
321322
}
322323

323324
if(concern.q08_value){
324-
concern.q08_label = "badge-danger";
325+
concern.q08_label = "badge-warning";
325326
concern.q08_sign = "yes";
326327
} else {
327-
concern.q08_label = "badge-success";
328+
concern.q08_label = "badge-default";
328329
concern.q08_sign = "no";
329330
}
330331

331332
if(concern.q09_value){
332-
concern.q09_label = "badge-danger";
333+
concern.q09_label = "badge-warning";
333334
concern.q09_sign = "yes";
334335
} else {
335-
concern.q09_label = "badge-success";
336+
concern.q09_label = "badge-default";
336337
concern.q09_sign = "no";
337338
}
338339

339340
if(concern.q10_value){
340-
concern.q10_label = "badge-danger";
341+
concern.q10_label = "badge-warning";
341342
concern.q10_sign = "yes";
342343
} else {
343-
concern.q10_label = "badge-success";
344+
concern.q10_label = "badge-default";
344345
concern.q10_sign = "no";
345346
}
346347

347348
if(concern.q11_1_value){
348-
concern.q11_1_label = "badge-danger";
349+
concern.q11_1_label = "badge-warning";
349350
concern.q11_1_sign = "yes";
350351
} else {
351-
concern.q11_1_label = "badge-success";
352+
concern.q11_1_label = "badge-default";
352353
concern.q11_1_sign = "no";
353354
}
354355

355356
if(concern.q11_2_value){
356-
concern.q11_2_label = "badge-danger";
357+
concern.q11_2_label = "badge-warning";
357358
concern.q11_2_sign = "yes";
358359
} else {
359-
concern.q11_2_label = "badge-success";
360+
concern.q11_2_label = "badge-default";
360361
concern.q11_2_sign = "no";
361362
}
362363

363364
if(concern.q12_value){
364-
concern.q12_label = "badge-danger";
365+
concern.q12_label = "badge-warning";
365366
concern.q12_sign = "yes";
366367
} else {
367-
concern.q12_label = "badge-success";
368+
concern.q12_label = "badge-default";
368369
concern.q12_sign = "no";
369370
}
370371

371372
if(concern.q13_value){
372-
concern.q13_label = "badge-danger";
373+
concern.q13_label = "badge-warning";
373374
concern.q13_sign = "yes";
374375
} else {
375-
concern.q13_label = "badge-success";
376+
concern.q13_label = "badge-default";
376377
concern.q13_sign = "no";
377378
}
378-
379+
379380
if(concern.q14_value){
380-
concern.q14_label = "badge-danger";
381+
concern.q14_label = "badge-warning";
381382
concern.q14_sign = "yes";
382383
} else {
383-
concern.q14_label = "badge-success";
384+
concern.q14_label = "badge-default";
384385
concern.q14_sign = "no";
385386
}
386387

@@ -411,17 +412,18 @@ exports.request = function(req, res) {
411412
address: process.env.SENDER_EMAIL_ADDRESS
412413
},
413414
to: member.email_address,
414-
subject: "[Ethics-App] A Study needs your review - Study Title: " + description.en_title,
415+
subject: "[Ethics-App] A document needs your review - Study title: " + description.en_title,
415416
text: text,
416417
html: output,
417418
messageId: document.document_id + "[email protected]"
418419
}, function(err, info) {
419420
if (err) {
420421
callback(err);
421422
} else {
422-
callback();
423+
callback(null);
423424
}
424425
});
426+
callback(null);
425427

426428
}, function(err){
427429
callback(null, 204, null);

controllers/recovery/find_user_by_email.js

+31-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ var fs = require("fs");
1515
var dir_1 = "/../../templates/emails/";
1616
var dir_2 = "/../../sql/queries/users/";
1717
var dir_3 = "/../../sql/queries/documents/";
18+
var dir_4 = "/../../sql/queries/revisions/";
1819
var template_document_recovery = fs.readFileSync(__dirname + dir_1 + 'document_recovery.html', 'utf8').toString();
1920
var query_get_user_by_email = fs.readFileSync(__dirname + dir_2 + 'get_by_email.sql', 'utf8').toString();
2021
var query_list_documents_by_user = fs.readFileSync(__dirname + dir_3 + 'list_by_user.sql', 'utf8').toString();
22+
var query_get_latest_revision_by_document = fs.readFileSync(__dirname + dir_4 + 'get_latest_by_document.sql', 'utf8').toString();
2123

2224

2325
// FIND BY EMAIL
@@ -79,6 +81,33 @@ exports.request = function(req, res) {
7981
}
8082
});
8183
},
84+
function(client, done, user, documents, callback) {
85+
async.eachOfSeries(documents, function (document, key, callback) {
86+
// Database query
87+
client.query(query_get_latest_revision_by_document, [
88+
document.document_id
89+
], function(err, result) {
90+
done();
91+
if (err) {
92+
callback(err, 500);
93+
} else {
94+
// Check if Revision exists
95+
if (result.rows.length === 0) {
96+
callback(new Error("Revision not found"), 404);
97+
} else {
98+
document.latest_revision = result.rows[0];
99+
callback(null);
100+
}
101+
}
102+
});
103+
}, function(err){
104+
if (err) {
105+
callback(err, 500);
106+
} else {
107+
callback(null, client, done, user, documents);
108+
}
109+
});
110+
},
82111
function(client, done, user, documents, callback) {
83112

84113
// Formatting
@@ -148,7 +177,7 @@ exports.request = function(req, res) {
148177
});
149178

150179
// Render text for emails without HTML support
151-
var text = "You asked for your Document-IDs";
180+
var text = "You asked for your document-IDs";
152181

153182
// Send email
154183
transporter.sendMail({
@@ -157,7 +186,7 @@ exports.request = function(req, res) {
157186
address: process.env.SENDER_EMAIL_ADDRESS
158187
},
159188
to: user.email_address,
160-
subject: "[Ethics-App] You asked for your Document-IDs",
189+
subject: "[Ethics-App] You asked for your document-IDs",
161190
text: text,
162191
html: output
163192
}, function(err, info) {

0 commit comments

Comments
 (0)