2014-05-18 09:04:54 -04:00
|
|
|
Achievement = require './Achievement'
|
|
|
|
Handler = require '../commons/Handler'
|
|
|
|
|
|
|
|
class AchievementHandler extends Handler
|
|
|
|
modelClass: Achievement
|
|
|
|
|
2014-05-18 10:04:50 -04:00
|
|
|
# Used to determine which properties requests may edit
|
2014-05-22 10:59:01 -04:00
|
|
|
editableProperties: ['name', 'query', 'worth', 'collection', 'description', 'userField', 'proportionalTo', 'icon']
|
2014-05-18 09:04:54 -04:00
|
|
|
jsonSchema = require '../../app/schemas/models/achievement.coffee'
|
|
|
|
|
2014-05-18 10:04:50 -04:00
|
|
|
hasAccess: (req) ->
|
|
|
|
req.method is 'GET' or req.user?.isAdmin()
|
|
|
|
|
2014-05-19 18:05:21 -04:00
|
|
|
get: (req, res) ->
|
2014-05-18 09:04:54 -04:00
|
|
|
query = @modelClass.find({})
|
|
|
|
query.exec (err, documents) =>
|
|
|
|
return @sendDatabaseError(res, err) if err
|
|
|
|
documents = (@formatEntity(req, doc) for doc in documents)
|
|
|
|
@sendSuccess(res, documents)
|
|
|
|
|
2014-05-19 18:05:21 -04:00
|
|
|
module.exports = new AchievementHandler()
|