11import Checkit from 'checkit'
22import Promise from 'bluebird'
33import { linkAgreementAndPersonRole , unlinkAgreementAndPersonRole } from '../services/RoleService'
4+ import logger from '../util/logger'
45
56const thesisService = require ( '../services/ThesisService' )
67const agreementService = require ( '../services/AgreementService' )
@@ -75,15 +76,16 @@ async function validateThesis(thesis) {
7576}
7677
7778export async function saveThesisForm ( req , res ) {
79+ logger . info ( "Starting saveThesisForm" )
7880 const thesis = JSON . parse ( req . body . json )
7981
8082 await validateThesis ( thesis )
81-
83+ logger . info ( "Thesis validated" )
8284 const response = await knex . transaction ( async ( trx ) => {
8385 // TODO refactor!!!
84-
86+ logger . info ( "Checking user rights for adding" )
8587 await permissionService . checkUserHasRightToAddAgreement ( req , thesis . studyfieldId )
86-
88+ logger . info ( "User rights ok" )
8789 // Order so that agreementId is available to save attachments.
8890 const agreement = await agreementService . createFakeAgreement ( trx )
8991 const attachments = await attachmentService . saveAttachmentFiles ( req . files , agreement . agreementId , trx )
@@ -100,11 +102,12 @@ export async function saveThesisForm(req, res) {
100102 // TODO: Add email to new email send table
101103 delete thesis . thesisEmails
102104 delete thesis . authorEmail
103-
105+ logger . info ( "Updating graders" )
104106 if ( thesis . graders ) {
105107 await updateGraders ( thesis . graders , agreement , trx )
106108 delete thesis . graders
107109 }
110+ logger . info ( "Saving thesis" )
108111 const savedThesis = await thesisService . saveThesis ( thesis , trx )
109112
110113 // Agreement was missing the thesisId completing linking.
0 commit comments