disable parties, merge in private, back to old REST, hide "next day" button

This commit is contained in:
Tyler Renelle 2013-02-04 17:43:30 -05:00
parent 57a7edc5d3
commit c62b2d3e05
4 changed files with 72 additions and 8 deletions

View file

@ -84,9 +84,9 @@ updateStats = (newStats, batch) ->
# Set to object, then also send to browser right away to get model.on() subscription notification
batch.set 'items.itemsEnabled', true
obj.items.itemsEnabled = true
if !obj.flags.partyEnabled and obj.stats.lvl >= 3
batch.set 'flags.partyEnabled', true
obj.flags.partyEnabled = true
# if !obj.flags.partyEnabled and obj.stats.lvl >= 3
# batch.set 'flags.partyEnabled', true
# obj.flags.partyEnabled = true
obj.stats.exp = newStats.exp
if newStats.money?

View file

@ -1,6 +1,69 @@
_ = require 'underscore'
module.exports.middleware = (req, res, next) ->
model = req.getModel()
model.set '_stripePubKey', process.env.STRIPE_PUB_KEY
return next()
module.exports.app= (appExports, model) ->
module.exports.app = (appExports, model) ->
module.exports.routes = (expressApp) ->
appExports.showStripe = (e, el) ->
token = (res) ->
console.log(res);
$.ajax({
type:"POST",
url:"/charge",
data:res
}).success ->
window.location.href = "/"
.error (err) ->
alert err.responseText
StripeCheckout.open
key: model.get('_stripePubKey')
address: false
amount: 500
name: "Checkout"
description: "Removes ads and grants 20 additional tokens."
panelLabel: "Checkout"
token: token
###
Buy Reroll Button
###
appExports.buyReroll = (e, el, next) ->
user = model.at('_user')
tasks = user.get('tasks')
user.set('balance', user.get('balance')-1)
_.each tasks, (task) -> task.value = 0 unless task.type == 'reward'
user.set('tasks', tasks)
window.DERBY.app.dom.clear()
window.DERBY.app.view.render(model)
module.exports.routes = (expressApp) ->
###
Setup Stripe response when posting payment
###
expressApp.post '/charge', (req, res) ->
stripeCallback = (err, response) ->
if err
console.error(err, 'Stripe Error')
return res.send(500, err.response.error.message)
else
model = req.getModel()
userId = model.session.userId
model.fetch "users.#{userId}", (err, user) ->
model.ref '_user', "users.#{userId}"
model.set('_user.balance', model.get('_user.balance')+5)
model.set('_user.flags.ads','hide')
return res.send(200)
api_key = process.env.STRIPE_API_KEY # secret stripe API key
stripe = require("stripe")(api_key)
token = req.body.id
# console.dir {token:token, req:req}, 'stripe'
stripe.charges.create
amount: "500" # $5
currency: "usd"
card: token
, stripeCallback

View file

@ -25,7 +25,8 @@ module.exports = (expressApp, root, derby) ->
v1 API. Requires user-id and api_token, task-id, direction. Test with:
curl -X POST -H "Content-Type:application/json" -d '{"api_token":"{TOKEN}"}' localhost:3000/v1/users/{UID}/tasks/productivity/up
###
expressApp.post '/v1/users/:uid/tasks/:taskId/:direction', (req, res) ->
# TODO /v1/..
expressApp.post '/users/:uid/tasks/:taskId/:direction', (req, res) ->
{uid, taskId, direction} = req.params
{api_token, title, service, icon} = req.body
console.log {params:req.params, body:req.body} if process.env.NODE_ENV == 'development'

View file

@ -308,9 +308,9 @@
<!-- Footer -->
<footer class=footer>
<div class=container>
<div class='pull-right'>
<!--<div class='pull-right'>
<button class='btn' x-bind="click:emulateNextDay">Emulate Next Day</button>
</div>
</div>-->
<div>
<ul>
<li>Copyright &copy; 2012 OCDevel LLC</li>