mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Processed Scott's feedback. Db endpoint slightly safer, some refactorings.
This commit is contained in:
parent
8607162cd7
commit
bb57756cd9
7 changed files with 23 additions and 26 deletions
|
@ -5,6 +5,7 @@ locale = require 'locale/locale'
|
|||
{me} = require 'lib/auth'
|
||||
Tracker = require 'lib/Tracker'
|
||||
CocoView = require 'views/kinds/CocoView'
|
||||
AchievementNotify = require '../../templates/achievement_notify'
|
||||
|
||||
marked.setOptions {gfm: true, sanitize: true, smartLists: true, breaks: false}
|
||||
|
||||
|
@ -39,6 +40,7 @@ Application = initialize: ->
|
|||
@facebookHandler = new FacebookHandler()
|
||||
@gplusHandler = new GPlusHandler()
|
||||
$(document).bind 'keydown', preventBackspace
|
||||
$.notify.addStyle 'achievement', html: $(AchievementNotify())
|
||||
@linkedinHandler = new LinkedInHandler()
|
||||
preload(COMMON_FILES)
|
||||
$.i18n.init {
|
||||
|
|
7
app/collections/NewAchievementCollection.coffee
Normal file
7
app/collections/NewAchievementCollection.coffee
Normal file
|
@ -0,0 +1,7 @@
|
|||
CocoCollection = require 'collections/CocoCollection'
|
||||
|
||||
class NewAchievementCollection extends CocoCollection
|
||||
initialize: (me = require('lib/auth').me) ->
|
||||
@url = "/db/user/#{me.id}/achievements?notified=false"
|
||||
|
||||
module.exports = NewAchievementCollection
|
|
@ -1,9 +1,7 @@
|
|||
storage = require 'lib/storage'
|
||||
deltasLib = require 'lib/deltas'
|
||||
|
||||
class NewAchievementCollection extends Backbone.Collection
|
||||
initialize: (me = require('lib/auth').me) ->
|
||||
@url = "/db/user/#{me.id}/achievements?notified=false"
|
||||
NewAchievementCollection = require '../collections/NewAchievementCollection'
|
||||
|
||||
class CocoModel extends Backbone.Model
|
||||
idAttribute: "_id"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
div
|
||||
div.clearfix.achievement-body
|
||||
div.achievement-image(data-notify-html="image")
|
||||
div.achievement-content
|
||||
div.achievement-title(data-notify-html="title")
|
||||
div.achievement-description(data-notify-html="description")
|
||||
.clearfix.achievement-body
|
||||
.achievement-image(data-notify-html="image")
|
||||
.achievement-content
|
||||
.achievement-title(data-notify-html="title")
|
||||
.achievement-description(data-notify-html="description")
|
||||
|
||||
div.achievement-progress
|
||||
div.achievement-message(data-notify-html="message")
|
||||
div.progress-wrapper
|
||||
div.earned-exp(data-notify-html="earnedExp")
|
||||
div.progress-bar-wrapper(data-notify-html="progressBar")
|
||||
.achievement-progress
|
||||
.achievement-message(data-notify-html="message")
|
||||
.progress-wrapper
|
||||
.earned-exp(data-notify-html="earnedExp")
|
||||
.progress-bar-wrapper(data-notify-html="progressBar")
|
||||
|
|
|
@ -6,7 +6,6 @@ CocoView = require './CocoView'
|
|||
{logoutUser, me} = require('lib/auth')
|
||||
locale = require 'locale/locale'
|
||||
|
||||
AchievementNotify = require '../../templates/achievement_notify'
|
||||
Achievement = require '../../models/Achievement'
|
||||
User = require '../../models/User'
|
||||
|
||||
|
@ -28,10 +27,7 @@ module.exports = class RootView extends CocoView
|
|||
|
||||
initialize: ->
|
||||
$ =>
|
||||
$.notify.addStyle 'achievement',
|
||||
html: $(AchievementNotify())
|
||||
|
||||
# TODO Remove this. Allows for easy testing right now though
|
||||
# TODO Ruben remove this. Allows for easy testing right now though
|
||||
#test = new Achievement(_id:'537ce4855c91b8d1dda7fda8')
|
||||
#test.fetch(success:@showNewAchievement)
|
||||
|
||||
|
|
|
@ -21,12 +21,6 @@ candidateProperties = [
|
|||
'jobProfile', 'jobProfileApproved', 'jobProfileNotes'
|
||||
]
|
||||
|
||||
parseLiteral = (literalString) ->
|
||||
return true if literalString is 'true'
|
||||
return false if literalString is 'false'
|
||||
return number if (number = Number(literalString)) isnt NaN
|
||||
literalString
|
||||
|
||||
UserHandler = class UserHandler extends Handler
|
||||
modelClass: User
|
||||
|
||||
|
@ -245,7 +239,7 @@ UserHandler = class UserHandler extends Handler
|
|||
|
||||
getEarnedAchievements: (req, res, userID) ->
|
||||
queryObject = {$query: {user: userID}, $orderby: {changed: -1}}
|
||||
queryObject.$query[key] = parseLiteral(val) for key, val of req.query
|
||||
queryObject.$query.notified = false if req.query.notified is 'false'
|
||||
query = EarnedAchievement.find(queryObject)
|
||||
query.exec (err, documents) =>
|
||||
return @sendDatabaseError(res, err) if err?
|
||||
|
|
Loading…
Reference in a new issue