Merge branch 'master' of github.com:sharelatex/web-sharelatex

This commit is contained in:
Shane Kilkelly 2016-02-22 12:04:43 +00:00
commit 1e1f57a80b
6 changed files with 59 additions and 13 deletions

View file

@ -97,7 +97,7 @@ module.exports = SubscriptionController =
else else
SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel user, (error, subscription, groups) -> SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel user, (error, subscription, groups) ->
return next(error) if error? return next(error) if error?
logger.log user: user, subscription:subscription, hasSubOrIsGroupMember:hasSubOrIsGroupMember, "showing subscription dashboard" logger.log user: user, subscription:subscription, hasSubOrIsGroupMember:hasSubOrIsGroupMember, groups:groups, "showing subscription dashboard"
plans = SubscriptionViewModelBuilder.buildViewModel() plans = SubscriptionViewModelBuilder.buildViewModel()
res.render "subscriptions/dashboard", res.render "subscriptions/dashboard",
title: "your_subscription" title: "your_subscription"

View file

@ -28,6 +28,13 @@ module.exports =
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, -> SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, ->
res.send() res.send()
removeSelfFromGroup: (req, res)->
adminUserId = req.query.admin_user_id
userToRemove_id = req.session.user._id
logger.log adminUserId:adminUserId, userToRemove_id:userToRemove_id, "removing user from group subscription after self request"
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, ->
res.send()
renderSubscriptionGroupAdminPage: (req, res)-> renderSubscriptionGroupAdminPage: (req, res)->
user_id = req.session.user._id user_id = req.session.user._id
SubscriptionLocator.getUsersSubscription user_id, (err, subscription)-> SubscriptionLocator.getUsersSubscription user_id, (err, subscription)->

View file

@ -24,6 +24,8 @@ module.exports =
webRouter.post '/subscription/group/user', AuthenticationController.requireLogin(), SubscriptionGroupController.addUserToGroup webRouter.post '/subscription/group/user', AuthenticationController.requireLogin(), SubscriptionGroupController.addUserToGroup
webRouter.get '/subscription/group/export', AuthenticationController.requireLogin(), SubscriptionGroupController.exportGroupCsv webRouter.get '/subscription/group/export', AuthenticationController.requireLogin(), SubscriptionGroupController.exportGroupCsv
webRouter.delete '/subscription/group/user/:user_id', AuthenticationController.requireLogin(), SubscriptionGroupController.removeUserFromGroup webRouter.delete '/subscription/group/user/:user_id', AuthenticationController.requireLogin(), SubscriptionGroupController.removeUserFromGroup
webRouter.delete '/subscription/group/user', AuthenticationController.requireLogin(), SubscriptionGroupController.removeSelfFromGroup
webRouter.get '/user/subscription/:subscription_id/group/invited', AuthenticationController.requireLogin(), SubscriptionGroupController.renderGroupInvitePage webRouter.get '/user/subscription/:subscription_id/group/invited', AuthenticationController.requireLogin(), SubscriptionGroupController.renderGroupInvitePage
webRouter.post '/user/subscription/:subscription_id/group/begin-join', AuthenticationController.requireLogin(), SubscriptionGroupController.beginJoinGroup webRouter.post '/user/subscription/:subscription_id/group/begin-join', AuthenticationController.requireLogin(), SubscriptionGroupController.beginJoinGroup

View file

@ -9,7 +9,7 @@ module.exports =
conditions = _id:user_id conditions = _id:user_id
update = {} update = {}
plan = PlansLocator.findLocalPlanInSettings(plan_code) plan = PlansLocator.findLocalPlanInSettings(plan_code)
logger.log user_id:user_id, plan:plan, plan_code:plan_code, "updating users features" logger.log user_id:user_id, features:plan.features, plan_code:plan_code, "updating users features"
update["features.#{key}"] = value for key, value of plan.features update["features.#{key}"] = value for key, value of plan.features
User.update conditions, update, (err)-> User.update conditions, update, (err)->
callback err, plan.features callback err, plan.features

View file

