mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-13 13:35:30 -04:00
Create specific campaign view for campaign selection screen.
This commit is contained in:
parent
5701e13873
commit
991fead0f6
2 changed files with 15 additions and 1 deletions
|
@ -33,7 +33,7 @@ class LevelSessionsCollection extends CocoCollection
|
|||
@url = "/db/user/#{me.id}/level.sessions?project=state.complete,levelID,state.difficulty,playtime"
|
||||
|
||||
class CampaignsCollection extends CocoCollection
|
||||
url: '/db/campaign'
|
||||
url: '/db/campaign/-/overview'
|
||||
model: Campaign
|
||||
project: ['name', 'fullName', 'description', 'i18n']
|
||||
|
||||
|
|
|
@ -52,8 +52,22 @@ CampaignHandler = class CampaignHandler extends Handler
|
|||
documents = (@formatEntity(req, doc) for doc in documents)
|
||||
@sendSuccess(res, documents)
|
||||
|
||||
getOverview: (req, res) ->
|
||||
return @sendForbiddenError(res) if not @hasAccess(req)
|
||||
q = @modelClass.find {}, slug: 1, adjacentCampaigns: 1, fullName: 1, description: 1, color: 1
|
||||
q.exec (err, documents) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
formatCampaign = (doc) =>
|
||||
obj = @formatEntity(req, doc)
|
||||
obj.adjacentCampaigns = _.map(obj.adjacentCampaigns, (a) -> _.pick(a, ['showIfUnlocked', 'color', 'name', 'description' ]))
|
||||
obj
|
||||
documents = (formatCampaign(doc) for doc in documents)
|
||||
@sendSuccess(res, documents)
|
||||
|
||||
getByRelationship: (req, res, args...) ->
|
||||
relationship = args[1]
|
||||
return @getOverview(req,res) if args[0] is '-' and relationship is 'overview'
|
||||
|
||||
if relationship in ['levels', 'achievements']
|
||||
projection = {}
|
||||
if req.query.project
|
||||
|
|
Loading…
Add table
Reference in a new issue