Added StackLead integration. Employerified profile backgrounds.

This commit is contained in:
Nick Winter 2014-06-14 20:59:28 -07:00
parent babfa04a9e
commit 66e2805a9a
6 changed files with 45 additions and 5 deletions

View file

@ -63,6 +63,7 @@
td:nth-child(7) select
min-width: 100px
#employers-view, #profile-view.viewed-by-employer
#outer-content-wrapper, #intermediate-content-wrapper, #inner-content-wrapper
background: #949494

View file

@ -233,6 +233,8 @@ module.exports = class ProfileView extends View
afterRender: ->
super()
if me.get('employerAt')
@$el.addClass 'viewed-by-employer'
return unless @user
unless @user.get('jobProfile')?.projects?.length or @editing
@$el.find('.right-column').hide()
@ -269,6 +271,9 @@ module.exports = class ProfileView extends View
active = not @user.get('jobProfile').active
@user.get('jobProfile').active = active
@saveEdits()
if active and not (me.isAdmin() or @stackLed)
$.post "/stacklead"
@stackLed = true
enterEspionageMode: ->
postData = emailLower: @user.get('email').toLowerCase(), usernameLower: @user.get('name').toLowerCase()

View file

@ -83,7 +83,7 @@ module.exports = class EmployerSignupView extends View
alert "There was an error signing the contract. Please contact team@codecombat.com with this error: #{error.responseText}"
checkForFormSubmissionEnterPress: (e) ->
if e.which is 13
if e.which is 13
if $("#signup-email").val() isnt '' and $("#signup-password").val() isnt ''
@createAccount(e)
else if $("#more-info-email").val() isnt ''
@ -104,7 +104,7 @@ module.exports = class EmployerSignupView extends View
return forms.applyErrorsToForm(el, res.errors) unless res.valid
@enableModalInProgress(el)
auth.createUserWithoutReload userObject, null
submitMoreInfoEmail: (e) =>
emailAddress = $("#more-info-email").val()
window.tracker?.trackEvent 'Employer requested more information.'
@ -121,7 +121,8 @@ module.exports = class EmployerSignupView extends View
message: "THIS IS AN AUTOMATED MESSAGE FROM THE EMPLOYER SIGNUP FORM \n Please send me more info about hiring CodeCombat players."
success: successFunc
error: errorFunc
$.post "/stacklead", email: emailAddress
setHashToOpenModalAutomatically: (e) ->
window.location.hash = "employerSignupLoggingIn"

View file

@ -1,4 +1,3 @@
module.exports.handlers =
'article': 'articles/article_handler'
'level': 'levels/level_handler'
@ -24,4 +23,5 @@ module.exports.routes =
'routes/mail'
'routes/sprites'
'routes/queue'
'routes/stacklead'
]

View file

@ -0,0 +1,32 @@
config = require '../../server_config'
request = require 'request'
log = require 'winston'
module.exports.setup = (app) ->
app.post '/stacklead', (req, res) ->
return res.end() unless req.user
email = req.body.email or req.user.get 'email'
sendStackLead email, req.user
return res.end()
module.exports.sendStackLead = sendStackLead = (email, user) ->
return unless key = config.mail.stackleadAPIKey
form = email: email, api_key: key
if user
form.first_name = firstName if firstName = user.get('firstName')
form.last_name = lastName if lastName = user.get('lastName')
if profile = user.get 'jobProfile'
form.name = name if name = profile.name
form.location = location if location = profile.city
form.location = location if location = profile.city
for link in (profile.links ? [])
form.linkedin = link.link if /linkedin/.test link.link
form.twitter = link.link if /twitter/.test link.link
form.company = company if company = profile.work?[0]?.employer
if linkedIn = user.get('signedEmployerAgreement')?.data
form.first_name = data.firstName if data.firstName
form.last_name = data.lastName if data.lastName
form.linkedin = data.publicProfileUrl if data.publicProfileUrl
data.company = company if company = data.positions?.values?[0]?.company?.name
request.post {uri: "https://stacklead.com/api/leads", form: form}, (err, res, body) ->
return log.error "Error sending StackLead request:", err or body if err or /error/.test body

View file

@ -26,9 +26,10 @@ config.mail =
mailchimpAPIKey: process.env.COCO_MAILCHIMP_API_KEY or ""
mailchimpWebhook: process.env.COCO_MAILCHIMP_WEBHOOK or "/mail/webhook"
sendwithusAPIKey: process.env.COCO_SENDWITHUS_API_KEY or ""
stackleadAPIKey: process.env.COCO_STACKLEAD_API_KEY or ""
cronHandlerPublicIP: process.env.COCO_CRON_PUBLIC_IP or ""
cronHandlerPrivateIP: process.env.COCO_CRON_PRIVATE_IP or ""
config.queue =
accessKeyId: process.env.COCO_AWS_ACCESS_KEY_ID or ""
secretAccessKey: process.env.COCO_AWS_SECRET_ACCESS_KEY or ""