mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-25 00:28:31 -05:00
f0fa88206d
* Refactor several related endpoints and views * Redesign EnrollmentView, add TeacherContactModal * Add "Enrollment Status" tab to TeacherClassView * Delete PurchaseCoursesView and related files * Style-flatten RemoveStudentModal * Fix error handling in ActivateLicensesModal * TeacherCoursesView loads faster by only loading course campaigns, and not load prepaids
37 lines
1.1 KiB
CoffeeScript
37 lines
1.1 KiB
CoffeeScript
User = require 'models/User'
|
|
CocoCollection = require 'collections/CocoCollection'
|
|
|
|
module.exports = class Users extends CocoCollection
|
|
model: User
|
|
url: '/db/user'
|
|
|
|
fetchForClassroom: (classroom, options={}) ->
|
|
if options.removeDeleted
|
|
delete options.removeDeleted
|
|
@listenTo @, 'sync', @removeDeletedUsers
|
|
classroomID = classroom.id or classroom
|
|
limit = 10
|
|
skip = 0
|
|
size = _.size(classroom.get('members'))
|
|
options.url = "/db/classroom/#{classroomID}/members"
|
|
options.data ?= {}
|
|
options.data.memberLimit = limit
|
|
options.remove = false
|
|
jqxhrs = []
|
|
while skip < size
|
|
options = _.cloneDeep(options)
|
|
options.data.memberSkip = skip
|
|
jqxhrs.push(@fetch(options))
|
|
skip += limit
|
|
return jqxhrs
|
|
|
|
removeDeletedUsers: ->
|
|
@remove @filter (user) ->
|
|
user.get('deleted')
|
|
true
|
|
|
|
search: (term) ->
|
|
return @slice() unless term
|
|
term = term.toLowerCase()
|
|
return @filter (user) ->
|
|
user.broadName().toLowerCase().indexOf(term) > -1 or (user.get('email') ? '').indexOf(term) > -1
|