mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-12 00:31:21 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
8a074b7777
5 changed files with 21 additions and 8 deletions
|
@ -22,6 +22,7 @@ before_install:
|
|||
- npm install -g npm@latest
|
||||
|
||||
before_script:
|
||||
- npm update
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
- "node index.js --unittest &"
|
||||
|
|
|
@ -11,6 +11,7 @@ _.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.'}
|
||||
|
||||
c.extendBasicProperties CourseSchema, 'Course'
|
||||
|
||||
|
|
|
@ -142,7 +142,9 @@ module.exports =
|
|||
database.assignBody(req, classroom)
|
||||
|
||||
# Copy over data from how courses are right now
|
||||
courses = yield Course.find()
|
||||
query = {}
|
||||
query = {adminOnly: {$ne: true}} unless req.user?.isAdmin()
|
||||
courses = yield Course.find(query)
|
||||
campaigns = yield Campaign.find({_id: {$in: (course.get('campaignID') for course in courses)}})
|
||||
campaignMap = {}
|
||||
campaignMap[campaign.id] = campaign for campaign in campaigns
|
||||
|
|
|
@ -49,3 +49,12 @@ module.exports =
|
|||
level = yield dbq
|
||||
level = level.toObject({req: req})
|
||||
res.status(200).send(level)
|
||||
|
||||
get: (Model, options={}) -> wrap (req, res) ->
|
||||
# Don't use standard rest middleware get, because we want to filter out adminOnly courses for non-admins
|
||||
query = {}
|
||||
query = {adminOnly: {$ne: true}} unless req.user?.isAdmin()
|
||||
dbq = Model.find(query)
|
||||
dbq.select(parse.getProjectFromReq(req))
|
||||
results = yield database.viewSearch(dbq, req)
|
||||
res.send(results)
|
||||
|
|
|
@ -79,7 +79,7 @@ module.exports.setup = (app) ->
|
|||
app.get('/db/codelogs', mw.auth.checkHasPermission(['admin']), mw.rest.get(CodeLog))
|
||||
|
||||
Course = require '../models/Course'
|
||||
app.get('/db/course', mw.rest.get(Course))
|
||||
app.get('/db/course', mw.courses.get(Course))
|
||||
app.get('/db/course/:handle', mw.rest.getByHandle(Course))
|
||||
app.get('/db/course/:handle/levels/:levelOriginal/next', mw.courses.fetchNextLevel)
|
||||
|
||||
|
|
Loading…
Reference in a new issue