mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
Merge branch 'develop' into priority-multiplier
This commit is contained in:
commit
2e26df743f
5 changed files with 52 additions and 31 deletions
|
|
@ -60,6 +60,9 @@ module.exports.app = (appExports, model) ->
|
|||
appExports.closeAlgosNotification = (e, el) ->
|
||||
user.set('flags.algosNotification', 'hide')
|
||||
|
||||
appExports.closeOnliesNotification = (e, el) ->
|
||||
user.set('flags.onliesNotification', 'hide')
|
||||
|
||||
appExports.customizeGender = (e, el) ->
|
||||
user.set 'preferences.gender', $(el).attr('data-value')
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,9 @@ cron = (model) ->
|
|||
value = obj.tasks[taskObj.id].value #get updated value
|
||||
absVal = if (completed) then Math.abs(value) else value
|
||||
todoTally += absVal
|
||||
else if type is 'habit' #reset 'onlies' value to 0
|
||||
if taskObj.up==false or taskObj.down==false
|
||||
batch.set "tasks.#{taskObj.id}.value", 0
|
||||
|
||||
# Finished tallying
|
||||
obj.history ?= {}; obj.history.todos ?= []; obj.history.exp ?= []
|
||||
|
|
|
|||
|
|
@ -117,38 +117,39 @@ router.get '/user/tasks', auth, (req, res) ->
|
|||
This is called form deprecated.coffee's score function, and the req.headers are setup properly to handle the login
|
||||
###
|
||||
scoreTask = (req, res, next) ->
|
||||
auth req, res, ->
|
||||
{taskId, direction} = req.params
|
||||
{title, service, icon} = req.body
|
||||
{taskId, direction} = req.params
|
||||
{title, service, icon} = req.body
|
||||
|
||||
# Send error responses for improper API call
|
||||
return res.send(500, ':taskId required') unless taskId
|
||||
return res.send(500, ":direction must be 'up' or 'down'") unless direction in ['up','down']
|
||||
# Send error responses for improper API call
|
||||
return res.send(500, ':taskId required') unless taskId
|
||||
return res.send(500, ":direction must be 'up' or 'down'") unless direction in ['up','down']
|
||||
|
||||
model = req.getModel()
|
||||
{user, userObj} = req
|
||||
model = req.getModel()
|
||||
{user, userObj} = req
|
||||
|
||||
model.ref('_user', user)
|
||||
model.ref('_user', user)
|
||||
|
||||
# Create task if doesn't exist
|
||||
# TODO add service & icon to task
|
||||
unless model.get("_user.tasks.#{taskId}")
|
||||
model.refList "_habitList", "_user.tasks", "_user.habitIds"
|
||||
model.at('_habitList').push
|
||||
id: taskId
|
||||
type: 'habit'
|
||||
text: (title || taskId)
|
||||
value: 0
|
||||
up: true
|
||||
down: true
|
||||
notes: "This task was created by a third-party service. Feel free to edit, it won't harm the connection to that service. Additionally, multiple services may piggy-back off this task."
|
||||
# Create task if doesn't exist
|
||||
# TODO add service & icon to task
|
||||
unless model.get("_user.tasks.#{taskId}")
|
||||
model.refList "_habitList", "_user.tasks", "_user.habitIds"
|
||||
model.at('_habitList').push
|
||||
id: taskId
|
||||
type: 'habit'
|
||||
text: (title || taskId)
|
||||
value: 0
|
||||
up: true
|
||||
down: true
|
||||
notes: "This task was created by a third-party service. Feel free to edit, it won't harm the connection to that service. Additionally, multiple services may piggy-back off this task."
|
||||
|
||||
delta = scoring.score(model, taskId, direction)
|
||||
result = model.get ('_user.stats')
|
||||
result.delta = delta
|
||||
res.send(result)
|
||||
router.post '/user/tasks/:taskId/:direction', scoreTask
|
||||
delta = scoring.score(model, taskId, direction)
|
||||
result = model.get ('_user.stats')
|
||||
result.delta = delta
|
||||
res.send(result)
|
||||
|
||||
router.post '/user/tasks/:taskId/:direction', auth, scoreTask
|
||||
|
||||
module.exports = router
|
||||
module.exports.auth = auth
|
||||
module.exports.scoreTask = scoreTask # export so deprecated can call it
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@ router.get '/:uid/down/:score?', (req, res) -> res.send(500, deprecatedMessage)
|
|||
router.post '/users/:uid/tasks/:taskId/:direction', (req, res) -> res.send(500, deprecatedMessage)
|
||||
|
||||
# Redirect to new API
|
||||
router.post '/v1/users/:uid/tasks/:taskId/:direction', (req, res, next) ->
|
||||
initDeprecated = (req, res, next) ->
|
||||
req.headers['x-api-user'] = req.params.uid
|
||||
req.headers['x-api-key'] = req.body.apiToken
|
||||
api.scoreTask(req, res, next)
|
||||
next()
|
||||
|
||||
router.post '/v1/users/:uid/tasks/:taskId/:direction', initDeprecated, api.auth, api.scoreTask
|
||||
|
||||
router.get '/v1/users/:uid/calendar.ics', (req, res) ->
|
||||
#return next() #disable for now
|
||||
|
|
@ -47,4 +49,4 @@ router.get '/v1/users/:uid/calendar.ics', (req, res) ->
|
|||
formattedIcal = ical.toString().replace(/DTSTART\:/g, 'DTSTART;VALUE=DATE:')
|
||||
res.send(200, formattedIcal)
|
||||
|
||||
module.exports = router
|
||||
module.exports = router
|
||||
|
|
|
|||
|
|
@ -7,8 +7,20 @@
|
|||
|
||||
{#if equal(_user.flags.algosNotification,'show')}
|
||||
<div class='alert alert-success'>
|
||||
<a target="_blank" x-bind="click:closeAlgosNotification" class=pull-right>[x]</a>
|
||||
<p>New features! Custom day start, new and better algorithms, authentication enhancements. See <a href="http://habitrpg.tumblr.com/post/44468869138/custom-day-start-better-algorithms-auth-enhancements">details here.</a>
|
||||
<a x-bind="click:closeAlgosNotification" class=pull-right>[x]</a>
|
||||
<p>New features! Custom day start, new and better algorithms, authentication enhancements. See <a target="_blank" href="http://habitrpg.tumblr.com/post/44468869138/custom-day-start-better-algorithms-auth-enhancements">details here.</a>
|
||||
"Hey, I had more Exp before this roll-out!" <a href="#restore-modal" data-toggle=modal>Restore your Exp here.</a></p>
|
||||
</div>
|
||||
{/}
|
||||
|
||||
{#if equal(_user.flags.onliesNotification, 'show')}
|
||||
<div class='alert alert-success'>
|
||||
<a x-bind="click:closeOnliesNotification " class=pull-right>[x]</a>
|
||||
<p>
|
||||
"Onlies" now gain / lose value just like other habits, and are reset back to 0 at the beginning of each day.
|
||||
See <a target="_blank" href="https://trello.com/card/shading-onlies/50e5d3684fe3a7266b0036d6/67">details here</a>, and
|
||||
chime in with your recommendations on this mechanic.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/}
|
||||
Loading…
Reference in a new issue