admin : { 'type' : Boolean, 'default' : false }
});
+UserSchema.virtual( 'sanitized' ).get(function() {
+ var user = {
+ email: this.email,
+ name: this.name,
+ affil: this.affil,
+ showName: this.showName,
+ admin: this.admin
+ }
+
+ return user;
+});
+
UserSchema.virtual( 'displayName' )
.get( function() {
if( this.showName ) {
SchoolSchema.virtual( 'sanitized' ).get(function() {
var school = {
+ _id: this._id,
name: this.name,
description: this.description,
url: this.url
users : Array
});
+CourseSchema.virtual( 'sanitized' ).get(function() {
+ var course = {
+ _id: this._id,
+ name: this.name,
+ number: this.number || 'None',
+ description: this.description || 'None',
+ subject: this.subject || 'None',
+ department: this.department || 'None'
+ }
+
+ return course;
+});
+
CourseSchema.virtual( 'displayName' )
.get( function() {
if( this.number ) {
course : ObjectId
});
+LectureSchema.virtual( 'sanitized' ).get(function() {
+ var lecture = {
+ _id: this._id,
+ name: this.name,
+ date: this.date,
+ live: this.live
+ }
+
+ return lecture;
+})
+
LectureSchema.method( 'authorize', function( user, cb ) {
Course.findById( this.course, function( err, course ) {
if (course) {
collaborators : [String]
});
+NoteSchema.virtual( 'sanitized').get(function() {
+ var note = {
+ _id: this._id,
+ name: this.name,
+ path: this.path,
+ public: this.public,
+ roID: this.roID,
+ visits: this.visits
+ }
+
+ return note;
+});
+
NoteSchema.method( 'authorize', function( user, cb ) {
Lecture.findById( this.lecture, function( err, lecture ) {
if (lecture) {
text: String
})
+ArchivedNote.virtual( 'sanitized' ).get(function() {
+ var note = {
+ _id: this._id,
+ topic: this.topic === '' ? (this.text.replace(/(<(.|\n)*?>)|[\r\n\t]*/g, '')).substr(0, 15) + '...' : this.topic
+ }
+ return note;
+})
+
mongoose.model( 'ArchivedNote', ArchivedNote )
var ArchivedSubject = new Schema({