diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 3e19adc57..2de78fd88 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -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" diff --git a/app/templates/admin.jade b/app/templates/admin.jade index feb9d9347..229f51607 100644 --- a/app/templates/admin.jade +++ b/app/templates/admin.jade @@ -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 diff --git a/app/templates/admin/clas.jade b/app/templates/admin/clas.jade new file mode 100644 index 000000000..16c16c98e --- /dev/null +++ b/app/templates/admin/clas.jade @@ -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} + \ No newline at end of file diff --git a/app/views/admin/clas_view.coffee b/app/views/admin/clas_view.coffee new file mode 100644 index 000000000..873fa6584 --- /dev/null +++ b/app/views/admin/clas_view.coffee @@ -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 diff --git a/server/routes/db.coffee b/server/routes/db.coffee index fec290cfa..177182888 100644 --- a/server/routes/db.coffee +++ b/server/routes/db.coffee @@ -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..]