-
Submit a request for a class to be approved by an administrator.
+
Submit a request for a class to be approved by an administrator.
You can have up to 8 unapproved classes at once.
diff --git a/hourglass/client/profile/profile.js b/hourglass/client/profile/profile.js
index 71e353c..9a55530 100644
--- a/hourglass/client/profile/profile.js
+++ b/hourglass/client/profile/profile.js
@@ -215,22 +215,7 @@ Template.profile.events({
});
Session.set("newClasses", newClasses);
$(".creInput").each(function(){$(this).val('');});
- /*if (!teachers.findOne({
- name: values.teacher
- })) {
- Meteor.call("createTeacher", values.teacher, values.school, function(error, result) {
- if (error !== undefined) {
- sAlert.error(error.message, {
- effect: 'stackslide',
- position: 'top'
- });
- } else {
- sendData("createClass");
- }
- });
- } else {
- sendData("createClass");
- }*/
+
},
'click #backArrow' () {
slideToField(Session.get("sections")[1]-1);
@@ -343,9 +328,10 @@ Template.profile.events({
}
} catch(err) {}
},
- 'click .classBox .fa-plus' (event) {
+ 'click .classBox .fa-plus, click #classBody .classBox' (event) {
var profile = Session.get("profile");
- var id = event.target.parentNode.getAttribute("classid");
+ while(event.target.getAttribute("classid") === null) event.target = event.target.parentNode;
+ var id = event.target.getAttribute("classid");
if(profile.classes.indexOf(id) === -1) {
profile.classes.push(id);
Session.set("profile", profile);
@@ -382,6 +368,74 @@ Template.profile.events({
return b.subscribers - a.subscribers;
}));
}
+ },
+ 'click #profileSubmit' () {
+ // clear html and make page uninteractable
+ var myClasses = Session.get("profile").classes;
+ var newClasses = Session.get("newClasses");
+ var message = "Sorry, your profile couldn't be created. Please try again!";
+
+ _.each(myClasses, function(myClass) {
+ Meteor.call("joinClass", [myClass, ""], function(err, result) {
+ if(err !== undefined) {
+ sAlert.error(message, {
+ effect: 'stackslide',
+ position: 'top'
+ });
+ }
+ })
+ });
+ _.each(newClasses, function(newClass) {
+ if (!teachers.findOne({
+ name: newClass.teacher
+ })) {
+ Meteor.call("createTeacher", newClass.teacher, newClass.school, function(error, result) {
+ if (error !== undefined) {
+ sAlert.error(message, {
+ effect: 'stackslide',
+ position: 'top'
+ });
+ } else {
+ Meteor.call("createClass", newClass, function(error, result) {
+ if(error !== undefined) {
+ sAlert.error(message, {
+ effect: 'stackslide',
+ position: 'top'
+ });
+ }
+ });
+ }
+ });
+ } else {
+ Meteor.call("createClass", newClass, function(error, result) {
+ if(error !== undefined) {
+ sAlert.error(message, {
+ effect: 'stackslide',
+ position: 'top'
+ });
+ }
+ });
+ }
+ });
+ var profile = Session.get("profile");
+ profile.complete = true;
+ profile.preferences = Meteor.user().profile.preferences;
+ profile.classes.push(Meteor.userId());
+ Meteor.call("editProfile", profile, function(err, result) {
+ if(err !== undefined) {
+ sAlert.error(message, {
+ effect: 'stackslide',
+ position: 'top'
+ });
+ }
+ Meteor.subscribe('classes');
+ Meteor.subscribe('schools');
+ Meteor.subscribe('teachers');
+ Meteor.subscribe('work');
+ Meteor.subscribe('requests');
+ Meteor.subscribe("personalUser");
+ Meteor.subscribe('users');
+ });
}
});
diff --git a/hourglass/lib/adminConfig.js b/hourglass/lib/adminConfig.js
index 82fb376..f56c4f3 100644
--- a/hourglass/lib/adminConfig.js
+++ b/hourglass/lib/adminConfig.js
@@ -77,6 +77,7 @@ AdminConfig = {
{ label: 'Name', name: 'profile.name' },
{ label: 'School', name: 'profile.school' },
{ label: 'Graduation Year', name:'profile.grade' },
+ { label: 'Complete', name:'profile.complete'},
{ label: 'Icon', name: '_id', template: 'adminUserDisplay' },
],
templates: {
@@ -98,6 +99,7 @@ AdminConfig = {
{ label: 'Name', name: 'profile.name' },
{ label: 'School', name: 'profile.school' },
{ label: 'Graduation Year', name:'profile.grade' },
+ { label: 'Complete', name:'profile.complete'},
{ label: 'Icon', name: '_id', template: 'adminUserDisplay' },
],
templates: {
diff --git a/hourglass/lib/constants.js b/hourglass/lib/constants.js
index 1af0f98..1f5733a 100644
--- a/hourglass/lib/constants.js
+++ b/hourglass/lib/constants.js
@@ -1,14 +1,14 @@
themeColors = {
"lux": {
"background": "White.jpg",
- "mainColor": "#DBDBDB",
- "secondaryColor": "#567393",
- "sidebarColor": "#6C94B4",
- "userDropdownColor": "#E6E6E6",
- "iconHighlight": "#FFF",
- "modeHighlight": "#D34949",
- "classCardColor":"#EBEBEB",
- "textColor": "#000"
+ "mainColor": "#4D82AC",
+ "secondaryColor": "#4C75A2",
+ "sidebarColor": "#5E88A8",
+ "userDropdownColor": "#427EB4",
+ "iconHighlight": "#39CAFF",
+ "modeHighlight": "#F02C2C",
+ "classCardColor":"#5D86A8",
+ "textColor": "#FFF"
},
"nox": {
"background": "Black.jpg",
diff --git a/hourglass/lib/router.js b/hourglass/lib/router.js
index be739f1..c824811 100644
--- a/hourglass/lib/router.js
+++ b/hourglass/lib/router.js
@@ -8,26 +8,30 @@ function completeProfile() {
Router.route('/', {
waitOn: function() {
+ if(!Meteor.userId()) {
+ return;
+ }
+ return [
+ Meteor.subscribe('classes', this.params._id),
+ Meteor.subscribe('schools', this.params._id),
+ Meteor.subscribe('teachers', this.params._id),
+ Meteor.subscribe('work', this.params._id),
+ Meteor.subscribe('requests', this.params._id),
+ Meteor.subscribe('personalUser', this.params._id),
+ Meteor.subscribe('users', this.params._id)
+ ];
+ },
+ action: function() {
if (!Meteor.userId() || !completeProfile()) {
this.redirect('/login');
} else {
- return [
- Meteor.subscribe('classes', this.params._id),
- Meteor.subscribe('schools', this.params._id),
- Meteor.subscribe('teachers', this.params._id),
- Meteor.subscribe('work', this.params._id),
- Meteor.subscribe('requests', this.params._id),
- Meteor.subscribe('users', this.params._id)
- ];
- }
- },
- action: function() {
- if(_.contains([null, undefined, ""], Meteor.user().profile.school ||
- _.contains([null, undefined, ""], Meteor.user().profile.grade))) {
- this.redirect('/profile');
- } else {
- Session.set("user", Meteor.user().profile);
- this.render("main");
+ if(_.contains([null, undefined, ""], Meteor.user().profile.school ||
+ _.contains([null, undefined, ""], Meteor.user().profile.grade))) {
+ this.redirect('/profile');
+ } else {
+ Session.set("user", Meteor.user().profile);
+ this.render("main");
+ }
}
}
});
@@ -37,10 +41,8 @@ Router.route('/login', {
if (!Meteor.userId()) {
this.render("login");
} else if (!completeProfile()) {
- Session.set("user", Meteor.user().profile);
this.redirect('/profile');
} else {
- Session.set("user", Meteor.user().profile);
this.redirect('/');
}
}
@@ -48,21 +50,22 @@ Router.route('/login', {
Router.route('/profile', {
waitOn: function() {
+ return [
+ Meteor.subscribe('classes', this.params._id),
+ Meteor.subscribe('schools', this.params._id),
+ Meteor.subscribe('teachers', this.params._id),
+ Meteor.subscribe('work', this.params._id),
+ Meteor.subscribe('requests', this.params._id),
+ Meteor.subscribe('personalUser', this.params._id),
+ Meteor.subscribe('users', this.params._id)
+ ];
+ },
+ action: function() {
if (!Meteor.userId() || completeProfile()) {
this.redirect('/login');
} else {
- return [
- Meteor.subscribe('classes', this.params._id),
- Meteor.subscribe('schools', this.params._id),
- Meteor.subscribe('teachers', this.params._id),
- Meteor.subscribe('work', this.params._id),
- Meteor.subscribe('requests', this.params._id),
- Meteor.subscribe('users', this.params._id)
- ];
+ this.render("profile");
}
- },
- action: function() {
- this.render("profile");
}
});
diff --git a/hourglass/server/main.js b/hourglass/server/main.js
index 433e6db..5742b26 100644
--- a/hourglass/server/main.js
+++ b/hourglass/server/main.js
@@ -65,7 +65,23 @@ Meteor.publish('classes', function() {
} else {
Meteor.call('createProfile', this.userId);
return classes.find({
- _id: null
+ privacy: false,
+ status: true,
+ }, {
+ // Return non-sensitive fields
+ fields: {
+ school: 1,
+ name: 1,
+ hour: 1,
+ teacher: 1,
+ admin: 1,
+ status: 1,
+ privacy: 1,
+ category: 1,
+ moderators: 1,
+ banned: 1,
+ subscribers: 1
+ }
});
}
}
@@ -108,6 +124,15 @@ Meteor.publish('requests', function() {
}
});
+Meteor.publish("personalUser", function() {
+ return Meteor.users.find({_id: this.userId}, {
+ fields: {
+ 'services': 1,
+ 'profile': 1
+ }
+ });
+});
+
//Publishes every-persons email and user-ids
Meteor.publish('users', function() {
@@ -119,9 +144,7 @@ Meteor.publish('users', function() {
fields: {
'services.google.email': 1,
'services.google.picture': 1,
- 'profile.banner': 1,
'profile.grade': 1,
- 'profile.description': 1,
'profile.name': 1,
'profile.school': 1
}
@@ -129,7 +152,6 @@ Meteor.publish('users', function() {
}
});
-
// Allows only superadmins to edit collections from client
Security.permit(['insert', 'update', 'remove']).collections([schools, classes, work]).ifHasRole('superadmin');
@@ -595,7 +617,6 @@ Meteor.methods({
throw new Meteor.Error(errors[security]);
}
},
-
// User Functions
'editProfile': function(change) {
var refyear = new Date().getUTCFullYear();
@@ -605,15 +626,11 @@ Meteor.methods({
"school": change.school,
"grade": change.grade,
"classes": current.classes,
- "description": change.description,
- "banner": change.banner,
"preferences": change.preferences,
"name": current.name,
- "complete": current.complete
+ "complete": change.complete
};
- if (current.description && current.description.length > 50) {
- current.description = current.description.slice(0, 50);
- }
+
if ((current.grade <= refyear || current.grade >= refyear + 4) && current.grade !== 0) {
current.grade = refyear;
}
@@ -646,7 +663,6 @@ Meteor.methods({
_id: userId
});
var current = currentuser.profile;
- current.banner = "/Banners/defaultcover.jpg";
current.classes = [userId];
current.preferences = {
"theme": themeColors.lux,