mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Added achievement model and some missing pieces
This commit is contained in:
parent
1b2a251c58
commit
c26f96f33e
4 changed files with 12 additions and 1 deletions
6
app/models/Achievement.coffee
Normal file
6
app/models/Achievement.coffee
Normal file
|
@ -0,0 +1,6 @@
|
|||
CocoModel = require './CocoModel'
|
||||
|
||||
module.exports = class Achievement extends CocoModel
|
||||
@className: 'Achievement'
|
||||
@schema: require 'schemas/models/achievement'
|
||||
urlRoot: '/db/achievement'
|
|
@ -31,6 +31,7 @@ module.exports = class SearchView extends View
|
|||
'shown.bs.modal #new-model-modal': 'focusOnName'
|
||||
'hidden.bs.modal #new-model-modal': 'onModalHidden'
|
||||
|
||||
|
||||
constructor: (options) ->
|
||||
@runSearch = _.debounce(@runSearch, 500)
|
||||
super options
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
mongoose = require('mongoose')
|
||||
plugins = require('../plugins/plugins')
|
||||
jsonschema = require('../../app/schemas/models/achievement')
|
||||
|
||||
# `pre` and `post` are not called for update operations executed directly on the database,
|
||||
|
@ -10,4 +11,7 @@ AchievementSchema = new mongoose.Schema({
|
|||
query: Object
|
||||
}, {strict: false})
|
||||
|
||||
AchievementSchema.plugin(plugins.SearchablePlugin, {searchable: ['name']})
|
||||
AchievementSchema.plugin(plugins.NamedPlugin)
|
||||
|
||||
module.exports = Achievement = mongoose.model('Achievement', AchievementSchema)
|
|
@ -153,10 +153,10 @@ module.exports = class Handler
|
|||
return @sendDatabaseError(res, err) if err
|
||||
@sendSuccess(res, @formatEntity(req, document))
|
||||
|
||||
# project=true or project=name,description,slug for example
|
||||
search: (req, res) ->
|
||||
unless @modelClass.schema.uses_coco_search
|
||||
return @sendNotFoundError(res)
|
||||
|
||||
term = req.query.term
|
||||
matchedObjects = []
|
||||
filters = [{filter: {index: true}}]
|
||||
|
|
Loading…
Reference in a new issue