<commit_before>const _ = require('underscore');
const Polyglot = require('node-polyglot');
const CartoNode = require('carto-node');
const AccountMainView = require('dashboard/views/account/account-main-view');
const UserNotificationView = require('dashboard/components/user-notification/user-notification-view');
const UserNotificationModel = require('dashboard/components/user-notification/user-notification-model');
const ConfigModel = require('dashboard/data/config-model');
const UserModel = require('dashboard/data/user-model');
const OrganizationModel = require('dashboard/data/organization-model');
const AssetsVersionHelper = require('dashboard/helpers/assets-version');

const Locale = require('locale/index');

const PACKAGE = require('../../../../package.json');
const ACTIVE_LOCALE = 'en';

const polyglot = new Polyglot({
  locale: ACTIVE_LOCALE,
  phrases: Locale[ACTIVE_LOCALE]
});

window._t = polyglot.t.bind(polyglot);
window.StaticConfig = window.StaticConfig || {};
window.CartoConfig = window.CartoConfig || {};

document.title = _t('account.title');

const InitAccount = function () {
  const client = new CartoNode.AuthenticatedClient();

  const dataLoaded = function (data) {
    const ASSETS_VERSION = AssetsVersionHelper.getAssetsVersion(PACKAGE.version);
    const dashboard_notifications = data.dashboard_notifications;
    const organizationNotifications = data.organization_notifications;
    const userData = data.user_data || {};

    const configModel = new ConfigModel(
      _.extend(
        { url_prefix: userData.base_url },
        data.config
      )
    );

    const userModelOptions = { groups: userData.groups };

    if (userData.organization) {
      userModelOptions.organization = new OrganizationModel(userData.organization, { configModel });
    }

    const userModel = new UserModel(
      _.extend(userData, {
        auth_username_password_enabled: data.auth_username_password_enabled,
        can_be_deleted: data.can_be_deleted,
        can_change_password: data.can_change_password,
        cant_be_deleted_reason: data.cant_be_deleted_reason,
        logged_with_google: data.google_sign_in,
        plan_name: data.plan_name,
        plan_url: data.plan_url,
        services: data.services,
        should_display_old_password: data.should_display_old_password
      }), userModelOptions
    );

    if (!configModel.get('cartodb_com_hosted') && userModel.get('actions').builder_enabled &&
        userModel.get('show_builder_activated_message') && _.isEmpty(dashboard_notifications)) {
      const userNotificationModel = new UserNotificationModel(dashboard_notifications, {
        key: 'dashboard',
        configModel
      });

      new UserNotificationView({ // eslint-disable-line no-new
        notification: userNotificationModel
      });
    }

    new AccountMainView({ // eslint-disable-line no-new
      el: document.body,
      userModel: userModel,
      configModel: configModel,
      assetsVersion: ASSETS_VERSION,
      client,
      organizationNotifications
    });
  };

  if (window.CartoConfig && window.CartoConfig.data) {
    dataLoaded(window.CartoConfig.data);
  } else {
    client.getConfig(function (err, response, data) {
      if (err) {
        console.error(err);
        return err;
      }

      window.CartoConfig.data = data;
      dataLoaded(data);
    });
  }
};

InitAccount();
<commit_msg>Add sync-options to account page<commit_after>const _ = require('underscore');
const Polyglot = require('node-polyglot');
const CartoNode = require('carto-node');
const AccountMainView = require('dashboard/views/account/account-main-view');
const UserNotificationView = require('dashboard/components/user-notification/user-notification-view');
const UserNotificationModel = require('dashboard/components/user-notification/user-notification-model');
const ConfigModel = require('dashboard/data/config-model');
const UserModel = require('dashboard/data/user-model');
const OrganizationModel = require('dashboard/data/organization-model');
const AssetsVersionHelper = require('dashboard/helpers/assets-version');

const Locale = require('locale/index');

const PACKAGE = require('../../../../package.json');
const ACTIVE_LOCALE = 'en';

const polyglot = new Polyglot({
  locale: ACTIVE_LOCALE,
  phrases: Locale[ACTIVE_LOCALE]
});

require('dashboard/data/backbone/sync-options');

window._t = polyglot.t.bind(polyglot);
window.StaticConfig = window.StaticConfig || {};
window.CartoConfig = window.CartoConfig || {};

document.title = _t('account.title');

const InitAccount = function () {
  const client = new CartoNode.AuthenticatedClient();

  const dataLoaded = function (data) {
    const ASSETS_VERSION = AssetsVersionHelper.getAssetsVersion(PACKAGE.version);
    const dashboard_notifications = data.dashboard_notifications;
    const organizationNotifications = data.organization_notifications;
    const userData = data.user_data || {};

    const configModel = new ConfigModel(
      _.extend(
        { base_url: userData.base_url,
          url_prefix: userData.base_url },
        data.config
      )
    );

    const userModelOptions = { groups: userData.groups };

    if (userData.organization) {
      userModelOptions.organization = new OrganizationModel(userData.organization, { configModel });
    }

    const userModel = new UserModel(
      _.extend(userData, {
        auth_username_password_enabled: data.auth_username_password_enabled,
        can_be_deleted: data.can_be_deleted,
        can_change_password: data.can_change_password,
        cant_be_deleted_reason: data.cant_be_deleted_reason,
        logged_with_google: data.google_sign_in,
        plan_name: data.plan_name,
        plan_url: data.plan_url,
        services: data.services,
        should_display_old_password: data.should_display_old_password
      }), userModelOptions
    );

    if (!configModel.get('cartodb_com_hosted') && userModel.get('actions').builder_enabled &&
        userModel.get('show_builder_activated_message') && _.isEmpty(dashboard_notifications)) {
      const userNotificationModel = new UserNotificationModel(dashboard_notifications, {
        key: 'dashboard',
        configModel
      });

      new UserNotificationView({ // eslint-disable-line no-new
        notification: userNotificationModel
      });
    }

    new AccountMainView({ // eslint-disable-line no-new
      el: document.body,
      userModel: userModel,
      configModel: configModel,
      assetsVersion: ASSETS_VERSION,
      client,
      organizationNotifications
    });
  };

  if (window.CartoConfig && window.CartoConfig.data) {
    dataLoaded(window.CartoConfig.data);
  } else {
    client.getConfig(function (err, response, data) {
      if (err) {
        console.error(err);
        return err;
      }

      window.CartoConfig.data = data;
      dataLoaded(data);
    });
  }
};

InitAccount();

{'fraction_non_alphanumeric': 0.11463768115942029, 'fraction_numerical': 0.0, 'mean_word_length': 3.822501747030049, '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': '5889793', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1973, 'n_words': 345}