Refactor CLAsView to use view in template

This commit is contained in:
Scott Erickson 2015-10-26 14:35:42 -07:00
parent 58eaec8e6b
commit 45044d06a4
2 changed files with 8 additions and 13 deletions
app
templates/admin
views/admin

View file

@ -6,11 +6,13 @@ block content
table.table.table-striped.table-bordered.table-condensed#clas
tbody
each cla in clas
- var models = view.clas.models
- var models = _.uniq(models, true, function(model) { return model.get('githubUsername'); });
each cla in models
tr
td #{cla.name}
td #{cla.get('name')}
if me.isAdmin()
td #{cla.email}
td #{cla.githubUsername}
td #{cla.created}
td #{cla.get('email')}
td #{cla.get('githubUsername')}
td #{cla.get('created')}

View file

@ -11,6 +11,7 @@ class CLASubmission extends CocoModel
class CLACollection extends CocoCollection
url: '/db/cla.submissions'
model: CLASubmission
comparator: (claSubmission) -> return (claSubmission.get('githubUsername') or 'zzzzz').toLowerCase()
module.exports = class CLAsView extends RootView
id: 'admin-clas-view'
@ -19,11 +20,3 @@ module.exports = class CLAsView extends RootView
constructor: (options) ->
super options
@clas = @supermodel.loadCollection(new CLACollection(), 'clas', {cache: false}).model
getRenderData: ->
c = super()
c.clas = []
if @supermodel.finished()
c.clas = _.uniq (_.sortBy (cla.attributes for cla in @clas.models), (m) ->
m.githubUsername?.toLowerCase()), 'githubUsername'
c