A couple mirror match ladder tweaks. Made programmableMethods other code languages use proper code formatting.

This commit is contained in:
Nick Winter 2015-09-07 18:00:48 -07:00
parent 0549994693
commit 0d2d1ddad0
3 changed files with 10 additions and 13 deletions

View file

@ -256,12 +256,7 @@ class CodeTreema extends TreemaNode.nodeMap.ace
constructor: ->
super(arguments...)
@workingSchema.aceTabSize = 4
buildValueForEditing: (valEl, data) ->
super(valEl, data)
if not @workingSchema.aceMode and mode = codeLanguages[@keyForParent]
@editor.getSession().setMode mode
valEl
@workingSchema.aceMode ?= mode if mode = codeLanguages[@keyForParent]
class CoffeeTreema extends CodeTreema
constructor: ->

View file

@ -74,7 +74,7 @@ module.exports = class LadderSubmissionView extends CocoView
data: ajaxData
success: success
error: failure
if @mirrorSession
if @mirrorSession and @mirrorSession.get('submittedCode')
# Also submit the mirrorSession after the main session submits successfully.
mirrorAjaxData = _.clone ajaxData
mirrorAjaxData.session = @mirrorSession.id

View file

@ -21,21 +21,23 @@ module.exports = createNewTask = (req, res) ->
fetchInitialSessionsToRankAgainst.bind(yetiGuru, requestLevelMajorVersion, originalLevelID)
generateAndSendTaskPairsToTheQueue
], (err, successMessageObject) ->
if err? then return errors.serverError res, "There was an error submitting the game to the queue:#{err}"
if err? then return errors.serverError res, "There was an error submitting the game to the queue: #{err}"
scoringUtils.sendResponseObject res, successMessageObject
validatePermissions = (req, sessionID, callback) ->
return callback 'You are unauthorized to submit that game to the simulator' unless req.user?.get('email')
return callback 'You are unauthorized to submit that game to the simulator.' unless req.user?.get('email')
return callback null if req.user?.isAdmin()
findParameters = _id: sessionID
selectString = 'creator submittedCode code'
LevelSession.findOne(findParameters).select(selectString).lean().exec (err, retrievedSession) ->
LevelSession.findOne(findParameters).select(selectString).lean().exec (err, retrievedSession) =>
if err? then return callback err
userHasPermissionToSubmitCode = retrievedSession.creator is req.user?.id and
not _.isEqual(retrievedSession.code, retrievedSession.submittedCode)
unless userHasPermissionToSubmitCode then return callback 'You are unauthorized to submit that game to the simulator'
userHasPermissionToSubmitCode = retrievedSession.creator is req.user?.id
unless userHasPermissionToSubmitCode then return callback 'You are unauthorized to submit that game to the simulator.'
# Disabling this for now, since mirror matches submit different transpiled code for the same source code.
#alreadySubmitted = _.isEqual(retrievedSession.code, retrievedSession.submittedCode)
#unless alreadySubmitted then return callback 'You have already submitted that exact code for simulation.'
callback null