codecombat/app/views/cla_view.coffee

32 lines
802 B
CoffeeScript
Raw Normal View History

2014-01-03 13:32:13 -05:00
View = require 'views/kinds/RootView'
template = require 'templates/cla'
{me} = require 'lib/auth'
module.exports = class CLAView extends View
id: "cla-view"
template: template
2014-01-03 13:32:13 -05:00
events:
'click #agreement-button': 'onAgree'
2014-01-03 13:32:13 -05:00
getRenderData: ->
c = super()
c.signedOn = moment(me.get('signedCLA')).format('LLLL') if me.get('signedCLA')
c
2014-01-03 13:32:13 -05:00
onAgree: ->
@$el.find('#agreement-button').prop('disabled', true).text('Saving')
2014-01-03 13:32:13 -05:00
$.ajax({
url: "/db/user/me/agreeToCLA"
data: { 'githubUsername': @$el.find('#github-username').val() }
method: 'POST'
success: @onAgreeSucceeded
error: @onAgreeFailed
})
2014-01-03 13:32:13 -05:00
onAgreeSucceeded: =>
@$el.find('#agreement-button').text('Success')
onAgreeFailed: =>
@$el.find('#agreement-button').text('Failed')