Add owner name to course details page

This commit is contained in:
Scott Erickson 2015-10-27 17:47:48 -07:00
parent 9e04d425cc
commit 6e1cb8a1d1
2 changed files with 20 additions and 6 deletions

View file

@ -30,15 +30,20 @@ block content
button.btn.btn-success.btn-select-instance(data-i18n="courses.select") button.btn.btn-success.btn-select-instance(data-i18n="courses.select")
else if !course || !courseInstance else if !course || !courseInstance
h1(data-i18n="common.loading") Loading... h1(data-i18n="common.loading") Loading...
else
if courseInstance.get('name')
h1= courseInstance.get('name')
small.spl (#{course.get('name')})
else else
h1 h1
if courseInstance.get('name')
| #{courseInstance.get('name')}
else
span(data-i18n='courses.unnamed_class') span(data-i18n='courses.unnamed_class')
small.spl (#{course.get('name')}) small.spl (#{course.get('name')})
if !view.owner.isNew()
p
span.spr Creator:
a(href="/user/#{view.owner.id}")
strong= view.getOwnerName()
p p
if courseInstance.get('description') if courseInstance.get('description')
each line in courseInstance.get('description').split('\n') each line in courseInstance.get('description').split('\n')

View file

@ -133,6 +133,8 @@ module.exports = class CourseDetailsView extends RootView
}) })
me.patch() me.patch()
@supermodel.loadCollection @members, 'members', cache: false @supermodel.loadCollection @members, 'members', cache: false
@owner = new User({_id: @courseInstance.get('ownerID')})
@supermodel.loadModel @owner, 'user'
if @adminMode and prepaidID = @courseInstance.get('prepaidID') if @adminMode and prepaidID = @courseInstance.get('prepaidID')
@prepaid = @supermodel.getModel(Prepaid, prepaidID) or new Prepaid _id: prepaidID @prepaid = @supermodel.getModel(Prepaid, prepaidID) or new Prepaid _id: prepaidID
@listenTo @prepaid, 'sync', @onPrepaidSync @listenTo @prepaid, 'sync', @onPrepaidSync
@ -320,3 +322,10 @@ module.exports = class CourseDetailsView extends RootView
aName = @memberUserMap[a]?.get('name') ? 'Anoner' aName = @memberUserMap[a]?.get('name') ? 'Anoner'
bName = @memberUserMap[b]?.get('name') ? 'Anoner' bName = @memberUserMap[b]?.get('name') ? 'Anoner'
aName.localeCompare(bName) aName.localeCompare(bName)
getOwnerName: ->
if @owner.isNew()
return '?'
if @owner.get('firstName') and @owner.get('lastName')
return "#{@owner.get('firstName')} #{@owner.get('lastName')}"
return @owner.get('name') or @owner.get('email') or '?'