codecombat/app/views/admin/UsersView.coffee

45 lines
1.2 KiB
CoffeeScript
Raw Normal View History

RootView = require 'views/kinds/RootView'
2014-01-03 13:32:13 -05:00
template = require 'templates/admin/users'
User = require 'models/User'
module.exports = class UsersView extends RootView
2014-01-03 13:32:13 -05:00
# TODO: Pagination, choosing filters on the page itself.
2014-06-30 22:16:26 -04:00
id: 'admin-users-view'
2014-01-03 13:32:13 -05:00
template: template
constructor: (options) ->
super options
@getUsers()
getUsers: ->
# can have this page show arbitrary conditions, see mongoose queries
# http://mongoosejs.com/docs/queries.html
# Each list in conditions is a function call.
# The first arg is the function name
# The rest are the agrs for the function
conditions = [
['limit', 20]
['sort', '-dateCreated']
['where', 'anonymous']
['equals', false]
#['where', 'email']
#['equals', 'sderickson@gmail.com']
#['where', 'dateCreated']
#['lt', (new Date()).toString()]
]
conditions = $.param({conditions:JSON.stringify(conditions)})
UserCollection = Backbone.Collection.extend({
model: User
url: '/db/user?' + conditions
})
@users = new UserCollection()
@users.fetch()
2014-03-24 02:53:41 -04:00
@listenTo(@users, 'all', @render)
2014-01-03 13:32:13 -05:00
getRenderData: ->
2014-01-03 13:32:13 -05:00
c = super()
c.users = (user.attributes for user in @users.models)
2014-06-30 22:16:26 -04:00
c