<commit_before>from . import models
from crispy_forms import bootstrap, layout
from django import forms
from django.contrib.auth import models as auth_models
from django.contrib.sites import models as sites_models
from haystack import forms as haystack_forms
from utils import forms as utils_forms


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


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

    class Meta:
        fields = ('about',)
        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/gestalt/' % {'domain': DOMAIN}),
                'first_name',
                'last_name',
                layout.Field('about', rows=5),
                utils_forms.Submit('Profileinstellungen ändern'),
                )

class GroupAttention(utils_forms.FormMixin, forms.ModelForm):
    attendee_email = forms.EmailField(disabled=True, widget=forms.HiddenInput)
    group = forms.ModelChoiceField(disabled=True, queryset=models.Group.objects.all(), widget=forms.HiddenInput)
    layout = ('attendee_email', 
            layout.HTML('<p>Möchtest Du per E-Mail benachrichtigt werden, '
                'wenn Mitglieder der Gruppe <em>{{ group }}</em> neue Beiträge '
                'veröffentlichen?</p>'),
            utils_forms.Submit('Benachrichtigungen erhalten'))

    class Meta:
        fields = ('group',)
        model = models.GroupAttention

    def save(self):
        attention = super().save(commit=False)
        attention.attendee = models.Gestalt.objects.get(user__email=self.cleaned_data['attendee_email'])
        attention.save()
        return attention


class GroupSearch(haystack_forms.ModelSearchForm):
    def no_query_found(self):
        return self.searchqueryset<commit_msg>using latest additions in search form<commit_after>from . import models
from crispy_forms import bootstrap, layout
from django import forms
from django.contrib.auth import models as auth_models
from django.contrib.sites import models as sites_models
from haystack import forms as haystack_forms
from utils import forms as utils_forms


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


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

    class Meta:
        fields = ('about',)
        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/gestalt/' % {'domain': DOMAIN}),
                'first_name',
                'last_name',
                layout.Field('about', rows=5),
                utils_forms.Submit('Profileinstellungen ändern'),
                )

class GroupAttention(utils_forms.FormMixin, forms.ModelForm):
    attendee_email = forms.EmailField(disabled=True, widget=forms.HiddenInput)
    group = forms.ModelChoiceField(disabled=True, queryset=models.Group.objects.all(), widget=forms.HiddenInput)
    layout = ('attendee_email', 
            layout.HTML('<p>Möchtest Du per E-Mail benachrichtigt werden, '
                'wenn Mitglieder der Gruppe <em>{{ group }}</em> neue Beiträge '
                'veröffentlichen?</p>'),
            utils_forms.Submit('Benachrichtigungen erhalten'))

    class Meta:
        fields = ('group',)
        model = models.GroupAttention

    def save(self):
        attention = super().save(commit=False)
        attention.attendee = models.Gestalt.objects.get(user__email=self.cleaned_data['attendee_email'])
        attention.save()
        return attention


class GroupSearch(utils_forms.FormMixin, haystack_forms.ModelSearchForm):
    initial = {'models': 'entities.group'}
    inline = True
    layout = ('q', utils_forms.Submit('Gruppe finden'))
    method = 'GET'

    def no_query_found(self):
        return self.searchqueryset.order_by('text')
{'fraction_non_alphanumeric': 0.10379635725257845, 'fraction_numerical': 0.00043888523151195964, 'mean_word_length': 2.8464135021097046, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '7174449', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1273, 'n_words': 286}