Merge pull request #1454 from sharelatex/hb-subscriptions-page-messaging

Subscription page messaging updates

GitOrigin-RevId: c29999d22636dfe11c55b3f6110a38992645fad3
This commit is contained in:
Chrystal Maria Griffiths 2019-02-04 11:10:54 +00:00 committed by sharelatex
parent e73a7dbe9c
commit 2463fef390
4 changed files with 49 additions and 36 deletions

View file

@ -49,14 +49,14 @@ module.exports = SubscriptionController =
LimitationsManager.userHasV1OrV2Subscription user, (err, hasSubscription)->
return next(err) if err?
if hasSubscription or !plan?
res.redirect "/user/subscription"
res.redirect "/user/subscription?hasSubscription=true"
else
# LimitationsManager.userHasV2Subscription only checks Mongo. Double check with
# Recurly as well at this point (we don't do this most places for speed).
SubscriptionHandler.validateNoSubscriptionInRecurly user._id, (error, valid) ->
return next(error) if error?
if !valid
res.redirect "/user/subscription"
res.redirect "/user/subscription?hasSubscription=true"
return
else
currency = req.query.currency?.toUpperCase()
@ -100,30 +100,37 @@ module.exports = SubscriptionController =
managedPublishers,
v1SubscriptionStatus
} = results
logger.log {
user,
personalSubscription,
memberGroupSubscriptions,
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1SubscriptionStatus
}, "showing subscription dashboard"
plans = SubscriptionViewModelBuilder.buildViewModel()
data = {
title: "your_subscription"
plans,
user,
personalSubscription,
memberGroupSubscriptions,
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1SubscriptionStatus
}
res.render "subscriptions/dashboard", data
LimitationsManager.userHasV1OrV2Subscription user, (err, hasSubscription) ->
return next(error) if error?
fromPlansPage = req.query.hasSubscription
logger.log {
user,
hasSubscription,
fromPlansPage,
personalSubscription,
memberGroupSubscriptions,
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1SubscriptionStatus
}, "showing subscription dashboard"
plans = SubscriptionViewModelBuilder.buildViewModel()
data = {
title: "your_subscription"
plans,
user,
hasSubscription,
fromPlansPage,
personalSubscription,
memberGroupSubscriptions,
managedGroupSubscriptions,
confirmedMemberInstitutions,
managedInstitutions,
managedPublishers,
v1SubscriptionStatus
}
res.render "subscriptions/dashboard", data
createSubscription: (req, res, next)->
user = AuthenticationController.getSessionUser(req)

View file

@ -7,29 +7,29 @@ block content
.container
.row
.col-md-8.col-md-offset-2
-if (fromPlansPage)
.alert.alert-warning
p You already have a subscription
.card
.page-header
h1 #{translate("your_subscription")}
-var hasAnySubscription = false
-var hasDisplayedSubscription = false
-if (personalSubscription)
-hasAnySubscription = true
-hasDisplayedSubscription = true
include ./dashboard/_personal_subscription
-if (managedGroupSubscriptions && managedGroupSubscriptions.length > 0)
-hasAnySubscription = true
include ./dashboard/_managed_groups
-if (managedInstitutions && managedInstitutions.length > 0)
-hasAnySubscription = true
include ./dashboard/_managed_institutions
-if (managedPublishers && managedPublishers.length > 0)
-hasAnySubscription = true
include ./dashboard/_managed_publishers
-if (memberGroupSubscriptions && memberGroupSubscriptions.length > 0)
-hasAnySubscription = true
-hasDisplayedSubscription = true
include ./dashboard/_group_memberships
-if (confirmedMemberInstitutions && confirmedMemberInstitutions.length > 0)
@ -38,7 +38,13 @@ block content
-if (v1SubscriptionStatus)
include ./dashboard/_v1_subscription_status
-if (!hasAnySubscription)
-if (hasSubscription && !hasDisplayedSubscription)
-hasDisplayedSubscription = true
p You're on an #{settings.appName} Paid plan. Contact
a(href="mailto:support@overleaf.com") support@overleaf.com
| to find out more.
-if (!hasSubscription)
p You're on the #{settings.appName} Free plan.
|
a(href="/user/subscription/plans").btn.btn-primary Upgrade now

View file

@ -1,6 +1,6 @@
each institution in confirmedMemberInstitutions
if (institution.licence != 'free')
-hasAnySubscription = true
-hasDisplayedSubscription = true
p
| You have a
|

View file

@ -1,5 +1,5 @@
- if (v1SubscriptionStatus['team'] && v1SubscriptionStatus['team']['default_plan_name'] != 'free')
- hasAnySubscription = true
- hasDisplayedSubscription = true
p
| You have a legacy group licence from Overleaf v1.
- if (v1SubscriptionStatus['team']['will_end_at'])
@ -29,7 +29,7 @@
hr
- if (v1SubscriptionStatus['product'])
- hasAnySubscription = true
- hasDisplayedSubscription = true
p
| You have a legacy Overleaf v1
|