mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
21 lines
No EOL
730 B
CoffeeScript
21 lines
No EOL
730 B
CoffeeScript
Achievement = require './Achievement'
|
|
Handler = require '../commons/Handler'
|
|
|
|
class AchievementHandler extends Handler
|
|
modelClass: Achievement
|
|
|
|
# Used to determine which properties requests may edit
|
|
editableProperties: ['name', 'query', 'worth', 'model', 'description', 'userField', 'proportionalTo']
|
|
jsonSchema = require '../../app/schemas/models/achievement.coffee'
|
|
|
|
hasAccess: (req) ->
|
|
req.method is 'GET' or req.user?.isAdmin()
|
|
|
|
getAll: (req, res) ->
|
|
query = @modelClass.find({})
|
|
query.exec (err, documents) =>
|
|
return @sendDatabaseError(res, err) if err
|
|
documents = (@formatEntity(req, doc) for doc in documents)
|
|
@sendSuccess(res, documents)
|
|
|
|
module.exports = new AchievementHandler() |