mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Fixed #1968.
This commit is contained in:
parent
04e0624268
commit
d69c5941b3
4 changed files with 8 additions and 7 deletions
|
@ -353,10 +353,10 @@ class CocoModel extends Backbone.Model
|
|||
@pollAchievements: ->
|
||||
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
Achievement = require 'models/Achievement'
|
||||
EarnedAchievement = require 'models/EarnedAchievement'
|
||||
|
||||
class NewAchievementCollection extends CocoCollection
|
||||
model: Achievement
|
||||
model: EarnedAchievement
|
||||
initialize: (me = require('core/auth').me) ->
|
||||
@url = "/db/user/#{me.id}/achievements?notified=false"
|
||||
|
||||
|
|
|
@ -38,10 +38,12 @@ module.exports = class RootView extends CocoView
|
|||
showNewAchievement: (achievement, earnedAchievement) ->
|
||||
return if achievement.get('collection') is 'level.sessions'
|
||||
return if @isIE() # Some bugs in IE right now, TODO fix soon!
|
||||
popup = new AchievementPopup achievement: achievement, earnedAchievement: earnedAchievement
|
||||
new AchievementPopup achievement: achievement, earnedAchievement: earnedAchievement
|
||||
|
||||
handleNewAchievements: (e) ->
|
||||
_.each e.earnedAchievements.models, (earnedAchievement) =>
|
||||
earnedAchievement.set('notified', true)
|
||||
earnedAchievement.patch()
|
||||
achievement = new Achievement(_id: earnedAchievement.get('achievement'))
|
||||
achievement.fetch
|
||||
success: (achievement) => @showNewAchievement?(achievement, earnedAchievement)
|
||||
|
|
|
@ -10,11 +10,13 @@ util = require '../../app/core/utils'
|
|||
|
||||
class EarnedAchievementHandler extends Handler
|
||||
modelClass: EarnedAchievement
|
||||
|
||||
editableProperties: ['notified']
|
||||
|
||||
# Don't allow POSTs or anything yet
|
||||
hasAccess: (req) ->
|
||||
return false unless req.user
|
||||
req.method in ['GET', 'POST'] # or req.user.isAdmin()
|
||||
req.method in ['GET', 'POST', 'PUT'] # or req.user.isAdmin()
|
||||
|
||||
get: (req, res) ->
|
||||
return @getByAchievementIDs(req, res) if req.query.view is 'get-by-achievement-ids'
|
||||
|
|
|
@ -318,9 +318,6 @@ UserHandler = class UserHandler extends Handler
|
|||
EarnedAchievement.find(query).sort(changed: -1).exec (err, documents) =>
|
||||
return @sendDatabaseError(res, err) if err?
|
||||
cleandocs = (@formatEntity(req, doc) for doc in documents)
|
||||
for doc in documents # TODO Ruben Maybe move this logic elsewhere
|
||||
doc.set('notified', true)
|
||||
doc.save()
|
||||
@sendSuccess(res, cleandocs)
|
||||
|
||||
getRecentlyPlayed: (req, res, userID) ->
|
||||
|
|
Loading…
Reference in a new issue