<commit_before>'use strict';

app.controller('party/network', [
  '$scope', 'pageService', function ($scope, page) {
    $scope.refreshPanel = getPartyAuth;

    //

    var actionMessages = {};

    $scope.$on('$destroy', function () {
      angular.forEach(actionMessages, function (bundle) {
        page.messages.remove(bundle.message);
      });
    });

    var getPartyAuth = function () {
      if (!$scope.party.checkPermission(page.permission.ADMIN))
        return;
      angular.forEach($scope.party.children, function (party) {
        if (!party.member && !party.site) {
          if (!actionMessages[party.id]) {
            actionMessages[party.id] = {
              party: party,
              message: page.messages.add({
                type: 'yellow',
                closeable: true,
                body: page.$sce.trustAsHtml('<span>' + page.constants.message('auth.pending.notice', {sce:page.$sce.HTML}, party.party.name) + ' <a href="' + $scope.party.editRoute('grant') + '">Manage</a>.</span>')
              })
            };
          }
          else {
            actionMessages[party.id].party = party;
          }
        }
      });
    };

    //

    $scope.isAdmin = $scope.party.checkPermission(page.permission.ADMIN);

    var userExists = function (list) {
      var user = page.models.Login.user.id;

      /* you always exist on your own page */
      return $scope.party.id <= 0 || $scope.party.id === user ||
        list.some(function (a) {
          return a.party.id === user;
        });
    };

    $scope.canGrant = !($scope.party.institution || userExists($scope.party.parents));
    $scope.canApply = !userExists($scope.party.children);

    $scope.grant = function () {
      page.$location.url(page.models.Login.user.editRoute('grant'));
      var remove = page.$rootScope.$on('partyEditGrantForm-init', function (event, form) {
        form.preSelect($scope.party);
        remove();
      });
    };
<commit_msg>Fix authorization request alert message on profile<commit_after>'use strict';

app.controller('party/network', [
  '$scope', 'pageService', function ($scope, page) {
    var actionMessages = {};

    $scope.$on('$destroy', function () {
      angular.forEach(actionMessages, function (bundle) {
        bundle.message.remove();
      });
    });

    $scope.isAdmin = $scope.party.checkPermission(page.permission.ADMIN);

    $scope.refreshPanel = function () {
      if (!$scope.isAdmin)
        return;
      angular.forEach($scope.party.children, function (party) {
        if (!party.member && !party.site) {
          if (!actionMessages[party.id]) {
            actionMessages[party.id] = {
              party: party,
              message: page.messages.add({
                type: 'yellow',
                closeable: true,
                body: page.$sce.trustAsHtml('<span>' + page.constants.message('auth.pending.notice', {sce:page.$sce.HTML}, party.party.name) + ' <a href="' + $scope.party.editRoute('grant') + '">Manage</a>.</span>')
              })
            };
          }
          else {
            actionMessages[party.id].party = party;
          }
        }
      });
    };

    //

    var userExists = function (list) {
      var user = page.models.Login.user.id;

      /* you always exist on your own page */
      return $scope.party.id <= 0 || $scope.party.id === user ||
        list.some(function (a) {
          return a.party.id === user;
        });
    };

    $scope.canGrant = !($scope.party.institution || userExists($scope.party.parents));
    $scope.canApply = !userExists($scope.party.children);

    $scope.grant = function () {
      page.$location.url(page.models.Login.user.editRoute('grant'));
      var remove = page.$rootScope.$on('partyEditGrantForm-init', function (event, form) {
        form.preSelect($scope.party);
        remove();
      });
    };

{'fraction_non_alphanumeric': 0.1672258064516129, 'fraction_numerical': 0.0005161290322580645, 'mean_word_length': 2.198019801980198, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '6116530', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1119, 'n_words': 193}