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'
|
{me} = require 'lib/auth'
|
||||||
Tracker = require 'lib/Tracker'
|
Tracker = require 'lib/Tracker'
|
||||||
CocoView = require 'views/kinds/CocoView'
|
CocoView = require 'views/kinds/CocoView'
|
||||||
|
AchievementNotify = require '../../templates/achievement_notify'
|
||||||
|
|
||||||
marked.setOptions {gfm: true, sanitize: true, smartLists: true, breaks: false}
|
marked.setOptions {gfm: true, sanitize: true, smartLists: true, breaks: false}
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ Application = initialize: ->
|
||||||
@facebookHandler = new FacebookHandler()
|
@facebookHandler = new FacebookHandler()
|
||||||
@gplusHandler = new GPlusHandler()
|
@gplusHandler = new GPlusHandler()
|
||||||
$(document).bind 'keydown', preventBackspace
|
$(document).bind 'keydown', preventBackspace
|
||||||
|
$.notify.addStyle 'achievement', html: $(AchievementNotify())
|
||||||
@linkedinHandler = new LinkedInHandler()
|
@linkedinHandler = new LinkedInHandler()
|
||||||
preload(COMMON_FILES)
|
preload(COMMON_FILES)
|
||||||
$.i18n.init {
|
$.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
|
|
@ -59,4 +59,4 @@ setUpChannels = ->
|
||||||
|
|
||||||
setUpDefinitions = ->
|
setUpDefinitions = ->
|
||||||
for definition of definitionSchemas
|
for definition of definitionSchemas
|
||||||
Backbone.Mediator.addDefSchemas definitionSchemas[definition]
|
Backbone.Mediator.addDefSchemas definitionSchemas[definition]
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
storage = require 'lib/storage'
|
storage = require 'lib/storage'
|
||||||
deltasLib = require 'lib/deltas'
|
deltasLib = require 'lib/deltas'
|
||||||
|
|
||||||
class NewAchievementCollection extends Backbone.Collection
|
NewAchievementCollection = require '../collections/NewAchievementCollection'
|
||||||
initialize: (me = require('lib/auth').me) ->
|
|
||||||
@url = "/db/user/#{me.id}/achievements?notified=false"
|
|
||||||
|
|
||||||
class CocoModel extends Backbone.Model
|
class CocoModel extends Backbone.Model
|
||||||
idAttribute: "_id"
|
idAttribute: "_id"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
div
|
div
|
||||||
div.clearfix.achievement-body
|
.clearfix.achievement-body
|
||||||
div.achievement-image(data-notify-html="image")
|
.achievement-image(data-notify-html="image")
|
||||||
div.achievement-content
|
.achievement-content
|
||||||
div.achievement-title(data-notify-html="title")
|
.achievement-title(data-notify-html="title")
|
||||||
div.achievement-description(data-notify-html="description")
|
.achievement-description(data-notify-html="description")
|
||||||
|
|
||||||
div.achievement-progress
|
.achievement-progress
|
||||||
div.achievement-message(data-notify-html="message")
|
.achievement-message(data-notify-html="message")
|
||||||
div.progress-wrapper
|
.progress-wrapper
|
||||||
div.earned-exp(data-notify-html="earnedExp")
|
.earned-exp(data-notify-html="earnedExp")
|
||||||
div.progress-bar-wrapper(data-notify-html="progressBar")
|
.progress-bar-wrapper(data-notify-html="progressBar")
|
||||||
|
|
|
@ -6,7 +6,6 @@ CocoView = require './CocoView'
|
||||||
{logoutUser, me} = require('lib/auth')
|
{logoutUser, me} = require('lib/auth')
|
||||||
locale = require 'locale/locale'
|
locale = require 'locale/locale'
|
||||||
|
|
||||||
AchievementNotify = require '../../templates/achievement_notify'
|
|
||||||
Achievement = require '../../models/Achievement'
|
Achievement = require '../../models/Achievement'
|
||||||
User = require '../../models/User'
|
User = require '../../models/User'
|
||||||
|
|
||||||
|
@ -28,10 +27,7 @@ module.exports = class RootView extends CocoView
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
$ =>
|
$ =>
|
||||||
$.notify.addStyle 'achievement',
|
# TODO Ruben remove this. Allows for easy testing right now though
|
||||||
html: $(AchievementNotify())
|
|
||||||
|
|
||||||
# TODO Remove this. Allows for easy testing right now though
|
|
||||||
#test = new Achievement(_id:'537ce4855c91b8d1dda7fda8')
|
#test = new Achievement(_id:'537ce4855c91b8d1dda7fda8')
|
||||||
#test.fetch(success:@showNewAchievement)
|
#test.fetch(success:@showNewAchievement)
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,6 @@ candidateProperties = [
|
||||||
'jobProfile', 'jobProfileApproved', 'jobProfileNotes'
|
'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
|
UserHandler = class UserHandler extends Handler
|
||||||
modelClass: User
|
modelClass: User
|
||||||
|
|
||||||
|
@ -245,7 +239,7 @@ UserHandler = class UserHandler extends Handler
|
||||||
|
|
||||||
getEarnedAchievements: (req, res, userID) ->
|
getEarnedAchievements: (req, res, userID) ->
|
||||||
queryObject = {$query: {user: userID}, $orderby: {changed: -1}}
|
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 = EarnedAchievement.find(queryObject)
|
||||||
query.exec (err, documents) =>
|
query.exec (err, documents) =>
|
||||||
return @sendDatabaseError(res, err) if err?
|
return @sendDatabaseError(res, err) if err?
|
||||||
|
|
Loading…
Reference in a new issue