codecombat/app/models/Prepaid.coffee
Matt Lott d7a66722b9 Update teacher surveys
Removing trial subscriptions
Updating trial page copy
Adding special HoC trial
Introducing a new course prepaid property endDate, which won’t be
returned or redeemed after the date.
2015-11-24 10:32:19 -08:00

21 lines
621 B
CoffeeScript

CocoModel = require './CocoModel'
schema = require 'schemas/models/prepaid.schema'
module.exports = class Prepaid extends CocoModel
@className: "Prepaid"
urlRoot: '/db/prepaid'
openSpots: ->
return @get('maxRedeemers') - @get('redeemers')?.length if @get('redeemers')?
@get('maxRedeemers')
userHasRedeemed: (userID) ->
for redeemer in @get('redeemers')
return redeemer.date if redeemer.userID is userID
return null
initialize: ->
@listenTo @, 'add', ->
maxRedeemers = @get('maxRedeemers')
if _.isString(maxRedeemers)
@set 'maxRedeemers', parseInt(maxRedeemers)