mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-23 22:12:32 -05:00
d7a66722b9
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.
21 lines
621 B
CoffeeScript
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)
|