<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.utils import timezone
from django.db import models, migrations


def settings10to11(apps, schema_editor):
    """
    Update with new settings introduced in 1.1 which include:

    * Apps Library Title
    """
    # Figure out what time it is right now
    now = timezone.now()

    # The settings to add and their default values
    general_setting_defaults = {'Apps Library Title': 'Apps Library'}

    # Assumed values to add
    general_settings_to_add = ['Apps Library Title', ]

    # Get current settings
    Setting = apps.get_model('tethys_config', 'Setting')
    all_settings = Setting.objects.all()

    # Remove any settings that already exist
    for setting in all_settings:
        if setting in general_settings_to_add:
            general_settings_to_add.remove(setting)

    # Add remaining settings to the database
    SettingsCategory = apps.get_model('tethys_config', 'SettingsCategory')
    general_category = SettingsCategory.objects.get(name="General Settings")

    for general_setting_to_add in general_settings_to_add:
        general_category.setting_set.create(name=general_setting_to_add,
                                            content=general_setting_defaults[general_setting_to_add],
                                            date_modified=now)

    general_category.save()


class Migration(migrations.Migration):

    dependencies = [
        ('tethys_config', '0003_auto_20141223_2244'),
    ]

    operations = [
        migrations.RunPython(settings10to11),
    ]
<commit_msg>Removed social_auth from installed apps in generated settings file and fixed a few bugs in docs.<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.utils import timezone
from django.db import models, migrations


def settings10to11(apps, schema_editor):
    """
    Update with new settings introduced in 1.1 which include:

    * Apps Library Title
    """
    # Figure out what time it is right now
    now = timezone.now()

    # Get current settings
    Setting = apps.get_model('tethys_config', 'Setting')
    all_settings = Setting.objects.all()

    # Remove any settings that already exist
    SettingsCategory = apps.get_model('tethys_config', 'SettingsCategory')
    general_category = SettingsCategory.objects.get(name="General Settings")

    for setting in all_settings:
        if setting == 'Apps Library Title':
            general_category.setting_set.create(name='Apps Library Title',
                                                content='Apps Library',
                                                date_modified=now)

    general_category.save()


class Migration(migrations.Migration):

    dependencies = [
        ('tethys_config', '0003_auto_20141223_2244'),
    ]

    operations = [
        migrations.RunPython(settings10to11),
    ]

{'fraction_non_alphanumeric': 0.08090503942406582, 'fraction_numerical': 0.018512170037709975, 'mean_word_length': 2.844532279314888, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3396140', 'n_tokens_mistral': 811, 'n_tokens_neox': 760, 'n_words': 212}