2016-08-19 17:05:21 -04:00
|
|
|
RootView = require 'views/core/RootView'
|
2016-09-04 02:10:02 -04:00
|
|
|
Prepaids = require 'collections/Prepaids'
|
2016-08-19 17:05:21 -04:00
|
|
|
|
|
|
|
module.exports = class ResourceHubView extends RootView
|
|
|
|
id: 'resource-hub-view'
|
|
|
|
template: require 'templates/teachers/resource-hub-view'
|
2016-09-04 02:10:02 -04:00
|
|
|
|
|
|
|
getTitle: -> return $.i18n.t('teacher.resource_hub')
|
|
|
|
|
|
|
|
initialize: (options) ->
|
|
|
|
unless me.isAnonymous()
|
|
|
|
@prepaids = new Prepaids()
|
|
|
|
@supermodel.trackRequest(@prepaids.fetchByCreator(me.id))
|
|
|
|
super(options)
|
|
|
|
|
|
|
|
onLoaded: ->
|
|
|
|
# Grant access for current or future licenses
|
|
|
|
today = new Date().toISOString()
|
|
|
|
for prepaid in @prepaids.models when prepaid.get('type') is 'course'
|
|
|
|
if today.localeCompare(prepaid.get('endDate') ? '') < 0
|
|
|
|
@paidAccess = true
|
|
|
|
break
|
|
|
|
super()
|