<commit_before>angular.module('spiff.members', [
  'spiff',
  'restangular',
  'ui.bootstrap.progressbar',
  'template/progressbar/progressbar.html'
])

.controller('ConfirmSubscriptionChangesCtrl', function($scope, additions, removals, user, $modalInstance, Restangular) {
  $scope.additions = additions;
  $scope.removals = removals;
  $scope.close = $modalInstance.close;
  $scope.pending = 0;
  $scope.save = function() {
    _.each(removals, function(subscription) {
      $scope.pending++;
      Restangular.one('subscription', subscription.id).remove().then(function() {
        $scope.pending--;
        if ($scope.pending == 0)
          $modalInstance.close();
      });
    });
    _.each(additions, function(addition) {
      $scope.pending++;
      Restangular.all('subscription').post({
        plan: '/v1/subscriptionplan/'+addition.id+'/',
        member: user.id
      }).then(function() {
        $scope.pending--;
        if ($scope.pending == 0)
          $modalInstance.close();
      });
    });
  }
})

.controller('MembershipCtrl', function($scope, $modal, $stateParams, Restangular, Spiff) {
  var user = Restangular.one('member', $stateParams.memberID);
  function refresh() {
    user.get().then(function (u) {
      $scope.user = u;
      $scope.activeSubscriptions = u.subscriptions;
    });
    $scope.pendingAdditions = [];
    $scope.pendingRemovals = [];
  }

  refresh();

  var membershipPlans = Restangular.all('ranksubscriptionplan');
  membershipPlans.getList().then(function(plans) {<commit_msg>Also send the user id when editing subscriptions<commit_after>angular.module('spiff.members', [
  'spiff',
  'restangular',
  'ui.bootstrap.progressbar',
  'template/progressbar/progressbar.html'
])

.controller('ConfirmSubscriptionChangesCtrl', function($scope, additions, removals, user, $modalInstance, Restangular) {
  $scope.additions = additions;
  $scope.removals = removals;
  $scope.close = $modalInstance.close;
  $scope.pending = 0;
  $scope.save = function() {
    _.each(removals, function(subscription) {
      $scope.pending++;
      Restangular.one('subscription', subscription.id).remove().then(function() {
        $scope.pending--;
        if ($scope.pending == 0)
          $modalInstance.close();
      });
    });
    _.each(additions, function(addition) {
      $scope.pending++;
      Restangular.all('subscription').post({
        plan: '/v1/subscriptionplan/'+addition.id+'/',
        user: '/v1/member/'+user.id+'/'
      }).then(function() {
        $scope.pending--;
        if ($scope.pending == 0)
          $modalInstance.close();
      });
    });
  }
})

.controller('MembershipCtrl', function($scope, $modal, $stateParams, Restangular, Spiff) {
  var user = Restangular.one('member', $stateParams.memberID);
  function refresh() {
    user.get().then(function (u) {
      $scope.user = u;
      $scope.activeSubscriptions = u.subscriptions;
    });
    $scope.pendingAdditions = [];
    $scope.pendingRemovals = [];
  }

  refresh();

  var membershipPlans = Restangular.all('ranksubscriptionplan');
  membershipPlans.getList().then(function(plans) {
{'fraction_non_alphanumeric': 0.16992625841615902, 'fraction_numerical': 0.0028855402372555306, 'mean_word_length': 3.3943661971830985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6709872', 'n_tokens_mistral': 965, 'n_tokens_neox': 960, 'n_words': 149}