<commit_before>import allauth
from crispy_forms import bootstrap, layout
import django
from django import forms
from django.contrib.auth import models as auth_models
from django.contrib.sites import models as sites_models

from features.groups.models import Group
from utils import forms as utils_forms
from . import models


def validate_slug(slug):
    if slug in django.conf.settings.ENTITY_SLUG_BLACKLIST:
        raise django.core.exceptions.ValidationError(
                'Die Adresse \'%(slug)s\' ist reserviert und darf nicht verwendet werden.',
                params={'slug': slug}, code='reserved')
    if (Group.objects.filter(slug__iexact=slug).exists()
            or models.Gestalt.objects.filter(user__username__iexact=slug).exists()):
        raise django.core.exceptions.ValidationError(
                'Die Adresse \'%(slug)s\' ist bereits vergeben.',
                params={'slug': slug}, code='in-use')


class User(utils_forms.FormMixin, forms.ModelForm):
    class Meta:
        fields = ('first_name', 'last_name', 'username')
        labels = {'username': 'Adresse der Benutzerseite / Pseudonym'}
        model = auth_models.User

    def clean_username(self):
        slug = self.cleaned_data['username']
        validate_slug(slug)
        return slug


class Gestalt(utils_forms.ExtraFormMixin, forms.ModelForm):
    extra_form_class = User

    class Meta:
        fields = ('about', 'public')
        model = models.Gestalt

    def get_instance(self):
        return self.instance.user

    def get_layout(self):
        DOMAIN = sites_models.Site.objects.get_current().domain
        return (
                bootstrap.PrependedText(
                    'username',
                    '%(domain)s/' % {'domain': DOMAIN}),
                'first_name',
                'last_name',
                layout.Field('about', rows=5),
                'public',
                utils_forms.Submit('Profil ändern'),
                )


class Login(allauth.account.forms.LoginForm):
    password = forms.CharField(label='Kennwort', widget=forms.PasswordInput())<commit_msg>Quick'n'dirty fix for username change problem<commit_after>import allauth
from crispy_forms import bootstrap, layout
import django
from django import forms
from django.contrib.auth import models as auth_models
from django.contrib.sites import models as sites_models

from features.groups.models import Group
from utils import forms as utils_forms
from . import models


def validate_slug(slug, gestalt):
    if slug in django.conf.settings.ENTITY_SLUG_BLACKLIST:
        raise django.core.exceptions.ValidationError(
                'Die Adresse \'%(slug)s\' ist reserviert und darf nicht verwendet werden.',
                params={'slug': slug}, code='reserved')
    if (Group.objects.filter(slug__iexact=slug).exists()
            or models.Gestalt.objects.exclude(id=gestalt.id).filter(
                user__username__iexact=slug).exists()):
        raise django.core.exceptions.ValidationError(
                'Die Adresse \'%(slug)s\' ist bereits vergeben.',
                params={'slug': slug}, code='in-use')


class User(utils_forms.FormMixin, forms.ModelForm):
    class Meta:
        fields = ('first_name', 'last_name', 'username')
        labels = {'username': 'Adresse der Benutzerseite / Pseudonym'}
        model = auth_models.User

    def clean_username(self):
        slug = self.cleaned_data['username']
        validate_slug(slug, self.instance.gestalt)
        return slug


class Gestalt(utils_forms.ExtraFormMixin, forms.ModelForm):
    extra_form_class = User

    class Meta:
        fields = ('about', 'public')
        model = models.Gestalt

    def get_instance(self):
        return self.instance.user

    def get_layout(self):
        DOMAIN = sites_models.Site.objects.get_current().domain
        return (
                bootstrap.PrependedText(
                    'username',
                    '%(domain)s/' % {'domain': DOMAIN}),
                'first_name',
                'last_name',
                layout.Field('about', rows=5),
                'public',
                utils_forms.Submit('Profil ändern'),
                )


class Login(allauth.account.forms.LoginForm):
    password = forms.CharField(label='Kennwort', widget=forms.PasswordInput())
{'fraction_non_alphanumeric': 0.10757434944237919, 'fraction_numerical': 0.00046468401486988845, 'mean_word_length': 2.602510460251046, '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': '7457672', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1186, 'n_words': 279}