diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee
index 0d2cc46f67..a2287a5d44 100644
--- a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee
+++ b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee
@@ -97,7 +97,7 @@ module.exports = SubscriptionController =
else
SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel user, (error, subscription, groups) ->
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()
res.render "subscriptions/dashboard",
title: "your_subscription"
diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee
index cf97417d9d..ff90023ff1 100644
--- a/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee
+++ b/services/web/app/coffee/Features/Subscription/SubscriptionGroupController.coffee
@@ -27,6 +27,13 @@ module.exports =
logger.log adminUserId:adminUserId, userToRemove_id:userToRemove_id, "removing user from group subscription"
SubscriptionGroupHandler.removeUserFromGroup adminUserId, userToRemove_id, ->
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)->
user_id = req.session.user._id
diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee
index 39eb53ad15..f2d66c30c5 100644
--- a/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee
+++ b/services/web/app/coffee/Features/Subscription/SubscriptionRouter.coffee
@@ -24,6 +24,8 @@ module.exports =
webRouter.post '/subscription/group/user', AuthenticationController.requireLogin(), SubscriptionGroupController.addUserToGroup
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', AuthenticationController.requireLogin(), SubscriptionGroupController.removeSelfFromGroup
+
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
diff --git a/services/web/app/coffee/Features/Subscription/UserFeaturesUpdater.coffee b/services/web/app/coffee/Features/Subscription/UserFeaturesUpdater.coffee
index 2d84d69b10..83a76d5f8e 100644
--- a/services/web/app/coffee/Features/Subscription/UserFeaturesUpdater.coffee
+++ b/services/web/app/coffee/Features/Subscription/UserFeaturesUpdater.coffee
@@ -9,7 +9,7 @@ module.exports =
conditions = _id:user_id
update = {}
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
User.update conditions, update, (err)->
callback err, plan.features
diff --git a/services/web/app/views/subscriptions/dashboard.jade b/services/web/app/views/subscriptions/dashboard.jade
index 34f552760b..dd3e600aa1 100644
--- a/services/web/app/views/subscriptions/dashboard.jade
+++ b/services/web/app/views/subscriptions/dashboard.jade
@@ -46,11 +46,13 @@ block content
-if (groups.length != 0)
each groupSubscription in groups
p !{translate("member_of_group_subscription", {admin_email: "" + groupSubscription.admin_id.email + ""})}
+ span
+ button.btn.btn-danger(ng-click="removeSelfFromGroup('#{groupSubscription.admin_id._id}')") #{translate("leave_group")}
- else if (subscription)
case subscription.state
when "free-trial"
p !{translate("on_free_trial_expiring_at", {expiresAt:"" + subscription.expiresAt + ""})}
- p !{translate("choose_a_plan_below")}
+
when "active"
p !{translate("currently_subscribed_to_plan", {planName:"" + subscription.name + ""})}
a(href, ng-click="changePlan = true") !{translate("change_plan")}.
@@ -103,9 +105,7 @@ block content
mixin printPlans(plans.individualMonthlyPlans)
mixin printPlans(plans.individualAnnualPlans)
-
-
- .card(ng-if="view == 'cancelation'")
+ .card(ng-if="view == 'cancelation'")
.page-header
h1 #{translate("Cancel Subscription")}
@@ -122,8 +122,7 @@ block content
div(ng-show="showDowngradeToStudent", style="text-align: center")
span(ng-controller="ChangePlanFormController")
- p
- !{translate("interested_in_cheaper_plan",{price:'{{studentPrice}}'})}
+ p !{translate("interested_in_cheaper_plan",{price:'{{studentPrice}}'})}
button(type="submit", ng-click="downgradeToStudent()", ng-disabled='inflight').btn.btn-success #{translate("yes_please")}
p
|
@@ -147,7 +146,6 @@ block content
ga('send', 'event', 'subscription-funnel', 'cancelation')
})
-
script(type='text/ng-template', id='confirmChangePlanModalTemplate')
.modal-header
h3 #{translate("change_plan")}
@@ -166,4 +164,22 @@ block content
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")}...
+
+
diff --git a/services/web/public/coffee/main/subscription-dashboard.coffee b/services/web/public/coffee/main/subscription-dashboard.coffee
index 90457cef15..63eec0d65a 100644
--- a/services/web/public/coffee/main/subscription-dashboard.coffee
+++ b/services/web/public/coffee/main/subscription-dashboard.coffee
@@ -53,11 +53,9 @@ define [
price = ""
-
-
App.controller "ConfirmChangePlanController", ($scope, $modalInstance, $http)->
+
$scope.confirmChangePlan = ->
-
body =
plan_code: $scope.plan.planCode
_csrf : window.csrfToken
@@ -74,8 +72,23 @@ define [
$scope.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)
sevenDaysTime = new Date()
@@ -120,6 +133,7 @@ define [
$scope.cancelSubscription = ->
body =
_csrf : window.csrfToken
+
$scope.inflight = true
$http.post("/user/subscription/cancel", body)
.success ->
@@ -130,6 +144,13 @@ define [
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 = ->
sixpack.participate 'cancelation-options-view', ['basic', 'downgrade-options'], (view, rawResponse)->