mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Adding CLAs view.
This commit is contained in:
parent
b30bf35945
commit
ba66dbf5a1
5 changed files with 60 additions and 0 deletions
|
@ -249,6 +249,7 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr
|
|||
av_other_debug_base_url: "Base (for debugging base.jade)"
|
||||
u_title: "User List"
|
||||
lg_title: "Latest Games"
|
||||
clas: "CLAs"
|
||||
|
||||
editor:
|
||||
main_title: "CodeCombat Editors"
|
||||
|
|
|
@ -29,3 +29,5 @@ block content
|
|||
ul
|
||||
li
|
||||
a(href="/admin/base", data-i18n="admin.av_other_debug_base_url") Base (for debugging base.jade)
|
||||
li
|
||||
a(href="/admin/clas", data-i18n="admin.clas") CLAs
|
||||
|
|
15
app/templates/admin/clas.jade
Normal file
15
app/templates/admin/clas.jade
Normal file
|
@ -0,0 +1,15 @@
|
|||
extends /templates/base
|
||||
|
||||
block content
|
||||
|
||||
h1(data-i18n="admin.clas") CLAs
|
||||
|
||||
table.table.table-striped.table-bordered.table-condensed#clas
|
||||
tbody
|
||||
each cla in clas
|
||||
tr
|
||||
td #{cla.name}
|
||||
td #{cla.email}
|
||||
td #{cla.githubUsername}
|
||||
td #{cla.created}
|
||||
|
30
app/views/admin/clas_view.coffee
Normal file
30
app/views/admin/clas_view.coffee
Normal file
|
@ -0,0 +1,30 @@
|
|||
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()
|
||||
@clas.on '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
|
|
@ -2,8 +2,20 @@ log = require 'winston'
|
|||
errors = require '../commons/errors'
|
||||
handlers = require('../commons/mapping').handlers
|
||||
schemas = require('../commons/mapping').schemas
|
||||
mongoose = require 'mongoose'
|
||||
|
||||
module.exports.setup = (app) ->
|
||||
# This is hacky and should probably get moved somewhere else, I dunno
|
||||
app.get '/db/cla.submissions', (req, res) ->
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
collection = mongoose.connection.db.collection 'cla.submissions', (err, collection) ->
|
||||
return log.error "Couldn't fetch CLA submissions because #{err}" if err
|
||||
resultCursor = collection.find {}
|
||||
resultCursor.toArray (err, docs) ->
|
||||
return log.error "Couldn't fetch distinct CLA submissions because #{err}" if err
|
||||
res.send docs
|
||||
res.end
|
||||
|
||||
app.all '/db/*', (req, res) ->
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
module = req.path[4..]
|
||||
|
|
Loading…
Reference in a new issue