From 16b2dab8c2a384ccb95fca048414f33daf3925a8 Mon Sep 17 00:00:00 2001 From: HumairAK Date: Mon, 25 Jul 2016 04:51:37 -0400 Subject: added warning message for adding solution while not logged in --- assets/css/creative.css | 7 ++ assets/css/style.css | 2 +- node_simple.js | 3 - routes/index.js | 1 + routes/user.js | 9 ++- views/user_solutions.hbs | 173 ++++++++++++++++++++++++----------------------- 6 files changed, 102 insertions(+), 93 deletions(-) diff --git a/assets/css/creative.css b/assets/css/creative.css index 54e1cbb..45f388b 100644 --- a/assets/css/creative.css +++ b/assets/css/creative.css @@ -376,5 +376,12 @@ header .header-content .header-content-inner hr { background-color: #d9edf7; color: #3170a6; } +/******************Alert Changes**************/ +.custom-Alert{ + text-align: center; + margin: 30px 12% 30px 12%; + box-shadow: 2px 4px 5px 0 rgba(0,0,0,0.1); +} + /********************************************/ diff --git a/assets/css/style.css b/assets/css/style.css index 91d75c4..160076a 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -51,7 +51,7 @@ main .search h2{ box-sizing: border-box; background: white url('../images/search_icon.png') no-repeat 9px 9px; background-size: 20px 20px; - padding: 12px 20px 12px 40px; + padding: 0; } .search input, .search button.search-button { diff --git a/node_simple.js b/node_simple.js index 2eab34c..165eb22 100644 --- a/node_simple.js +++ b/node_simple.js @@ -330,7 +330,6 @@ exports.retrieve_userComments_history = function (username, callback) { // get a connection mongoFactory.getConnection(uri).then(function (db) { - console.log("for Each here"); var solutions = db.collection('solutions'); var exams = db.collection('exams'); var mylist = []; @@ -367,9 +366,7 @@ exports.retrieve_userComments_history = function (username, callback) { }); function doCall() { - console.log("Am i inside the doCall()"); callback(true, mylist); - console.log("IN NODE SIMPLE: " + mylist); } diff --git a/routes/index.js b/routes/index.js index 283b196..6218dd1 100644 --- a/routes/index.js +++ b/routes/index.js @@ -201,6 +201,7 @@ router.get('/solutions/:exam_id/:q_num', function (req, res) { soln.commentCount = soln.comments.length; }); res.render('user_solutions', {query: solutions, examID: examID, qID: qID, csrfToken: req.csrfToken()}); + req.session.messages = null; }); }); diff --git a/routes/user.js b/routes/user.js index f9487ea..68fee21 100644 --- a/routes/user.js +++ b/routes/user.js @@ -23,7 +23,6 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { var comments = []; var inbox = []; function getComments() { - console.log('in getComments'); return new Promise(function(resolve, reject) { dbFile.retrieve_userComments_history(req.user.user_name, function (success, object) { if (!success) { @@ -55,7 +54,6 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { }); } function getMail(){ - console.log('ing getMail'); return new Promise(function(resolve, reject) { dbFile.checkMailbox(req.user.user_name, function(success, error, data, message){ @@ -82,7 +80,6 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { }); } getComments().then(getMail).then(function (data) { - console.log('got here'); res.render('user_profile_alt', {comments : comments, inbox: inbox, csrfToken: req.csrfToken()}); }); @@ -138,7 +135,9 @@ router.get('/add_solution/:examID/:qID', function (req, res, next) { if(req.isAuthenticated()){ res.render('add_solutions', {csrfToken: req.csrfToken(), examID: examID, qID: qID}); } else { - res.redirect('/'); // Change this to go back to the solutions page + var message = "Must be logged in to add a solution!"; + req.session.messages = {error : message}; + res.redirect('/solutions/' + examID + '/' + qID); } }); @@ -232,7 +231,7 @@ router.post('/user_profile/send_message', loggedIn, function(req, res, next) { date: current_date }; - console.log(mail_data); + //console.log(mail_data); dbFile.sendMail(mail_data, function(success, error, message) { if ((!success && !error) || (error)) { req.session.messages = {error : message}; diff --git a/views/user_solutions.hbs b/views/user_solutions.hbs index b00b098..db17aa6 100644 --- a/views/user_solutions.hbs +++ b/views/user_solutions.hbs @@ -2,102 +2,107 @@ + {{/each}} -- cgit v1.2.3