2016-08-17 23:39:51 -04:00
|
|
|
Router.route('/', {
|
|
|
|
|
waitOn: function() {
|
2016-09-01 00:30:05 -04:00
|
|
|
if (!Meteor.userId()) {
|
2016-08-17 23:39:51 -04:00
|
|
|
this.redirect('/login');
|
|
|
|
|
} else {
|
|
|
|
|
return [
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('classes', this.params._id),
|
|
|
|
|
Meteor.subscribe('schools', this.params._id),
|
|
|
|
|
Meteor.subscribe('work', this.params._id),
|
|
|
|
|
Meteor.subscribe('requests', this.params._id),
|
|
|
|
|
Meteor.subscribe('users', this.params._id)
|
2016-08-17 23:39:51 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-09-01 00:13:17 -04:00
|
|
|
action: function() {
|
2016-08-12 17:18:30 -04:00
|
|
|
this.render("main");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Router.route('/login', function() {
|
|
|
|
|
if (!Meteor.userId()) {
|
|
|
|
|
this.render("login");
|
2016-09-01 00:13:17 -04:00
|
|
|
} else if (!Meteor.user().profile.school) {
|
2016-08-12 17:18:30 -04:00
|
|
|
this.redirect('/profile');
|
|
|
|
|
} else {
|
|
|
|
|
this.redirect('/');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-17 23:39:51 -04:00
|
|
|
Router.route('/profile', {
|
|
|
|
|
waitOn: function() {
|
|
|
|
|
if (!Meteor.userId()) {
|
|
|
|
|
this.redirect('/login');
|
|
|
|
|
} else {
|
|
|
|
|
return [
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('classes', this.params._id),
|
|
|
|
|
Meteor.subscribe('schools', this.params._id),
|
|
|
|
|
Meteor.subscribe('work', this.params._id),
|
|
|
|
|
Meteor.subscribe('requests', this.params._id),
|
|
|
|
|
Meteor.subscribe('users', this.params._id)
|
2016-08-17 23:39:51 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-09-04 20:20:40 -04:00
|
|
|
action: function() {
|
2016-08-12 17:18:30 -04:00
|
|
|
this.render("profile");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-09-05 13:44:18 -04:00
|
|
|
Router.route('/user/:email', {
|
|
|
|
|
template: 'user',
|
|
|
|
|
data: function() {
|
|
|
|
|
return Meteor.users.findOne({'services.google.email': this.params.email});
|
|
|
|
|
},
|
|
|
|
|
waitOn: function() {
|
|
|
|
|
return [
|
|
|
|
|
Meteor.subscribe('users', this.params._id)
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-25 23:09:12 -04:00
|
|
|
Router.route('/admin', {
|
2016-08-25 22:02:23 -04:00
|
|
|
waitOn: function() {
|
|
|
|
|
if (Roles.userIsInRole(Meteor.userId(), ['admin', 'superadmin'])) {
|
|
|
|
|
return [
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('classes', this.params._id),
|
|
|
|
|
Meteor.subscribe('schools', this.params._id),
|
|
|
|
|
Meteor.subscribe('work', this.params._id),
|
|
|
|
|
Meteor.subscribe('requests', this.params._id),
|
|
|
|
|
Meteor.subscribe('users', this.params._id)
|
2016-08-25 22:02:23 -04:00
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
this.render('NotFound');
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-09-04 20:20:40 -04:00
|
|
|
action: function() {
|
2016-08-16 06:15:15 -04:00
|
|
|
this.render("admin");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-12 17:18:30 -04:00
|
|
|
Router.configure({
|
|
|
|
|
notFoundTemplate: "NotFound"
|
2016-09-01 00:13:17 -04:00
|
|
|
});
|