diff --git a/app/collections/Courses.coffee b/app/collections/Courses.coffee index 7c89698d9..7eba81467 100644 --- a/app/collections/Courses.coffee +++ b/app/collections/Courses.coffee @@ -4,3 +4,8 @@ CocoCollection = require 'collections/CocoCollection' module.exports = class Courses extends CocoCollection model: Course url: '/db/course' + + fetchReleased: (options = {}) -> + options.data ?= {} + options.data.releasePhase = 'released' + @fetch(options) diff --git a/app/schemas/models/course.schema.coffee b/app/schemas/models/course.schema.coffee index 773fc5509..05b7e9697 100644 --- a/app/schemas/models/course.schema.coffee +++ b/app/schemas/models/course.schema.coffee @@ -11,7 +11,8 @@ _.extend CourseSchema.properties, pricePerSeat: {type: 'number', description: 'Price per seat in USD cents.'} # deprecated free: { type: 'boolean' } screenshot: c.url {title: 'URL', description: 'Link to course screenshot.'} - adminOnly: {type: 'boolean', description: 'Whether the course is in admin-only testing mode still and will not show up for normal users.'} + adminOnly: { type: 'boolean', description: 'Deprecated in favor of releasePhase.' } + releasePhase: { type: {enum: ['beta', 'released'] }, description: "How far along the course's development is, determining who sees it." } c.extendBasicProperties CourseSchema, 'Course' diff --git a/app/views/NewHomeView.coffee b/app/views/NewHomeView.coffee index e57c0f403..3b75505fc 100644 --- a/app/views/NewHomeView.coffee +++ b/app/views/NewHomeView.coffee @@ -3,7 +3,7 @@ template = require 'templates/new-home-view' CocoCollection = require 'collections/CocoCollection' TrialRequest = require 'models/TrialRequest' TrialRequests = require 'collections/TrialRequests' -Course = require 'models/Course' +Courses = require 'collections/Courses' utils = require 'core/utils' storage = require 'core/storage' {logoutUser, me} = require('core/auth') @@ -36,8 +36,8 @@ module.exports = class NewHomeView extends RootView 'esc': 'onEscapePressed' initialize: (options) -> - @courses = new CocoCollection [], {url: "/db/course", model: Course} - @supermodel.loadCollection(@courses, 'courses') + @courses = new Courses() + @supermodel.trackRequest @courses.fetchReleased() if me.isTeacher() @trialRequests = new TrialRequests() diff --git a/app/views/courses/TeacherCoursesView.coffee b/app/views/courses/TeacherCoursesView.coffee index 018326881..d1cf6d024 100644 --- a/app/views/courses/TeacherCoursesView.coffee +++ b/app/views/courses/TeacherCoursesView.coffee @@ -1,7 +1,7 @@ app = require 'core/application' CocoCollection = require 'collections/CocoCollection' CocoModel = require 'models/CocoModel' -Course = require 'models/Course' +Courses = require 'collections/Courses' Campaigns = require 'collections/Campaigns' Classroom = require 'models/Classroom' Classrooms = require 'collections/Classrooms' @@ -40,8 +40,8 @@ module.exports = class TeacherCoursesView extends RootView @ownedClassrooms = new Classrooms() @ownedClassrooms.fetchMine({data: {project: '_id'}}) @supermodel.trackCollection(@ownedClassrooms) - @courses = new CocoCollection([], { url: "/db/course", model: Course}) - @supermodel.loadCollection(@courses, 'courses') + @courses = new Courses() + @supermodel.trackRequest @courses.fetchReleased() @campaigns = new Campaigns() @supermodel.trackRequest @campaigns.fetchByType('course', { data: { project: 'levels,levelsUpdated' } }) @ diff --git a/scripts/mongodb/updateCourses.js b/scripts/mongodb/updateCourses.js index c569904b9..90e2355d2 100644 --- a/scripts/mongodb/updateCourses.js +++ b/scripts/mongodb/updateCourses.js @@ -2,6 +2,7 @@ // Usage: // mongo
:/