challneges: semi-functional challenge creation for parties

This commit is contained in:
Tyler Renelle
2013-05-12 16:47:18 +01:00
parent 5ea6e55e11
commit b8ef0789df
2 changed files with 26 additions and 4 deletions
+14 -2
View File
@@ -1,4 +1,9 @@
_ = require 'underscore'
module.exports.app = (appExports, model) ->
browser = require './browser'
helpers = require './helpers'
user = model.at '_user'
appExports.challengeCreate = ->
@@ -12,8 +17,15 @@ module.exports.app = (appExports, model) ->
model.set '_challenge.creating', true
appExports.challengeSave = ->
#TODO
challenge = _.defaults model.get('_challenge.new'),
id: model.id()
uuid: user.get('id')
user: helpers.username(model.get('_user.auth'), model.get('_user.profile.name'))
timestamp: +new Date
model.unshift '_party.challenges', challenge
challengeDiscard()
browser.growlNotification('Challenge Created','success')
appExports.challengeDiscard = ->
appExports.challengeDiscard = challengeDiscard = ->
model.set '_challenge.new', {}
model.set '_challenge.creating', false