createWork() and calendar work
This commit is contained in:
parent
1d948d0c39
commit
22704145c6
@ -20,7 +20,12 @@ var themeColors = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var calendarColors = {
|
||||||
|
"test": "red",
|
||||||
|
"project": "blue",
|
||||||
|
"normal": "green",
|
||||||
|
"quiz": "black"
|
||||||
|
}
|
||||||
var options = {
|
var options = {
|
||||||
"privacy": ["Public", "Hidden"],
|
"privacy": ["Public", "Hidden"],
|
||||||
"category": ["Class", "Club", "Other"]
|
"category": ["Class", "Club", "Other"]
|
||||||
@ -149,9 +154,16 @@ Template.main.helpers({
|
|||||||
return {
|
return {
|
||||||
height: window.innerHeight *.8,
|
height: window.innerHeight *.8,
|
||||||
events: function() {
|
events: function() {
|
||||||
//Get homeworks
|
var cursor = work.find({});
|
||||||
//if(homework thing ==test ) backgroundColor = color;
|
var current;
|
||||||
//return {title, start, end, className, backgroundColor}
|
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -30,9 +30,11 @@ work.schema = new SimpleSchema({
|
|||||||
class: {type: String},
|
class: {type: String},
|
||||||
dueDate: {type: Date},
|
dueDate: {type: Date},
|
||||||
aliases: {type: [String]},
|
aliases: {type: [String]},
|
||||||
submittor: {type: String},
|
submittor: {type: String, optional: true},
|
||||||
confirmations: {type: [String]},
|
confirmations: {type: [String], optional: true},
|
||||||
reports: {type: [String], optional: true},
|
reports: {type: [String], optional: true},
|
||||||
attachments: {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}
|
||||||
});
|
});
|
||||||
@ -6,6 +6,7 @@ _uuid4 = function(cc) {
|
|||||||
return (cc === 'x' ? rr : (rr & 0x3 | 0x8)).toString(16);
|
return (cc === 'x' ? rr : (rr & 0x3 | 0x8)).toString(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
worktype = ["test", "quiz", "project", "normal"];
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
'genCode': function() {
|
'genCode': function() {
|
||||||
return 'xxxxxx'.replace(/[x]/g, _uuid4);
|
return 'xxxxxx'.replace(/[x]/g, _uuid4);
|
||||||
@ -56,6 +57,26 @@ Meteor.methods({
|
|||||||
if (Meteor.user() != null && found != null && found.admin === Meteor.user()._id) {
|
if (Meteor.user() != null && found != null && found.admin === Meteor.user()._id) {
|
||||||
classes.remove({_id: classid})
|
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) {
|
'editProfile': function(change) {
|
||||||
current = Meteor.user().profile;
|
current = Meteor.user().profile;
|
||||||
@ -74,7 +95,8 @@ Meteor.methods({
|
|||||||
},
|
},
|
||||||
'joinClass': function(change, pass) {
|
'joinClass': function(change, pass) {
|
||||||
found = classes.findOne({_id: change, status: true});
|
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 = Meteor.user().profile;
|
||||||
current.classes.append(change);
|
current.classes.append(change);
|
||||||
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
|
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user