Skip to content

Instantly share code, notes, and snippets.

@zv
Last active August 29, 2015 14:13
Show Gist options
  • Save zv/70d2787987cb4217a7d7 to your computer and use it in GitHub Desktop.
Save zv/70d2787987cb4217a7d7 to your computer and use it in GitHub Desktop.
Generated
// Sections
attributes: {
name: {
type: 'text',
required: true
},
description: {
type: 'text'
},
listing: {
type: 'text',
required: true
},
location: {
type: 'text'
},
enrolled: {
type: 'integer'
},
catalog_number: {
type: 'text'
},
/*
* Schedule is an array of objects representing meeting times.
* [{day: 1, time: '9:00'}, // Monday @ 9:00AM,
* {day: 3, time: '9:00'}, // Wednesday @ 9:00AM,
* {day: 5, time: '24:00'}] // Friday @ 9:00AM
*/
schedule: {
type: 'json'
},
instructors: {
type: 'json'
},
// Write agenda method
// Associations
course: {
model: 'course'
},
secondaries: {
collection: 'section',
via: 'primary'
},
primary: {
model: 'section'
},
tasks: {
collection: 'task',
via: 'course'
},
term: {
model: 'term'
},
// Methods
agenda: function() {
// Create a weekly to day map
// this.schedule;
// Find a school with the id of my school course.
// this.course.school.term
// Count the number of weeks in the term
// Look up my tasks and attach that information
}
}
};
/**
* Term.js
*
* @description :: Represents a school term
*/
module.exports = {
tableName: 'terms',
attributes: {
name : { type: 'string' },
start : { type: 'date' },
end : { type: 'date' },
// Associations
school: {
model: 'school'
},
courses: {
collection: 'course',
via: 'term'
},
sections: {
collection: 'sections',
via: 'term'
}
}
};
// Course
/**
* Course.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
*/
module.exports = {
attributes: {
title: {
type: 'string'
},
status: {
type: 'string',
defaultsTo: 'syllabus_needed',
enum: [
// Syllabus Needed
'pending_syllabus',
// In Queue For Translation
'queued_translation',
// Translation in progress
'pending_translation',
// Translation in review
'pending_review',
// Awaiting no syllabus confirmation
'pending_syllabus_absence_confirmation',
// The translation is fundamentally problematic
'error',
// The translation has been rejected
'rejected',
// Course Live
'live'
]
},
subject: { type: 'string' },
division: { type: 'string' },
meta: { type: 'json' },
/** Associations ***********************************************************/
school: { model: 'school' },
term: {
model: 'term'
},
sections: {
collection: 'section',
via: 'course'
}
}
};
// Task
/**
* Task.js
*
* @description :: Tasks are arguably the core model of the Quad application, they contain the information
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName: 'tasks',
attributes: {
title: {
type: 'text',
required: true
},
category: {
type: 'text'
// Should be an enum
},
/**
* `due` can store two different types of due date data contingent on due.type:
* @property {string} due.type - Indicates how the due date will be stored
* @property {datetime} due.date - If type == 'abs' this field
stores the absolute due date expressed as a
JS date.
* @property {number} due.meeting - If type == 'rel' this field
stores the due date expressed as the 0-indexed
section meeting.
* @example
* Absolute Time:
{ type: 'abs', time: Thu Jan 15 2015 17:11:32 GMT-0800 (PST) }
* Term Relative:
{ type: 'rel', meeting: 11 }
*/
due: {
type: 'json'
},
location: { type: 'text' },
details: { type: 'text' },
deleted: {
type: 'boolean',
defaultsTo: 'false',
required: true
},
/*************************************************************
* Revisions stores the complete history of this task's editing history
* @example
* [ { revised: Thu Jan 15 2015 17:02:57 GMT-0800 (PST),
* // user_id of revision author
* author: 1083,
* fields_revised: [ 'details', 'due' ],
* // Previous is an array the editable fields as the time of revision
* previous:
* [{ title: 'Intricate Security Protocols',
* category: 'homework',
* due: 1421370176045,
* location: '242 Wheeler',
* details: 'Mess with the best die like the rest',
* deleted: false }] } ]
*/
revisions: {
type: 'json',
defaultsTo: []
},
/** Associations ***********************************************************/
course: { model: 'section' },
owner: { model: 'user' }
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment