Merge remote-tracking branch 'origin/hb-publisher-management'

GitOrigin-RevId: 746cb15097cdc7c4f4cbd9f029d5e456c9bfe3ad
This commit is contained in:
Douglas Lovell 2018-12-18 10:22:44 -03:00 committed by sharelatex
parent e139abb110
commit 740dce07a9
6 changed files with 74 additions and 1 deletions

View file

@ -0,0 +1,9 @@
UserMembershipHandler = require "../UserMembership/UserMembershipHandler"
UserMembershipEntityConfigs = require "../UserMembership/UserMembershipEntityConfigs"
logger = require 'logger-sharelatex'
_ = require 'underscore'
module.exports = PublishersGetter =
getManagedPublishers: (user_id, callback = (error, managedPublishers) ->) ->
UserMembershipHandler.getEntitiesByUser UserMembershipEntityConfigs.publisher, user_id, (error, managedPublishers) ->
callback(error, managedPublishers)

View file

@ -98,6 +98,7 @@ module.exports = SubscriptionController =
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1Subscriptions,
v1SubscriptionStatus
} = results
@ -108,6 +109,7 @@ module.exports = SubscriptionController =
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1Subscriptions,
v1SubscriptionStatus
}, "showing subscription dashboard"
@ -121,6 +123,7 @@ module.exports = SubscriptionController =
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1Subscriptions,
v1SubscriptionStatus
}

View file

@ -6,6 +6,7 @@ LimitationsManager = require("./LimitationsManager")
SubscriptionLocator = require("./SubscriptionLocator")
V1SubscriptionManager = require("./V1SubscriptionManager")
InstitutionsGetter = require("../Institutions/InstitutionsGetter")
PublishersGetter = require("../Publishers/PublishersGetter")
logger = require('logger-sharelatex')
_ = require("underscore")
async = require('async')
@ -46,6 +47,8 @@ module.exports =
InstitutionsGetter.getConfirmedInstitutions user._id, cb
managedInstitutions: (cb) ->
InstitutionsGetter.getManagedInstitutions user._id, cb
managedPublishers: (cb) ->
PublishersGetter.getManagedPublishers user._id, cb
v1Subscriptions: (cb) ->
V1SubscriptionManager.getSubscriptionsFromV1 user._id, (error, subscriptions, v1Id) ->
return cb(error) if error?
@ -63,6 +66,7 @@ module.exports =
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1Subscriptions,
v1SubscriptionStatus,
recurlySubscription,
@ -103,6 +107,7 @@ module.exports =
memberGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1Subscriptions,
v1SubscriptionStatus
}

View file

@ -24,6 +24,10 @@ block content
-hasAnySubscription = true
include ./dashboard/_managed_institutions
-if (managedPublishers && managedPublishers.length > 0)
-hasAnySubscription = true
include ./dashboard/_managed_publishers
-if (memberGroupSubscriptions && memberGroupSubscriptions.length > 0)
-hasAnySubscription = true
include ./dashboard/_group_memberships

View file

@ -0,0 +1,16 @@
each publisher in managedPublishers
p
| You are a manager of
|
strong= publisher.name
p
a(href="/publishers/" + publisher.slug + "/hub")
i.fa.fa-fw.fa-user-circle
|  
| View hub
p
a(href="/manage/publishers/" + publisher.slug + "/managers")
i.fa.fa-fw.fa-users
|  
| Manage publisher managers
hr

View file

@ -0,0 +1,36 @@
SandboxedModule = require('sandboxed-module')
require('chai').should()
expect = require('chai').expect
sinon = require('sinon')
modulePath = require('path').join __dirname, '../../../../app/js/Features/Publishers/PublishersGetter.js'
describe 'PublishersGetter', ->
beforeEach ->
@publisher =
_id: 'mock-publsiher-id'
slug: 'ieee'
fetchV1Data: sinon.stub()
@PublishersGetter = SandboxedModule.require modulePath, requires:
'../User/UserGetter': @UserGetter
"../UserMembership/UserMembershipHandler": @UserMembershipHandler = {
getEntitiesByUser: sinon.stub().callsArgWith(2, null, [@publisher])
}
"../UserMembership/UserMembershipEntityConfigs": @UserMembershipEntityConfigs = {
publisher:
modelName: 'Publisher'
canCreate: true
fields:
primaryKey: 'slug'
}
'logger-sharelatex':
log:-> console.log(arguments)
err:->
@userId = '12345abcde'
describe "getManagedPublishers", ->
it 'fetches v1 data before returning publisher list', (done) ->
@PublishersGetter.getManagedPublishers @userId, (error, publishers) ->
publishers.length.should.equal 1
done()