mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 07:21:15 +00:00
mass assignment on server #2 (@WIP)
This commit is contained in:
parent
7f0d4ee1ec
commit
3c8d18e55e
2 changed files with 27 additions and 26 deletions
|
|
@ -26,9 +26,9 @@ get '/', (page, model, next) ->
|
|||
# return page.redirect 'https://' + req.headers.host + req.url
|
||||
|
||||
userPath = "users.#{model.session.userId}"
|
||||
model.fetch userPath, (err, userFetch) ->
|
||||
model.subscribe userPath, (err, user) ->
|
||||
# Set variables which are passed from the controller to the view
|
||||
userObj = userFetch.get()
|
||||
userObj = user.get()
|
||||
|
||||
#FIXME remove this eventually, part of user schema
|
||||
userObj.balance = userObj.balance || 2
|
||||
|
|
@ -46,13 +46,14 @@ get '/', (page, model, next) ->
|
|||
reroll: content.items.reroll
|
||||
|
||||
# FIXME temporary hack to remove duplicates and empty (grey) tasks. Need to figure out why they're being produced
|
||||
taskIds = _.keys userObj.tasks
|
||||
taskIds = _.pluck(userObj.tasks, 'id')
|
||||
_.each ['habitIds','dailyIds','todoIds','rewardIds'], (path) ->
|
||||
original = userObj[path]
|
||||
unique = _.uniq original #remove duplicates
|
||||
preened = _.reject unique, (obj, key) -> #remove empty grey tasks
|
||||
!_.contains(taskIds, key)
|
||||
# userObj[path]= preened
|
||||
unique = _.uniq userObj[path] #remove duplicates
|
||||
#remove empty grey tasks
|
||||
userObj[path] = _.filter(unique, (val) ->
|
||||
console.log {objId:val, taskIds:taskIds}
|
||||
_.contains(taskIds, val)
|
||||
)
|
||||
|
||||
# ========== Notifiations ==========
|
||||
unless userObj.notifications.kickstarter
|
||||
|
|
@ -61,23 +62,23 @@ get '/', (page, model, next) ->
|
|||
model.set '_view', _view
|
||||
|
||||
model.set "users.#{userObj.id}", userObj
|
||||
model.subscribe userPath, (err, userSubscribe) ->
|
||||
model.ref '_user', userSubscribe
|
||||
|
||||
# Setup Task Lists
|
||||
model.refList "_habitList", "_user.tasks", "_user.habitIds"
|
||||
model.refList "_dailyList", "_user.tasks", "_user.dailyIds"
|
||||
model.refList "_todoList", "_user.tasks", "_user.todoIds"
|
||||
model.refList "_completedList", "_user.tasks", "_user.completedIds"
|
||||
model.refList "_rewardList", "_user.tasks", "_user.rewardIds"
|
||||
model.ref '_user', user
|
||||
|
||||
# Setup Model Functions
|
||||
model.fn '_user._tnl', '_user.stats.lvl', (lvl) ->
|
||||
# see https://github.com/lefnire/habitrpg/issues/4
|
||||
# also update in scoring.coffee. TODO create a function accessible in both locations
|
||||
(lvl*100)/5
|
||||
# Setup Task Lists
|
||||
model.refList "_habitList", "_user.tasks", "_user.habitIds"
|
||||
model.refList "_dailyList", "_user.tasks", "_user.dailyIds"
|
||||
model.refList "_todoList", "_user.tasks", "_user.todoIds"
|
||||
model.refList "_completedList", "_user.tasks", "_user.completedIds"
|
||||
model.refList "_rewardList", "_user.tasks", "_user.rewardIds"
|
||||
|
||||
page.render()
|
||||
# Setup Model Functions
|
||||
model.fn '_user._tnl', '_user.stats.lvl', (lvl) ->
|
||||
# see https://github.com/lefnire/habitrpg/issues/4
|
||||
# also update in scoring.coffee. TODO create a function accessible in both locations
|
||||
(lvl*100)/5
|
||||
|
||||
page.render()
|
||||
|
||||
# ========== CONTROLLER FUNCTIONS ==========
|
||||
|
||||
|
|
|
|||
|
|
@ -278,10 +278,10 @@
|
|||
|
||||
{#if _user.items.itemsEnabled}
|
||||
<ul class='items'>
|
||||
{#with _items.armor as :item}<app:item />{/}
|
||||
{#with _items.weapon as :item}<app:item />{/}
|
||||
{#with _items.potion as :item}<app:item />{/}
|
||||
{#with _items.reroll as :item}<app:item reroll=true/>{/}
|
||||
{#with _view.items.armor as :item}<app:item />{/}
|
||||
{#with _view.items.weapon as :item}<app:item />{/}
|
||||
{#with _view.items.potion as :item}<app:item />{/}
|
||||
{#with _view.items.reroll as :item}<app:item reroll=true/>{/}
|
||||
</ul>
|
||||
{/}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue