diff --git a/hourglass/client/main/main.css b/hourglass/client/main/main.css
index 91004c8..0dab4af 100644
--- a/hourglass/client/main/main.css
+++ b/hourglass/client/main/main.css
@@ -304,7 +304,7 @@ body {
.mode h4 {
width: 65%;
- padding-left: 9%;
+ padding-left: 5%;
line-height: 6vh;
display: table-cell;
vertical-align: middle;
@@ -363,6 +363,7 @@ body {
font-size: 1.7vh;
padding: 5%;
display: table-cell;
+ pointer-events: none;
}
.sideClassName {
@@ -684,9 +685,9 @@ textarea.clickModify {
}
.optionText {
- font-size: 120%;
+ font-size: 120% !important;
min-width: 10%;
- padding: 4% 7% 4% 7%;
+ padding: 4% 7% 4% 7% !important;
margin: 0;
box-shadow: inset 0 0 0 99999px rgba(0,0,0,0.05);
@@ -798,23 +799,16 @@ textarea.clickModify {
background-color: rgba(0,0,0,0.15);
}
-.overlay {
+.overlay, #confirmOverlay {
width: 100%;
height: 100%;
- background-color: rgba(0,0,0,0.5);
+ background-color: rgba(0,0,0,0.7);
display: none;
position: absolute;
top: 0;
left: 0;
z-index: 51;
-
- opacity: 0;
-
- -webkit-transition: opacity 0.4s ease;
- -moz-transition: opacity 0.4s ease;
- -ms-transition: opacity 0.4s ease;
- transition: opacity 0.4s ease;
}
.overlayCont {
@@ -824,11 +818,12 @@ textarea.clickModify {
margin: auto;
margin-top: 25vh;
padding: 1%;
- box-shadow: 2px 2px 5px 3px #666;
+
+ box-shadow: 2px 2px 5px 1px #666;
- -moz-border-radius: 30px;
- -webkit-border-radius: 30px;
- border-radius: 30px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
text-align: center;
}
@@ -1230,13 +1225,6 @@ textarea.clickModify {
top: 0.5vh;
right: 1.5vw;
z-index: 20;
-
- opacity: 0;
-
- -webkit-transition: opacity 0.4s ease;
- -moz-transition: opacity 0.4s ease;
- -ms-transition: opacity 0.4s ease;
- transition: opacity 0.4s ease;
}
#userDropdownAvatar {
diff --git a/hourglass/client/main/main.html b/hourglass/client/main/main.html
index c8df587..89ae751 100644
--- a/hourglass/client/main/main.html
+++ b/hourglass/client/main/main.html
@@ -61,7 +61,7 @@
{{> joinClass}}
{{/if}}
- {{$if currSettingMode 'createClass'}}
+ {{#if currSettingMode 'createClass'}}
{{> createClass}}
{{/if}}
@@ -138,6 +138,16 @@
+
+
+
{{confirmText}}
+
+
+
+
+
+
+
@@ -249,7 +259,7 @@
- {{alias}}
+ {{alias}}
diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js
index 5cacee8..b5bd0d7 100644
--- a/hourglass/client/main/main.js
+++ b/hourglass/client/main/main.js
@@ -32,6 +32,7 @@ Session.set("typeFilterHover", null); // Stores current hovered type filter.
Session.set("classDispHover", null); // Stores current hovered class filter.
Session.set("refetchEvents", null); // Stores whether to get calendar events again.
Session.set("restrictText", {}); // Stores text for comment character restriction.
+Session.set("confirmText", ""); // Stores text for confirmations.
// On render actions
@@ -63,17 +64,6 @@ Template.profile.rendered = function() {
document.getElementsByTagName("body")[0].style.color = Session.get("user").preferences.theme.textColor;
};
-Template.selectOptionMenu.rendered = function() {
- $(".optionText").hover(
- function() {
- $(this).addClass("selectedOption");
- },
- function() {
- $(this).removeClass("selectedOption");
- }
- );
-}
-
// Global Helpers
Template.registerHelper('adminPage', () => {
@@ -124,12 +114,14 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
_id: courses[i]
});
found.subscribers = found.subscribers.length;
+ found.teachershort = found.teacher.split(" ").slice(1).reduce(function(a,b) { return a+ " " + b;});
found.mine = true;
if (found.admin === Meteor.userId()) { // If user owns this class.
found.box = " owned";
found.mine = false;
}
}
+
found.selected = ((classDisp.indexOf(courses[i]) !== -1)) ? Session.get("user").preferences.theme.modeHighlight : "rgba(0,0,0,0)"; // Filter selected.
array.push(found);
@@ -265,6 +257,10 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
}
});
+Template.registerHelper('confirmText', () => {
+ return Session.get("confirmText");
+})
+
// Main template helpers and events
Template.main.helpers({
@@ -368,7 +364,7 @@ Template.main.helpers({
eventClick: function(event, jsEvent, view) { // On-click for work.
Session.set("newWork", false);
Session.set("currentWork", work.findOne({_id: event.id}));
- openDivFade(document.getElementsByClassName("overlay")[0]);
+ $(".overlay").fadeIn(250);
},
eventMouseover: function(event, jsEvent, view) {
this.style.boxShadow = "inset 0 0 0 99999px rgba(255,255,255,0.2)";
@@ -468,13 +464,13 @@ Template.main.events({
}
if (e === "overlay") { // Overlay closing.
- closeDivFade(document.getElementsByClassName("overlay")[0]);
+ $(".overlay").fadeOut(250);
if (!Session.get("newWork")) {
document.getElementById("workComment").value = "";
}
}
- if (!document.getElementById("userDropdown").contains(event.target)) closeDivFade(document.getElementById("userDropdown"));
+ if (!document.getElementById("userDropdown").contains(event.target)) $("#userDropdown").fadeOut(250);
},
// MAIN MENU BUTTONS
'click .fa-bars' (event) { // Click menu button.
@@ -495,13 +491,28 @@ Template.main.events({
}
Session.set("newWork", true);
Session.set("currentWork",{class: attr, dueDate: (new Date((new Date()).valueOf() + 1000*3600*24))});
- openDivFade(document.getElementsByClassName("overlay")[0]);
+ $(".overlay").fadeIn(250);
+ },
+ 'click .fa-check-circle-o' () { // Confirmation Button
+ sendData(confirm);
+ $("#confirmOverlay").fadeOut(250);
+ if(confirm === "changeAdmin") {
+ $("#changeAdminWrapper").fadeOut(250);
+ } else if(confirm === "deleteClass") {
+ Session.set("classInfo", null);
+ }
+ serverData = null;
+ confirm = null;
+
+ },
+ 'click .fa-times-circle-o' () { // Deny Button
+ $("#confirmOverlay").fadeOut(250);
+ serverData = null;
+ confirm = null;
},
'click #dropdown' (event) {
if (document.getElementById("userDropdown").style.display === "block") return;
- setTimeout(function() {
- openDivFade(document.getElementById("userDropdown"));
- }, 100);
+ $("#userDropdown").fadeIn(250);
},
'click .workCard' (event) { // Display work information on work card click.
var workid = event.target.getAttribute("workid");
@@ -523,7 +534,7 @@ Template.main.events({
var inputs = $('#editWork .clickModify').css("cursor", "default");
}
}
- openDivFade(document.getElementsByClassName("overlay")[0]);
+ $(".overlay").fadeIn(250);
},
'click #requestSubmit' () {
var area = document.getElementById("requestArea");
@@ -662,6 +673,8 @@ Template.main.events({
if(Session.get("newWork")) return;
if(checkMissing()) return;
sendData("editWork");
+ } else if(modifyingInput.slice(0,3) === "cre") {
+ document.getElementById(modifyingInput).value = option;
} else {
var newSetting = Session.get("user");
newSetting.preferences[modifyingInput] = (function() {
@@ -714,12 +727,12 @@ Template.main.events({
if(checkMissing()) return;
sendData("createWork");
Session.set("newWork",false);
- closeDivFade(document.getElementsByClassName("overlay")[0]);
+ $(".overlay").fadeOut(250);
},
'click #workDelete' () {
serverData = Session.get("currentWork")._id;
sendData("deleteWork");
- closeDivFade(document.getElementsByClassName("overlay")[0]);
+ $(".overlay").fadeOut(250);
},
'click #markDone' () { // Click done button.
serverData = [Session.get("currentWork")._id, "done"];
@@ -756,21 +769,6 @@ function toggleOptionMenu(toggle, menu) {
}
}
-function openDivFade(div) {
- div.style.display = "block";
- div.style.opacity = "0";
- setTimeout(function() {
- div.style.opacity = "1";
- }, 100);
-}
-
-function closeDivFade(div) {
- div.style.opacity = "0";
- setTimeout(function() {
- div.style.display = "none";
- }, 100);
-}
-
sendData = function(funcName) { // Call Meteor function, and do actions after function is completed depending on function.
if(funcName === "editWork" || funcName === "createWork") {
for(var key in serverData) {
@@ -780,6 +778,7 @@ sendData = function(funcName) { // Call Meteor function, and do actions after fu
Meteor.call(funcName, serverData, function(error, result) {
serverData = null;
currWork = Session.get("currentWork");
+
if(currWork !== null && currWork._id !== undefined) {
Session.set("currentWork", work.findOne({
_id: currWork._id
@@ -798,6 +797,13 @@ sendData = function(funcName) { // Call Meteor function, and do actions after fu
position: 'bottom-right',
timeout: 2500
});
+ if(funcName === "createClass") {
+ var inputs = document.getElementsByClassName("creInput");
+ for(var i = 0; i < inputs.length; i++) {
+ inputs[i].value = "";
+ }
+ toggleToMode("manageClass");
+ }
}
document.getElementsByTagName("body")[0].style.color = Session.get("user").preferences.theme.textColor;
});
diff --git a/hourglass/client/menus/menus.css b/hourglass/client/menus/menus.css
index f779aca..76e4aa7 100644
--- a/hourglass/client/menus/menus.css
+++ b/hourglass/client/menus/menus.css
@@ -155,6 +155,23 @@
background-color: rgba(0,0,0,0.3);
}
+.classBox .fa {
+ text-align: center;
+
+ -webkit-transition: color 0.4s ease;
+ -moz-transition: color 0.4s ease;
+ -ms-transition: color 0.4s ease;
+ transition: color 0.4s ease;
+}
+
+.classBox .fa-times:hover {
+ color: #FF1A1A;
+}
+
+.classBox .fa-plus:hover {
+ color: #85E085;
+}
+
.owned {
box-shadow: inset 0 0 0 99999px rgba(255,255,255,0.3);
-webkit-transition: background-color 0.4s ease;
@@ -175,16 +192,23 @@
pointer-events: none;
}
-.classBox .fa-times {
- display: table-cell;
- width: 5%;
+.classBox .fa {
+ font-size: 2.5vh !important;
+ padding: 0 !important;
+ display: table-cell !important;
+ width: 5% !important;
}
.name {
width: 40%;
}
+.teacher {
+ width: 25%;
+}
+
.hour.classText, .subscribers.classText {
+ width: 15%;
text-align: center;
}
@@ -370,6 +394,24 @@
background-color: rgba(0,0,0,0.2);
}
+#deleteClass {
+ cursor: pointer;
+ float: right;
+}
+
+#deleteClass:hover {
+ color: #FF1A1A;
+}
+
+#deleteClass .fa {
+ margin-top: 0;
+
+ -webkit-transition: color 0.4s ease;
+ -moz-transition: color 0.4s ease;
+ -ms-transition: color 0.4s ease;
+ transition: color 0.4s ease;
+}
+
.userAdder {
width: 100%;
margin-bottom: 3%;
@@ -491,3 +533,74 @@
100% { width: 25%; }
}
+#createWrapper {
+ padding: 3%;
+}
+
+#creRules p {
+ padding: 0;
+}
+
+.formDiv {
+ margin-left: 25%;
+ padding: 1% 2% 1% 2%;
+ width: 30%;
+ background-color: rgba(255,255,255,0.1);
+ position: relative;
+ display: table;
+}
+
+.formDiv:first-child {
+ padding-top: 2%;
+}
+
+.formDiv:last-child {
+ padding-bottom: 2%;
+}
+
+.formDiv input {
+ font-size: 2vh;
+ width: calc(98% - 8px) !important;
+ padding: 1%;
+ margin: 1%;
+}
+
+.formDiv .optionHolder {
+ width: 89%;
+}
+
+.formDiv .-autocomplete-container {
+ margin: 1% 0 0 0.5%;
+}
+
+.profTitle {
+ padding-left: 0 !important;
+}
+
+#formContainer {
+ margin: 2%;
+}
+
+#creSubmit {
+ font-weight: 200;
+ width: 30%;
+ padding: 2%;
+ margin-top: 2%;
+ margin-left: 25%;
+
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+
+ text-align: center;
+ cursor: pointer;
+
+ -webkit-transition: background-color 0.4s ease;
+ -moz-transition: background-color 0.4s ease;
+ -ms-transition: background-color 0.4s ease;
+ transition: background-color 0.4s ease;
+}
+
+#creSubmit:hover {
+ background-color: rgba(0,0,0,0.1);
+}
diff --git a/hourglass/client/menus/menus.html b/hourglass/client/menus/menus.html
index b728960..6b6c2b4 100644
--- a/hourglass/client/menus/menus.html
+++ b/hourglass/client/menus/menus.html
@@ -141,7 +141,9 @@
- Classes
+
+
Requests
+
{{#each myClasses}}
{{> sidebarClasses}}
@@ -211,7 +213,7 @@
Join Classes
-
+
@@ -276,57 +278,72 @@
-
Submit a request for a class to be approved by an administrator. You can have up to 8 unapproved classes at once.
-
{{name}}
- {{teacher}}
+ {{teachershort}}
{{hour}}
{{subscribers}}
{{#if mine}}
{{else}}
-
+ {{#if join}}
+
+ {{else}}
+
+ {{/if}}
{{/if}}
@@ -338,11 +355,25 @@
Private
+ {{#unless classInfo 'personal'}}
+ {{#if classInfo 'mine'}}
+
+
+
+ {{/if}}
+ {{/unless}}
{{else}}
Public
+ {{#unless classInfo 'personal'}}
+ {{#if classInfo 'mine'}}
+
+
+
+ {{/if}}
+ {{/unless}}
{{/if}}
@@ -454,3 +485,10 @@
{{/if}}
+
+ {{name}}
+
+
+
+ {{name}}
+
diff --git a/hourglass/client/menus/menus.js b/hourglass/client/menus/menus.js
index b046f79..09020c2 100644
--- a/hourglass/client/menus/menus.js
+++ b/hourglass/client/menus/menus.js
@@ -1,5 +1,8 @@
Session.set("settingMode", "manageClass");
Session.set("classInfoMode", "general");
+Session.set("notsearching", true); // If user isn't searching
+Session.set("noclass", null); // If user doesn't have classes.
+Session.set("notfound", null); // If no results for autocomplete.
var filterOpen = [false, true, true, true, true];
var sidebarMode = [null,null];
@@ -69,24 +72,14 @@ Template.sidebarMenuPlate.events({
},
// CLASS FILTERS
'click .sideClass' (event) { // Click class list in sidebar.
- var div = event.target;
- while (div.getAttribute("classid") === null) div = div.parentNode;
- var classid = div.getAttribute("classid");
-
- if (Session.equals("sidebarMode","create")) { // If creating work from calendar.
- var newSetting = Session.get("currentWork");
- newSetting.class = classid;
- Session.set("currentWork", newSetting);
- openDivFade(document.getElementsByClassName("overlay")[0]);
- } else { // Normal clicking turns on filter.
- var array = Session.get("classDisp");
- if (array.indexOf(classid) !== -1) {
- array.splice(array.indexOf(classid), 1);
- } else {
- array.push(classid);
- }
- Session.set("classDisp", array);
+ var classid = event.target.getAttribute("classid")
+ var array = Session.get("classDisp");
+ if (array.indexOf(classid) !== -1) {
+ array.splice(array.indexOf(classid), 1);
+ } else {
+ array.push(classid);
}
+ Session.set("classDisp", array);
},
'click .sideFilter' (event) {
var div = event.target;
@@ -180,6 +173,16 @@ Template.sidebarOptionPlate.events({
}
});
+Template.sidebarCreatePlate.events({
+ 'click .sideClass' (event) { // Click class list in sidebar.
+ var classid = event.target.getAttribute("classid");
+ var newSetting = Session.get("currentWork");
+ newSetting.class = classid;
+ Session.set("currentWork", newSetting);
+ $(".overlay").fadeIn(250);
+ }
+})
+
Template.registerHelper("classInfo", (info) => {
var thisClass = classes.findOne({_id:Session.get("classInfo")});
var isYou = Session.equals("classInfo", Meteor.userId());
@@ -197,7 +200,8 @@ Template.registerHelper("classInfo", (info) => {
case "admin":
return Meteor.users.findOne({_id: (isYou) ? Meteor.userId() : thisClass.admin});
case "code":
- return (isYou || !thisClass.code) ? {exists: false} : {exists: true, code: thisClass.code};
+ if(isYou) return {exists: false}
+ return (isYou || Meteor.userId() !== this.admin) ? {exists: false} : {exists: true, code: Meteor.call('getCode', thisClass._id)};
case "mine":
return (isYou) ? true : Meteor.userId() === thisClass.admin;
case "moderators":
@@ -275,8 +279,21 @@ Template.manageClass.events({
user._id,
classid
];
- sendData("changeAdmin");
- input.value = "";
+ Session.set("confirmText", "Change ownership?");
+ confirm = "changeAdmin";
+ $("#confirmOverlay").fadeIn(250);
+ },
+ 'click #deleteClass' () {
+ serverData = Session.get("classInfo");
+ confirm = "deleteClass";
+ Session.set("confirmText", "Delete this class?");
+ $("#confirmOverlay").fadeIn(250);
+ },
+ 'click .classBox .fa-times' (event) {
+ serverData = event.target.parentNode.getAttribute("classid");
+ confirm = "leaveClass";
+ Session.set("confirmText", "Leave this class?");
+ $("#confirmOverlay").fadeIn(250);
}
});
@@ -293,7 +310,9 @@ Template.joinClass.helpers({
).fetch();
for (var i = 0; i < array.length; i++) {
+ array[i].join = true;
array[i].subscribers = array[i].subscribers.length;
+ array[i].teachershort = array[i].teacher.split(" ").slice(1).reduce(function(a,b) { return a+ " " + b;});
}
if (array.length === 0) {
Session.set("noclass", true);
@@ -385,6 +404,12 @@ Template.joinClass.events({
}));
} catch (err) {}
},
+ 'click .classBox .fa-plus' (event) {
+ serverData = [event.target.parentNode.getAttribute("classid"), ""];
+ confirm = "joinClass";
+ Session.set("confirmText", "Join this class?");
+ $("#confirmOverlay").fadeIn(250);
+ },
'click #private' () {
$("#privateCode").css('display','inline-block');
var input = document.getElementById("privateCode");
@@ -408,6 +433,80 @@ Template.joinClass.events({
}
});
+Template.createClass.helpers({
+ schoolComplete() { // Returns autocomplete array for schools.
+ return {
+ position: "bottom",
+ limit: 6,
+ rules: [{
+ token: '',
+ collection: schools,
+ field: 'name',
+ matchAll: true,
+ template: Template.schoolList
+ }]
+ };
+ },
+ teacherComplete() { // Returns autocomplete array for teachers.
+ return {
+ position: "bottom",
+ limit: 1,
+ rules: [{
+ token: '',
+ collection: teachers,
+ field: 'name',
+ template: Template.teacherList
+ }]
+ };
+ },
+});
+
+Template.createClass.events({
+ 'click #creSubmit' () {
+ var inputs = document.getElementsByClassName("creInput");
+ var values = new Object;
+ var required = ["school","name","privacy","category"];
+ var no = [];
+ for(var i = 0; i < inputs.length; i++) {
+ var val = inputs[i].value;
+ var where = inputs[i].getAttribute("form");
+ if(val === "" && _.contains(required, where)) {
+ no.push(where);
+ }
+ values[where] = val;
+ }
+
+ if(no.length !== 0) { // Check missing fields.
+ sAlert.error("Missing " + no.reduce(function(a,b) { return (b === no[no.length-1]) ? a + ", and " + b : a + ", " + b }), {
+ effect: 'stackslide',
+ position: 'top',
+ timeout: 3000
+ });
+ return;
+ }
+ values.privacy = (values.privacy === "Public") ? false : true;
+ values.status = false;
+ values.category.toLowerCase();
+ values.code = "";
+ serverData = values;
+ if(!teachers.findOne({name: values["teacher"]})) {
+ Meteor.call("createTeacher", values["teacher"], function(error,result) {
+ console.log(error);
+ if (error !== undefined) {
+ sAlert.error(error.message, {
+ effect: 'stackslide',
+ position: 'top'
+ });
+ } else {
+ sendData("createClass");
+ }
+ });
+ } else {
+ sendData("createClass");
+ }
+ }
+});
+
Template.classInfoUsers.events({
'click .userAdder .fa' (event) {
var type = event.target.getAttribute("user");
diff --git a/hourglass/collections/main.js b/hourglass/collections/main.js
index 7cfa5be..8aff872 100644
--- a/hourglass/collections/main.js
+++ b/hourglass/collections/main.js
@@ -1,13 +1,19 @@
schools = new Mongo.Collection("Schools");
+teachers = new Mongo.Collection("Teachers");
classes = new Mongo.Collection("Classes");
work = new Mongo.Collection("Work");
requests = new Mongo.Collection("Requests");
admins = Meteor.users;
schools.schema = new SimpleSchema({
- name: {type: String},
+ name: {type: String}
});
+teachers.schema = new SimpleSchema({
+ name: {type: String},
+ school: {type: String}
+})
+
classes.schema = new SimpleSchema({
school: {type: String},
//icon: {type: String},
@@ -57,6 +63,7 @@ userSchema = new SimpleSchema({
});
schools.attachSchema(schools.schema);
+teachers.attachSchema(teachers.schema);
classes.attachSchema(classes.schema);
work.attachSchema(work.schema);
requests.attachSchema(requests.schema);
diff --git a/hourglass/lib/adminConfig.js b/hourglass/lib/adminConfig.js
index bef4086..82fb376 100644
--- a/hourglass/lib/adminConfig.js
+++ b/hourglass/lib/adminConfig.js
@@ -10,6 +10,16 @@ AdminConfig = {
color: 'red',
label: 'Schools'
},
+ teachers: {
+ icon: 'book',
+ tableColumns: [
+ { label: 'ID', name: '_id' },
+ { label: 'Name', name: 'name' },
+ { label: 'School', name: 'school'}
+ ],
+ color: 'orange',
+ label: 'Teachers'
+ },
classes: {
icon: 'graduation-cap',
tableColumns: [
diff --git a/hourglass/lib/constants.js b/hourglass/lib/constants.js
index c21d2ac..03bc54a 100644
--- a/hourglass/lib/constants.js
+++ b/hourglass/lib/constants.js
@@ -1,9 +1,9 @@
themeColors = {
"lux": {
"background": "White.jpg",
- "mainColor": "#EEE",
- "secondaryColor": "#FEFEFE",
- "sidebarColor": "#799cb8",
+ "mainColor": "#DBDBDB",
+ "secondaryColor": "#E8E8E8",
+ "sidebarColor": "#799CB8",
"userDropdownColor": "#E6E6E6",
"iconHighlight": "#FFF",
"modeHighlight": "#D34949",
@@ -28,8 +28,8 @@ themeColors = {
"sidebarColor": "#327C5A",
"userDropdownColor": "#CC3333",
"iconHighlight": "#327C5A",
- "modeHighlight": "#C9fE62",
- "classCardColor":"#302c36",
+ "modeHighlight": "#C9FE62",
+ "classCardColor":"#302C36",
"textColor": "#FCF0F0"
},
"aequor": {
@@ -50,7 +50,7 @@ themeColors = {
"sidebarColor": "#6D9957",
"userDropdownColor": "#89BB52",
"iconHighlight": "#91EE61",
- "modeHighlight": "#B9f643",
+ "modeHighlight": "#B9F643",
"classCardColor":"#C18311",
"textColor": "#FCF0F0"
},
@@ -121,4 +121,5 @@ options = {
]
}
-serverData = null;
\ No newline at end of file
+serverData = null;
+confirm = null;
\ No newline at end of file
diff --git a/hourglass/lib/router.js b/hourglass/lib/router.js
index 6f7167e..50de376 100644
--- a/hourglass/lib/router.js
+++ b/hourglass/lib/router.js
@@ -6,6 +6,7 @@ Router.route('/', {
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)
@@ -45,6 +46,7 @@ Router.route('/profile', {
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)
@@ -57,30 +59,6 @@ Router.route('/profile', {
}
});
-Router.route('/user/:email', {
- data: function() {
- return Meteor.users.findOne({'services.google.email': this.params.email});
- },
- waitOn: function() {
- return [
- Meteor.subscribe('users', this.params._id)
- ];
- },
- action: function() {
- if(Meteor.users.findOne({'services.google.email': this.params.email}) !== undefined) {
- if(Meteor.user() && this.params.email === Meteor.user().services.google.email) {
- Session.set("user", Meteor.user().profile);
- this.redirect('/profile');
- } else {
- Session.set("user", Meteor.user().profile);
- this.render('user');
- }
- } else {
- this.render("NotFound");
- }
- }
-});
-
Router.configure({
notFoundTemplate: "NotFound"
});
diff --git a/hourglass/server/main.js b/hourglass/server/main.js
index db1ec44..31b4e8c 100644
--- a/hourglass/server/main.js
+++ b/hourglass/server/main.js
@@ -25,6 +25,10 @@ Meteor.publish('schools', function() {
return schools.find();
});
+Meteor.publish('teachers', function() {
+ return teachers.find();
+})
+
// Returns the code for classes (for debug)
Meteor.publish('classes', function() {
@@ -151,7 +155,9 @@ var errors = [
["unauthorized", "This class has not been approved yet"],
["unauthorized", "Sorry, you are not authorized to complete this action."],
- ["other", "Error could not be processed"]
+ ["other", "Error could not be processed"],
+ ["matching", "This teacher already exists!"],
+ ["trivial", "Please put the full name!"]
];
function securityCheck(checklist, input) {
@@ -182,10 +188,9 @@ function securityCheck(checklist, input) {
case 3:
if (!schools.findOne({name: input.school})) error = 2;
break;
- // TODO: teachers with same name
// Duplicate classes
case 4:
- if (classes.findOne({school: input.school, status: true, privacy: false, teacher: input.teacher, hour: input.hour}) || (input.teacher === "" && input.hour === "")) error = 3;
+ if (classes.findOne({school: input.school, teacher: input.teacher, status: true, privacy: false, hour: input.hour}) || (input.teacher === "" && input.hour === "")) error = 3;
break;
// Class admin
case 5:
@@ -266,6 +271,14 @@ function securityCheck(checklist, input) {
case 25:
if (Meteor.userId() === null) error = errors.length - 1;
break;
+ // Teacher already exists
+ case 26:
+ if (teachers.findOne({name: {$eq: input.teacher}, school: {$eq: input.school}})) error = 21;
+ break;
+ // Incorrect teacher format
+ case 27:
+ if(input.split(" ").length < 2) error = 22;
+ break;
}
results.push(error);
}
@@ -317,7 +330,18 @@ Meteor.methods({
throw new Meteor.Error(errors[security]);
}
},
-
+ 'createTeacher': function(name) {
+ teachers.schema.validate({name: name});
+ var security = securityCheck([26, 27, true],
+ name);
+ if(!security) {
+ teachers.insert({
+ name: name
+ });
+ } else {
+ throw new Meteor.Error(errors[security]);
+ }
+ },
// Class Functions
'createClass': function(input) {
classes.schema.validate(input);
@@ -335,7 +359,6 @@ Meteor.methods({
input.subscribers = [];
input.moderators = [];
input.banned = [];
-
classes.insert(input, function(err, result) {
Meteor.call('joinClass', [result, input.code]);
});
@@ -711,9 +734,11 @@ Meteor.methods({
var current = Meteor.user().profile;
var index = current.classes.indexOf(change);
if (index >= 0) {
+ console.log("hi");
if (classes.findOne({
_id: change
}).admin != Meteor.userId()) {
+ console.log("f");
current.classes.splice(index, 1);
Meteor.users.update({
_id: Meteor.userId()