codecombat/app/views/admin/clas_view.coffee
2014-03-24 22:28:34 +05:30

30 lines
731 B
CoffeeScript

View = require 'views/kinds/RootView'
template = require 'templates/admin/clas'
module.exports = class CLAsView extends View
id: "admin-clas-view"
template: template
startsLoading: true
constructor: (options) ->
super options
@getCLAs()
getCLAs: ->
CLACollection = Backbone.Collection.extend({
url: '/db/cla.submissions'
})
@clas = new CLACollection()
@clas.fetch()
@listenTo(@clas, 'sync', @onCLAsLoaded)
onCLAsLoaded: ->
@startsLoading = false
@render()
getRenderData: ->
c = super()
c.clas = []
unless @startsLoading
c.clas = _.uniq (_.sortBy (cla.attributes for cla in @clas.models), (m) -> m.githubUsername?.toLowerCase()), 'githubUsername'
c