Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-08-28 20:03:30 -07:00
commit 9a59e38bd4
4 changed files with 18 additions and 4 deletions

View file

@ -313,7 +313,7 @@ module.exports = class ThangsTabView extends CocoView
createEssentialComponents: (defaultComponents) -> createEssentialComponents: (defaultComponents) ->
physicalConfig = {pos: {x: 10, y: 10, z: 1}} physicalConfig = {pos: {x: 10, y: 10, z: 1}}
if physicalOriginal = _.find(defaultComponents ? [], original: componentOriginals['physics.Physical']) if physicalOriginal = _.find(defaultComponents ? [], original: componentOriginals['physics.Physical'])
physicalConfig.pos.z = physicalOriginal.config.pos.z # Get the z right physicalConfig.pos.z = physicalOriginal.config?.pos?.z ? 1 # Get the z right
console.log physicalOriginal, defaultComponents, componentOriginals['physics.Physical'], physicalConfig console.log physicalOriginal, defaultComponents, componentOriginals['physics.Physical'], physicalConfig
[ [
{original: componentOriginals['existence.Exists'], majorVersion: 0, config: {}} {original: componentOriginals['existence.Exists'], majorVersion: 0, config: {}}

View file

@ -6,6 +6,7 @@ log = require 'winston'
Patch = require '../patches/Patch' Patch = require '../patches/Patch'
User = require '../users/User' User = require '../users/User'
sendwithus = require '../sendwithus' sendwithus = require '../sendwithus'
hipchat = require '../hipchat'
PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1, created: 1, permissions: 1} PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1, created: 1, permissions: 1}
FETCH_LIMIT = 300 FETCH_LIMIT = 300
@ -370,6 +371,8 @@ module.exports = class Handler
parentDocument.makeNewMajorVersion(updatedObject, done) parentDocument.makeNewMajorVersion(updatedObject, done)
notifyWatchersOfChange: (editor, changedDocument, editPath) -> notifyWatchersOfChange: (editor, changedDocument, editPath) ->
docLink = "http://codecombat.com#{editPath}"
@sendChangedHipChatMessage creator: editor, target: changedDocument, docLink: docLink
watchers = changedDocument.get('watchers') or [] watchers = changedDocument.get('watchers') or []
watchers = (w for w in watchers when not w.equals(editor.get('_id'))) watchers = (w for w in watchers when not w.equals(editor.get('_id')))
return unless watchers.length return unless watchers.length
@ -390,9 +393,20 @@ module.exports = class Handler
commit_message: changedDocument.get('commitMessage') commit_message: changedDocument.get('commitMessage')
sendwithus.api.send context, (err, result) -> sendwithus.api.send context, (err, result) ->
sendChangedHipChatMessage: (options) ->
message = "#{options.creator.get('name')} saved a change to <a href=\"#{options.docLink}\">#{options.target.get('name')}</a>: #{options.target.get('commitMessage')}"
hipchat.sendHipChatMessage message
makeNewInstance: (req) -> makeNewInstance: (req) ->
model = new @modelClass({}) model = new @modelClass({})
model.set 'watchers', [req.user.get('_id')] if @modelClass.schema.is_patchable if @modelClass.schema.is_patchable
watchers = [req.user.get('_id')]
if req.user.isAdmin() # https://github.com/codecombat/codecombat/issues/1105
nick = mongoose.Types.ObjectId('512ef4805a67a8c507000001')
scott = mongoose.Types.ObjectId('5162fab9c92b4c751e000274')
watchers.push nick unless _.find watchers, (id) -> id.equals nick
watchers.push scott unless _.find watchers, (id) -> id.equals scott
model.set 'watchers', watchers
model model
validateDocumentInput: (input) -> validateDocumentInput: (input) ->

View file

@ -22,5 +22,5 @@ module.exports.addDelightedUser = addDelightedUser = (user) ->
gender: user.get('gender') gender: user.get('gender')
lastLevel: user.get('lastLevel') lastLevel: user.get('lastLevel')
request.post {uri: "https://#{key}:@api.delightedapp.com/v1/people.json", form: form}, (err, res, body) -> request.post {uri: "https://#{key}:@api.delightedapp.com/v1/people.json", form: form}, (err, res, body) ->
return log.error 'Error sending Delighted request:', err or body if err or /error/.test body return log.error 'Error sending Delighted request:', err or body if err or /error/i.test body
#log.info "Got DelightedApp response: #{body}" #log.info "Got DelightedApp response: #{body}"

View file

@ -12,5 +12,5 @@ module.exports.sendHipChatMessage = sendHipChatMessage = (message) ->
messageFormat: 'html' messageFormat: 'html'
url = "https://api.hipchat.com/v2/room/#{roomID}/notification?auth_token=#{key}" url = "https://api.hipchat.com/v2/room/#{roomID}/notification?auth_token=#{key}"
request.post {uri: url, json: form}, (err, res, body) -> request.post {uri: url, json: form}, (err, res, body) ->
return log.error 'Error sending HipChat patch request:', err or body if err or /error/.test body return log.error 'Error sending HipChat patch request:', err or body if err or /error/i.test body
#log.info "Got HipChat patch response:", body #log.info "Got HipChat patch response:", body