From e23398999a4efd3e372c4846af99c2576d6883b2 Mon Sep 17 00:00:00 2001 From: Yaman Qalieh Date: Thu, 1 Sep 2016 00:13:17 -0400 Subject: [PATCH 1/5] fix #76 --- hourglass/lib/router.js | 8 ++++---- hourglass/server/main.js | 30 ++++++++++-------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/hourglass/lib/router.js b/hourglass/lib/router.js index 864468f..7190bfa 100644 --- a/hourglass/lib/router.js +++ b/hourglass/lib/router.js @@ -1,6 +1,6 @@ Router.route('/', { waitOn: function() { - if (!Meteor.userId()) { + if (!Meteor.userId() || !Meteor.user().profile.school) { this.redirect('/login'); } else { return [ @@ -12,7 +12,7 @@ Router.route('/', { ]; } }, - action: function() { + action: function() { this.render("main"); } }); @@ -20,7 +20,7 @@ Router.route('/', { Router.route('/login', function() { if (!Meteor.userId()) { this.render("login"); - } else if (Object.keys(Meteor.user().profile).length <= 1) { + } else if (!Meteor.user().profile.school) { this.redirect('/profile'); } else { this.redirect('/'); @@ -67,4 +67,4 @@ Router.route('/admin', { Router.configure({ notFoundTemplate: "NotFound" -}); \ No newline at end of file +}); diff --git a/hourglass/server/main.js b/hourglass/server/main.js index e04972b..e13060b 100644 --- a/hourglass/server/main.js +++ b/hourglass/server/main.js @@ -7,7 +7,6 @@ import { } from 'meteor/mongo'; // Defines who the admins are - not added - var superadmins = [ "ybq987@gmail.com", "ksjdragon@gmail.com", @@ -40,14 +39,14 @@ Meteor.publish('classes', function() { return classes.find(); } else { // Return user classes and all _public_ classes. - var userprofile = Meteor.users.findOne(this.userId).profile; - if (userprofile !== undefined && userprofile.classes !== undefined) { + var userprofile = Meteor.users.findOne(this.userId); + if (userprofile !== undefined && userprofile.profile.classes !== undefined) { return classes.find({ $or: [{ privacy: false }, { _id: { - $in: userprofile.classes + $in: userprofile.profile.classes } }] }, { @@ -67,11 +66,8 @@ Meteor.publish('classes', function() { } }); } else { - var empty; - Meteor.call('createProfile', this.userId, function(error, result) { - empty = result; - }); - return result; + Meteor.call('createProfile', this.userId); + return classes.find({_id: null}); } } }); @@ -82,20 +78,17 @@ Meteor.publish('work', function() { if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) { return work.find(); } else { - var userprofile = Meteor.users.findOne(this.userId).profile; - if (userprofile !== undefined && userprofile.classes !== undefined) { + var userprofile = Meteor.users.findOne(this.userId); + if (userprofile !== undefined && userprofile.profile.classes !== undefined) { return work.find({ // Only return work of enrolled classes class: { - $in: userprofile.classes + $in: userprofile.profile.classes } }); } else { - var empty; - Meteor.call('createProfile', this.userId, function(error, result) { - empty = result; - }); - return result; + Meteor.call('createProfile', this.userId); + return classes.find({_id: null}); } } @@ -518,9 +511,6 @@ Meteor.methods({ profile: current } }); - return classes.find({ - _id: null - }); }, 'joinClass': function(input) { var change = input[0]; From a0d277001e04d6184d656c8aaa91718964b29130 Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Thu, 1 Sep 2016 00:23:22 -0400 Subject: [PATCH 2/5] Fixed issue #77 --- hourglass/client/login/login.css | 4 +--- hourglass/client/main/main.js | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hourglass/client/login/login.css b/hourglass/client/login/login.css index d18e05d..aa20031 100644 --- a/hourglass/client/login/login.css +++ b/hourglass/client/login/login.css @@ -123,9 +123,7 @@ p.text { bottom: 0; } -.login-button { - display: none !important; -} + #github { font-size: 150%; diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js index 3053617..7099cf1 100644 --- a/hourglass/client/main/main.js +++ b/hourglass/client/main/main.js @@ -164,6 +164,7 @@ Template.registerHelper('pref', (val) => { // Obtains all user preferences. Template.main.helpers({ schoolName() { // Finds the name of the user's school. + if(Meteor.user().profile.school === undefined) return; return " - " + Meteor.user().profile.school; }, iconColor(icon) { // Sidebar status color @@ -279,6 +280,7 @@ Template.main.helpers({ if(jsEvent.target.className.includes("fc-past")) return; calCreWork = true; calWorkDate = date.format(); + Session.set("newWork", true); Session.set("sidebar","menuContainer"); } }; @@ -782,7 +784,7 @@ function closeDivFade(div) { function sendData(funcName) { // Call Meteor function, and do actions after function is completed depending on function. Meteor.call(funcName, serverData , function(err,result) { - if((funcName === "editWork" || funcName === "createWork") && Session.get("mode") === "calendar") { + if((funcName === "editWork" || funcName === "createWork" || funcName === "deleteWork") && Session.get("mode") === "calendar") { $("#fullcalendar").fullCalendar( 'refetchEvents' ); } else if(funcName === "toggleWork") { var workId = Session.get("currentWork")._id; From 3282d861ff57302f975bdcd526e4eaf78357f137 Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Thu, 1 Sep 2016 00:28:10 -0400 Subject: [PATCH 3/5] Display fixes --- hourglass/client/profile/profile.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hourglass/client/profile/profile.css b/hourglass/client/profile/profile.css index 2e941b6..e9b43b4 100644 --- a/hourglass/client/profile/profile.css +++ b/hourglass/client/profile/profile.css @@ -420,7 +420,7 @@ #mainpage, #logout2 { font-size: 90%; - padding: 0; + padding: 0.3%; background-color: #617C9E; box-shadow: -1px 2px 5px 1px #333; @@ -441,7 +441,8 @@ top: 0; left: 85%; } -#mainpage:active,#logout2:active { + +#mainpage:active, #logout2:active { background-color: #56708D; } From 7abb353961df2eb4d678d2f6c5d6b52848991305 Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Thu, 1 Sep 2016 00:30:05 -0400 Subject: [PATCH 4/5] Removed school checking, as client is changed to display nothing if undefined --- hourglass/lib/router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hourglass/lib/router.js b/hourglass/lib/router.js index 7190bfa..b85af25 100644 --- a/hourglass/lib/router.js +++ b/hourglass/lib/router.js @@ -1,6 +1,6 @@ Router.route('/', { waitOn: function() { - if (!Meteor.userId() || !Meteor.user().profile.school) { + if (!Meteor.userId()) { this.redirect('/login'); } else { return [ From ed6a59470504e250181bcd49a148f5397e688edf Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Thu, 1 Sep 2016 00:30:49 -0400 Subject: [PATCH 5/5] CSS Reversion --- hourglass/client/login/login.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hourglass/client/login/login.css b/hourglass/client/login/login.css index aa20031..2d6296a 100644 --- a/hourglass/client/login/login.css +++ b/hourglass/client/login/login.css @@ -123,7 +123,9 @@ p.text { bottom: 0; } - +.login-buttons { + display: none !important; +} #github { font-size: 150%;