<commit_before>from django.core.management.base import BaseCommand
from dashboard.models import SnippetPos


class Command(BaseCommand):

    snippet_pos_init_data = [
        {'slug': 'about'},
        {'slug': 'experience'},
        {'slug': 'china'},
        {'slug': 'accommodations'},
    ]

    def handle(self, *args, **options):
        for d in self.snippet_pos_init_data:
            print 'Update or create SnippetPos(%s)' % d
            SnippetPos.objects.update_or_create(**d)<commit_msg>update init_data<commit_after>from django.core.management.base import BaseCommand
from dashboard.models import SnippetPos, PagePos, SiteSetting


class Command(BaseCommand):

    snippet_pos_init_data = [
        {'slug': 'about'},
        {'slug': 'experience'},
        {'slug': 'china'},
        {'slug': 'accommodations'},
    ]

    page_pos_init_data = [
        {'slug': 'about'},
        {'slug': 'experience'},
        {'slug': 'china'},
        {'slug': 'accommodations'},
    ]

    site_setting_init_data = [
        {
            'key': 'header_links',
            'defaults': {
                'value': '|'.join(d['slug'] for d in page_pos_init_data)
            },
        },
    ]

    def add_arguments(self, parser):
        parser.add_argument('--with-templates',
                            action='store_true',
                            dest='with_templates',
                            default=False,
                            help='Create default templates.')

    def handle(self, *args, **options):

        for d in self.snippet_pos_init_data:
            print 'Update or create SnippetPos(%s)' % d
            SnippetPos.objects.update_or_create(**d)

        for d in self.page_pos_init_data:
            print 'Update or create PagePos(%s)' % d
            PagePos.objects.update_or_create(**d)

        for d in self.site_setting_init_data:
            print 'Update or create SiteSetting(%s)' % d
            SiteSetting.objects.update_or_create(**d)

        if options['with_templates']:
            self.auto_templates()

        print 'All Done!\nMay your system never fail!'

    def auto_templates(self):
        print 'Create default templates...'
{'fraction_non_alphanumeric': 0.12676698586411309, 'fraction_numerical': 0.0, 'mean_word_length': 2.12981455064194, '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': '1447772', 'n_tokens_mistral': 640, 'n_tokens_neox': 627, 'n_words': 137}