diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js index 0a2d29e..1f6d3e6 100644 --- a/hourglass/client/main/main.js +++ b/hourglass/client/main/main.js @@ -20,7 +20,12 @@ var themeColors = { } }; - +var calendarColors = { + "test": "red", + "project": "blue", + "normal": "green", + "quiz": "black" +} var options = { "privacy": ["Public", "Hidden"], "category": ["Class", "Club", "Other"] @@ -149,9 +154,16 @@ Template.main.helpers({ return { height: window.innerHeight *.8, events: function() { - //Get homeworks - //if(homework thing ==test ) backgroundColor = color; - //return {title, start, end, className, backgroundColor} + var cursor = work.find({}); + var current; + var donelist; + cursor.forEach(function(current) { + backgroundColor = calendarColors[current.type]; + title = current.name; + duedate = current.date.toISOString().slice(0,10); + donelist.append({start: duedate, title: title, backgroundColor: backgroundColor}); + }); + return donelist; } }; }, diff --git a/hourglass/collections/main.js b/hourglass/collections/main.js index 4df513d..daa6589 100644 --- a/hourglass/collections/main.js +++ b/hourglass/collections/main.js @@ -30,9 +30,11 @@ work.schema = new SimpleSchema({ class: {type: String}, dueDate: {type: Date}, aliases: {type: [String]}, - submittor: {type: String}, - confirmations: {type: [String]}, + submittor: {type: String, optional: true}, + confirmations: {type: [String], optional: true}, reports: {type: [String], optional: true}, attachments: {type: [String], optional: true}, - done: {type: [String], optional: true} + done: {type: [String], optional: true}, + numberdone: {type: Number, optional: true}, + type: {type: String} }); \ No newline at end of file diff --git a/hourglass/server/main.js b/hourglass/server/main.js index a171424..15e00f2 100644 --- a/hourglass/server/main.js +++ b/hourglass/server/main.js @@ -6,6 +6,7 @@ _uuid4 = function(cc) { return (cc === 'x' ? rr : (rr & 0x3 | 0x8)).toString(16); } +worktype = ["test", "quiz", "project", "normal"]; Meteor.methods({ 'genCode': function() { return 'xxxxxx'.replace(/[x]/g, _uuid4); @@ -56,6 +57,26 @@ Meteor.methods({ if (Meteor.user() != null && found != null && found.admin === Meteor.user()._id) { classes.remove({_id: classid}) } + }, + 'createWork': function(input) { + ref = new Date() + month = ref.getMonth +1 + ref = new Date(ref.getFullYear()+ "-" + month.toString() + "-" + ref.getDate()).getTime() + work.schema.validate(input); + found = Meteor.findOne({_id: input.class}) + if (Meteor.user() != null && found != null && found.subscribers.indexOf(Meteor.userId()) != -1 + && found.banned.indexOf(Meteor.userId()) === -1 && found.blockEdit.indexOf(Meteor.userId()) === -1 + && input.dueDate.getTime() >= ref && worktype.indexOf(type) != -1) { + input.submittor = Meteor.userId(); + input.confirmations = [Meteor.userId()]; + input.reports = []; + input.done = []; + input.numberdone = 0; + } + + }, + 'deleteWork': function(workid) { + }, 'editProfile': function(change) { current = Meteor.user().profile; @@ -74,7 +95,8 @@ Meteor.methods({ }, 'joinClass': function(change, pass) { found = classes.findOne({_id: change, status: true}); - if (Meteor.user() != null && found != null && pass === found.code && Meteor.user().profile.classes.indexOf(change) === -1) { + if (Meteor.user() != null && found != null && pass === found.code + && found.banned.indexOf(Meteor.userId()) === -1 && Meteor.user().profile.classes.indexOf(change) === -1) { current = Meteor.user().profile; current.classes.append(change); Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});