mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-25 05:23:39 -04:00
Merge branch 'master' into production
This commit is contained in:
commit
4c763a86ce
3 changed files with 8 additions and 12 deletions
app
server/commons
|
@ -265,8 +265,7 @@ mixin invite-tab
|
|||
p(data-i18n="courses.invite_link_p_2")
|
||||
.form
|
||||
.form-group
|
||||
textarea#invite-emails-textarea.form-control(
|
||||
rows=3, data-i18n="[placeholder]courses.enter_emails")
|
||||
textarea#invite-emails-textarea.form-control
|
||||
.help-block(data-i18n="courses.enter_emails")
|
||||
.form-group
|
||||
button#invite-btn.btn.btn-success(data-i18n="courses.send_invites")
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = class TrialRequestsView extends RootView
|
|||
-1
|
||||
else
|
||||
1
|
||||
@trialRequests = new CocoCollection([], { url: '/db/trial.request', model: TrialRequest, comparator: sortRequests })
|
||||
@trialRequests = new CocoCollection([], { url: '/db/trial.request?conditions[sort]=-_id&conditions[limit]=500', model: TrialRequest, comparator: sortRequests })
|
||||
@supermodel.loadCollection(@trialRequests, 'trial-requests', {cache: false})
|
||||
|
||||
getRenderData: ->
|
||||
|
|
|
@ -179,21 +179,18 @@ module.exports = class Handler
|
|||
# if it's not a text search but the user is an admin, let him try stuff anyway
|
||||
else if req.user?.isAdmin()
|
||||
# admins can send any sort of query down the wire
|
||||
# Example URL: http://localhost:3000/db/user?filter[anonymous]=true
|
||||
filter = {}
|
||||
filter[key] = (val for own key, val of req.query.filter when key not in specialParameters) if 'filter' of req.query
|
||||
|
||||
filter[key] = JSON.parse(val) for own key, val of req.query.filter when key not in specialParameters if 'filter' of req.query
|
||||
query = @modelClass.find(filter)
|
||||
|
||||
# Conditions are chained query functions, for example: query.find().limit(20).sort('-dateCreated')
|
||||
conditions = JSON.parse(req.query.conditions || '[]')
|
||||
# Example URL: http://localhost:3000/db/user?conditions[limit]=20&conditions[sort]=-dateCreated
|
||||
hasLimit = false
|
||||
try
|
||||
for condition in conditions
|
||||
name = condition[0]
|
||||
f = query[name]
|
||||
args = condition[1..]
|
||||
query = query[name](args...)
|
||||
hasLimit ||= f is 'limit'
|
||||
for own key, val of req.query.conditions
|
||||
query = query[key](val)
|
||||
hasLimit ||= key is 'limit'
|
||||
catch e
|
||||
return @sendError(res, 422, 'Badly formed conditions.')
|
||||
query.limit(2000) unless hasLimit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue