<commit_before>import hashlib
from datetime import datetime

from django.db import models
from django.contrib.auth.models import User, Group, Permission
from userena.models import UserenaBaseProfile
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db.models import get_apps
from django.contrib.auth.management import create_permissions
from tumblelog.models import ApiKeyProfileMixin


class Profile(UserenaBaseProfile, ApiKeyProfileMixin):
    user = models.OneToOneField(User,
                                unique=True,
                                verbose_name=('user'),
                                related_name='my_profile')

    about_me = models.TextField(blank=True, null=True)
    website = models.URLField(blank=True, null=True)


@receiver(post_save, sender=User)
def demo_mode_set_permission(sender, instance, created, raw, **kwargs):
    try:
        Profile.objects.get_or_create(user=instance)
    except Exception, e:
        print e
        return
    g, created = Group.objects.get_or_create(name='editor')

    # ensure that all Permissions exist. not doing it would break test environments & installation
    for app in get_apps():
        create_permissions(app, None, 2)

    default_group_perms = [
        Permission.objects.get_by_natural_key(app_label='lstory', model='story', codename='add_story'),
        Permission.objects.get_by_natural_key(app_label='lstory', model='story', codename='change_story'),
        Permission.objects.get_by_natural_key(app_label='lstory', model='story', codename='delete_story'),
    ]

    for p in default_group_perms:<commit_msg>dont auto create permissions for users for loaddata<commit_after>import hashlib
from datetime import datetime

from django.db import models
from django.contrib.auth.models import User, Group, Permission
from userena.models import UserenaBaseProfile
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db.models import get_apps
from django.contrib.auth.management import create_permissions
from tumblelog.models import ApiKeyProfileMixin


class Profile(UserenaBaseProfile, ApiKeyProfileMixin):
    user = models.OneToOneField(User,
                                unique=True,
                                verbose_name=('user'),
                                related_name='my_profile')

    about_me = models.TextField(blank=True, null=True)
    website = models.URLField(blank=True, null=True)


@receiver(post_save, sender=User)
def demo_mode_set_permission(sender, instance, created, raw, **kwargs):
    if raw:
        return
    try:
        Profile.objects.get_or_create(user=instance)
    except Exception, e:
        print e
        return
    g, created = Group.objects.get_or_create(name='editor')

    # ensure that all Permissions exist. not doing it would break test environments & installation
    for app in get_apps():
        create_permissions(app, None, 2)

    default_group_perms = [
        Permission.objects.get_by_natural_key(app_label='lstory', model='story', codename='add_story'),
        Permission.objects.get_by_natural_key(app_label='lstory', model='story', codename='change_story'),
        Permission.objects.get_by_natural_key(app_label='lstory', model='story', codename='delete_story'),
    ]

    for p in default_group_perms:
{'fraction_non_alphanumeric': 0.0855207451312447, 'fraction_numerical': 0.0005644933672029354, 'mean_word_length': 3.757046979865772, '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': '5263063', 'n_tokens_mistral': 993, 'n_tokens_neox': 965, 'n_words': 239}