diff options
| -rw-r--r-- | assets/css/creative.css | 7 | ||||
| -rw-r--r-- | assets/css/style.css | 2 | ||||
| -rw-r--r-- | node_simple.js | 3 | ||||
| -rw-r--r-- | routes/index.js | 1 | ||||
| -rw-r--r-- | routes/user.js | 9 | ||||
| -rw-r--r-- | 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 @@ <div class='search solutions-container container'> <div> -<!-- Add Solution button and path --> -<div class="row top-sol"> - <a href="/user/add_solution/{{examID}}/{{qID}}"> - <button class="col-xs-4 col-sm-2 col-md-2 col-lg-2 - col-xs-offset-4 col-sm-offset-5 col-md-offset-2 - col-lg-offset-2 rounded" id="add-solution"> - <h3>Add a solution</h3> - </button> - </a> + {{# if messages.error }} + <section class="alert alert-danger custom-Alert"> + <h5>{{ messages.error }}</h5> + </section> + {{/if}} - <!-- Replace p below with breadcrumbs later --> - <p class="col-xs-12 col-sm-12 col-md-6 show-path"> - CSC148 > Winter 2015 > Question 1 - </p> -</div> + <!-- Add Solution button and path --> + <div class="row top-sol"> + <a href="/user/add_solution/{{examID}}/{{qID}}"> + <button class="col-xs-4 col-sm-2 col-md-2 col-lg-2 + col-xs-offset-4 col-sm-offset-5 col-md-offset-2 + col-lg-offset-2 rounded" id="add-solution"> + <h3>Add a solution</h3> + </button> + </a> -<!-- Solution 1 Example --> -{{#each query}} - <div class="row"> - <section id="sol-" class="col-md-10 col-md-offset-1 rounded"> - <div class="post-info"> - <div class=""> - <img class="img-responsive img-circle user-image" src="/assets/images/misc/user1.jpeg"> - <p class="username">{{this.author}}</p> - </div> + <!-- Replace p below with breadcrumbs later --> + <p class="col-xs-12 col-sm-12 col-md-6 show-path"> + CSC148 > Winter 2015 > Question 1 + </p> + </div> - <div class="pull-right"> - <div class="voting"> - <form action="/user/solution/vote/{{../examID}}/{{../qID}}/{{this._id}}" method="post"> - <input type="hidden" name="vote" value="up"/> - <button class="upvote" type="submit"><img src="/assets/images/up_arrow.png"></button> - <input type="hidden" name="_csrf" value="{{../csrfToken }}"> - </form> - <form action="/user/solution/vote/{{../examID}}/{{../qID}}/{{this._id}}" method="post"> - <input type="hidden" name="vote" value="down"/> - <button class="downvote"><img src="/assets/images/down_arrow.png"></button> - <input type="hidden" name="_csrf" value="{{../csrfToken }}"> - </form> - <p class="num-votes">{{this.votes}}</p> + <!-- Solution 1 Example --> + {{#each query}} + <div class="row"> + <section id="sol-" class="col-md-10 col-md-offset-1 rounded"> + <div class="post-info"> + <div class=""> + <img class="img-responsive img-circle user-image" src="/assets/images/misc/user1.jpeg"> + <p class="username">{{this.author}}</p> </div> - </div> - </div> - <div class="user-sol"> - <h3>Solution</h3> - <p>{{this.text}}</p> - </div> + <div class="pull-right"> + <div class="voting"> + <form action="/user/solution/vote/{{../examID}}/{{../qID}}/{{this._id}}" method="post"> + <input type="hidden" name="vote" value="up"/> + <button class="upvote" type="submit"><img src="/assets/images/up_arrow.png"></button> + <input type="hidden" name="_csrf" value="{{../csrfToken }}"> + </form> + <form action="/user/solution/vote/{{../examID}}/{{../qID}}/{{this._id}}" method="post"> + <input type="hidden" name="vote" value="down"/> + <button class="downvote"><img src="/assets/images/down_arrow.png"></button> + <input type="hidden" name="_csrf" value="{{../csrfToken }}"> + </form> + <p class="num-votes">{{this.votes}}</p> + </div> + </div> + </div> - <div class="comments"> - <h3> - <a data-toggle="collapse" href="#com{{@index}}"> - <span> - {{this.commentCount}} - </span> - comments - <span class="caret"></span> - </a> - </h3> + <div class="user-sol"> + <h3>Solution</h3> + <p>{{this.text}}</p> + </div> - <div id="com{{@index}}" class="panel-collapse collapse"> - <ul class="list-group"> - {{#each this.comments}} - <li class="list-group-item"> - <img src="/assets/images/misc/user3.jpeg" - class="img-responsive img-circle comment-user-img"> - <p class="comment-username"> - <a href="/user_profile"> - {{this.by}} - </a> - , {{this.date}} - </p> - <p class="user-comment">{{this.text}}</p> - </li> - {{/each}} + <div class="comments"> + <h3> + <a data-toggle="collapse" href="#com{{@index}}"> + <span> + {{this.commentCount}} + </span> + comments + <span class="caret"></span> + </a> + </h3> - <form action="/user/comment/submit/{{../examID}}/{{../qID}}/{{this._id}}" method="post"> - <div class="form-group"> - <textarea type="text" - class="form-control" - placeholder="Enter comment" - name="comment"> + <div id="com{{@index}}" class="panel-collapse collapse"> + <ul class="list-group"> + {{#each this.comments}} + <li class="list-group-item"> + <img src="/assets/images/misc/user3.jpeg" + class="img-responsive img-circle comment-user-img"> + <p class="comment-username"> + <a href="/user_profile"> + {{this.by}} + </a> + , {{this.date}} + </p> + <p class="user-comment">{{this.text}}</p> + </li> + {{/each}} - </textarea> - </div> - <input type="hidden" name="_csrf" value="{{../csrfToken }}"> - <button type="submit" class="btn btn-primary">Submit</button> - </form> + <form action="/user/comment/submit/{{../examID}}/{{../qID}}/{{this._id}}" method="post"> + <div class="form-group"> + <textarea type="text" + class="form-control" + placeholder="Enter comment" + name="comment"> - </ul> - </div> + </textarea> + </div> + <input type="hidden" name="_csrf" value="{{../csrfToken }}"> + <button type="submit" class="btn btn-primary">Submit</button> + </form> - </div> - </section> - </div> -{{/each}} + </ul> + </div> + </div> + </section> + </div> + {{/each}} </div> </div> |
