2014-11-28 20:49:41 -05:00
|
|
|
RootView = require 'views/core/RootView'
|
2014-01-03 13:32:13 -05:00
|
|
|
template = require 'templates/admin/users'
|
|
|
|
User = require 'models/User'
|
|
|
|
|
2014-07-17 20:16:32 -04:00
|
|
|
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
|
|
|
|
2014-04-10 16:09:44 -04: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
|