@ -46,11 +46,13 @@ block content
-if (groups.length != 0) -if (groups.length != 0)
each groupSubscription in groups each groupSubscription in groups
p !{translate("member_of_group_subscription", {admin_email: "<strong>" + groupSubscription.admin_id.email + "</strong>"})} p !{translate("member_of_group_subscription", {admin_email: "<strong>" + groupSubscription.admin_id.email + "</strong>"})}
span
button.btn.btn-danger(ng-click="removeSelfFromGroup('#{groupSubscription.admin_id._id}')") #{translate("leave_group")}
- else if (subscription) - else if (subscription)
case subscription.state case subscription.state
when "free-trial" when "free-trial"
p !{translate("on_free_trial_expiring_at", {expiresAt:"<strong>" + subscription.expiresAt + "</strong>"})} p !{translate("on_free_trial_expiring_at", {expiresAt:"<strong>" + subscription.expiresAt + "</strong>"})}
p !{translate("choose_a_plan_below")}
when "active" when "active"
p !{translate("currently_subscribed_to_plan", {planName:"<strong>" + subscription.name + "</strong>"})} p !{translate("currently_subscribed_to_plan", {planName:"<strong>" + subscription.name + "</strong>"})}
a(href, ng-click="changePlan = true") !{translate("change_plan")}. a(href, ng-click="changePlan = true") !{translate("change_plan")}.
@ -103,8 +105,6 @@ block content
mixin printPlans(plans.individualMonthlyPlans) mixin printPlans(plans.individualMonthlyPlans)
mixin printPlans(plans.individualAnnualPlans) mixin printPlans(plans.individualAnnualPlans)
.card(ng-if="view == 'cancelation'") .card(ng-if="view == 'cancelation'")
.page-header .page-header
h1 #{translate("Cancel Subscription")} h1 #{translate("Cancel Subscription")}
@ -122,8 +122,7 @@ block content
div(ng-show="showDowngradeToStudent", style="text-align: center") div(ng-show="showDowngradeToStudent", style="text-align: center")
span(ng-controller="ChangePlanFormController") span(ng-controller="ChangePlanFormController")
p p !{translate("interested_in_cheaper_plan",{price:'{{studentPrice}}'})}
!{translate("interested_in_cheaper_plan",{price:'{{studentPrice}}'})}
button(type="submit", ng-click="downgradeToStudent()", ng-disabled='inflight').btn.btn-success #{translate("yes_please")} button(type="submit", ng-click="downgradeToStudent()", ng-disabled='inflight').btn.btn-success #{translate("yes_please")}
p p
| &nbsp; | &nbsp;
@ -147,7 +146,6 @@ block content
ga('send', 'event', 'subscription-funnel', 'cancelation') ga('send', 'event', 'subscription-funnel', 'cancelation')
}) })
script(type='text/ng-template', id='confirmChangePlanModalTemplate') script(type='text/ng-template', id='confirmChangePlanModalTemplate')
.modal-header .modal-header
h3 #{translate("change_plan")} h3 #{translate("change_plan")}
@ -166,4 +164,22 @@ block content
span(ng-show="inflight") #{translate("processing")}... span(ng-show="inflight") #{translate("processing")}...
script(type='text/ng-template', id='LeaveGroupModalTemplate')
.modal-header
h3 #{translate("leave_group")}
.modal-body
p #{translate("sure_you_want_to_leave_group")}
.modal-footer
button.btn.btn-default(
ng-disabled="inflight"
ng-click="cancel()"
) #{translate("cancel")}
button.btn.btn-danger(
ng-disabled="state.inflight"
ng-click="confirmLeaveGroup()"
)
span(ng-hide="inflight") #{translate("leave_now")}
span(ng-show="inflight") #{translate("processing")}...

View file

@ -53,11 +53,9 @@ define [
price = "" price = ""
App.controller "ConfirmChangePlanController", ($scope, $modalInstance, $http)-> App.controller "ConfirmChangePlanController", ($scope, $modalInstance, $http)->
$scope.confirmChangePlan = ->
$scope.confirmChangePlan = ->
body = body =
plan_code: $scope.plan.planCode plan_code: $scope.plan.planCode
_csrf : window.csrfToken _csrf : window.csrfToken
@ -74,8 +72,23 @@ define [
$scope.cancel = () -> $scope.cancel = () ->
$modalInstance.dismiss('cancel') $modalInstance.dismiss('cancel')
App.controller "LeaveGroupModalController", ($scope, $modalInstance, $http)->
$scope.confirmLeaveGroup = ->
$scope.inflight = true
$http({
url: "/subscription/group/user",
method: "DELETE",
params: {admin_user_id: $scope.admin_id, _csrf: window.csrfToken}
}).success ->
location.reload()
.error ->
console.log "something went wrong changing plan"
App.controller "UserSubscriptionController", ($scope, MultiCurrencyPricing, $http, sixpack) -> $scope.cancel = () ->
$modalInstance.dismiss('cancel')
App.controller "UserSubscriptionController", ($scope, MultiCurrencyPricing, $http, sixpack, $modal) ->
freeTrialEndDate = new Date(subscription?.trial_ends_at) freeTrialEndDate = new Date(subscription?.trial_ends_at)
sevenDaysTime = new Date() sevenDaysTime = new Date()
@ -120,6 +133,7 @@ define [
$scope.cancelSubscription = -> $scope.cancelSubscription = ->
body = body =
_csrf : window.csrfToken _csrf : window.csrfToken
$scope.inflight = true $scope.inflight = true
$http.post("/user/subscription/cancel", body) $http.post("/user/subscription/cancel", body)
.success -> .success ->
@ -130,6 +144,13 @@ define [
console.log "something went wrong changing plan" console.log "something went wrong changing plan"
$scope.removeSelfFromGroup = (admin_id)->
$scope.admin_id = admin_id
$modal.open(
templateUrl: "LeaveGroupModalTemplate"
controller: "LeaveGroupModalController"
scope: $scope
)
$scope.switchToCancelationView = -> $scope.switchToCancelationView = ->
sixpack.participate 'cancelation-options-view', ['basic', 'downgrade-options'], (view, rawResponse)-> sixpack.participate 'cancelation-options-view', ['basic', 'downgrade-options'], (view, rawResponse)->